Rmarkdown knitting to markdown changes hashed headers - hash

I am trying to knit from Rmarkdown to markdown.
When knitting
---
output: md_document
---
# Header 1
## Header 2
I get
Header 1
========
Header 2
--------
but I want the Headers to remain hashed which is valid markdown. How can I accomplish this from within the Rmd?
It works with
---
output:
html_document:
keep_md: true
---
but since I am conditionally compiling different content in the actual rmarkdown to html and md I cannot use this option.

When you run
---
output:
html_document:
keep_md: true
---
# Header 1
## Header 2
In the present working directory of this .Rmd file, Rstudio/Rmarkdown should render a .md file that is the actual Markdown file, while also rendering an HTML file. Which, when opens, shows the code just like the .RMD file has
This link May also give some more info regarding Rmarkdon YAML options for more markdown control.

Related

Github not navigating properly to the markdown header link

We are on Github Enterprise
I have created a md file with several headers like
# test
## subtest
# test1
## subtest1
# test2
## subtest2
# test3
## subtest3
Now when the md file is rendered in github .I create a link by right clicking on the #test 2 header and copy the link address.
I am navigated to somewhere in the content of #test header
Similarly all the header links naivgation are inconsistently behaving.
Best Regards,
Saurav

Papaja and quarto

Has anyone looked into using papaja with quarto, yet?
I've tried rendering a qmd file with
format:
papaja::apa6_pdf:
latex_engine: lualatex
keep_tex: true
in the header, but in seems that the render fails because of invalid YAML.

How can I solve this can any one help me with it

''' Conversion error: Jekyll::Converters::Scss encountered an error while converting 'assets/css/style.scss': No such file or directory # dir_chdir - /github/workspace/docs'''
At the top of the style.scss file Write the code in your style.scss file and make sure in your scss file doesn't have any coding error
---
# this ensures Jekyll reads the file to be transformed into CSS later
---
You can share your scss file also You can follow the doc https://github.com/mmistakes/minimal-mistakes/issues/220

How do I pass a tex template to Rmarkdown?

I want rmarkdown/knitr to create a pdf output using a custom tex template.
It is possible to override pandoc defaults with:
output:
pdf_document:
pandoc_args: '--pdf-engine=xelatex'
---
However it is not working when I add a further command:
'--pdf-engine=xelatex --template template.tex'
The error:
Unknown option --template template.tex .
How can I set a custom tex template using rmarkdown?
Much easier solution:
mainfont: Minion Pro
output:
pdf_document:
latex_engine: xelatex
---

Where is the .tex file kept when compiling Rmd in Rstudio server

This may sound like a dumb question, but I'd like to know where is the .tex file saved, when I compile a pdf document from a Rmd file, using RStudio server.
I added the keep_tex option, so the header of Rmd looks like this :
---
output:
pdf_document:
keep_tex: yes
---
Then when I compiled, the output looks like this
|...................... | 33%
ordinary text without R code
|........................................... | 67%
label: plot
processing file: test.Rmd
cropping /tmp/Rtmpb1x3Q0/preview-3bfe24922427.dir/test_files/figure-latex/plot-1.pdf
PDFCROP 1.33, 2012/02/01 - Copyright (c) 2002-2012 by Heiko Oberdiek.
==> 1 page written on `/tmp/Rtmpb1x3Q0/preview-3bfe24922427.dir/test_files/figure-latex/plot-1.pdf'.
|.................................................................| 100%
ordinary text without R code
/usr/lib/rstudio-server/bin/pandoc/pandoc test.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output /tmp/Rtmpb1x3Q0/preview-3bfe24922427.dir/test.tex --template /home/myusername/R/x86_64-pc-linux-gnu-library/3.1/rmarkdown/rmd/latex/default.tex --highlight-style tango --latex-engine pdflatex --variable 'geometry:margin=1in'
output file: test.knit.md
/usr/lib/rstudio-server/bin/pandoc/pandoc test.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output /tmp/Rtmpb1x3Q0/preview-3bfe24922427.dir/test.pdf --template /home/myusername/R/x86_64-pc-linux-gnu-library/3.1/rmarkdown/rmd/latex/default.tex --highlight-style tango --latex-engine pdflatex --variable 'geometry:margin=1in'
Output created: /tmp/Rtmpb1x3Q0/preview-3bfe24922427.dir/test.pdf
I'd like to find the intermediate .tex file (or test.knit.md), and do a bit of editing. Except it is no where to be found. Not in the working directory, or /home/myusername/, or /, or /tmp/Rtmpb1x3Q0/.
I'd really appreciate it if someone has the answer.
Actually, this first line in the console
/usr/lib/rstudio-server/bin/pandoc/pandoc test.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash-implicit_figures --output /tmp/Rtmpb1x3Q0/preview-3bfe24922427.dir/test.tex --template /home/myusername/R/x86_64-pc-linux-gnu-library/3.1/rmarkdown/rmd/latex/default.tex --highlight-style tango --latex-engine pdflatex --variable 'geometry:margin=1in'
told us that the output .tex file is in /tmp/Rtmpb1x3Q0/preview-3bfe24922427.dir/test.tex
Somehow I did not find the file last time, but on a recent instance, the .tex file is actually there, so that answers the question.
The initial code from the question
---
output:
pdf_document:
keep_tex: yes
---
Throws an error for me, while the following does not:
---
output:
pdf_document: default
keep_tex: T
---
However, I was still unable to find the .tex file following the console output. It appears to still not be saved. Instead what worked easily was running the following lines in the R studio console:
#install.packages(rmarkdown)
rmarkdown::render("FileName.Rmd", output_format = latex_document())
The file "FileName.Rmd" needs to be in the current working directory - which is where the .tex file will be saved.