Facing a very weird problem when knitting my rmarkdown document to a pdf...
Everything comes out nicely but halfway through the document, rmarkdown seems to not recognise the latex commands and decides to print them out directly in the pdf, leading to my pdf having latex commands like:
\begin{figure}[H]
and this affect the rest of the document.
I am not sure if its because of some encoding issues -- how does one check this and is there a solution to this?
Have been struggling with this for hours!
Would appreciate any advice, thanks!
Found the problem finally! Its % sign in my figure caption!
Hope this might help anyone who is having trouble with latex.
Related
I saw this https://bookdown.org/yihui/rmarkdown-cookbook/fig-chunk.html and I'm wondering if there is something similar if a use a .rnw file that I compile in a pdf with knitr.
Thanks in advance for the help.
Yes, you can use the same trick. All you need to do is use the right syntax in your document, i.e., LaTeX in your case. Below is a translation of the example you mentioned from (R) Markdown to Rnw/LaTeX:
We generate a plot in this code chunk but do not show it:
<<cars-plot, dev='pdf', fig.show='hide'>>=
plot(cars)
#
After another paragraph, we introduce the plot:
\includegraphics{\Sexpr{knitr::fig_chunk('cars-plot', 'pdf')}}
I am making a presentation in latex (Oxygen Beamer Template) in the online latex editor Overleaf, it is the original template that overleaf is available to modify it, the idea is to be able to implement it in Rmarkdown. So my question is if there is any package in R or trick to be able to capture the result of latex as a presentation in Rmarkdown?
Anyway when I have an advance or discover something I share it in this same way.
Thanks for your time, regards!
Hi knitr experts: I cannot for the life of me figure out how to compile the knitr Miminal Demo .Rnw document correctly. When I download and run Yihui's Minimal Demo of knitr .Rnw file (link), the document compiles but incorrectly handles the R chunks:
I changed nothing, just opened and compiled. Help welcome. As an aside, would very much appreciate tips on whether this is how I should be going about adding R code into a latex template that UT-Austin requires for dissertation publication. Thanks.
I can reproduce your PDF file when using Sweave instead of knitr for translating the .Rnw file. When switching to knitr via the RStudio options (c.f. https://support.rstudio.com/hc/en-us/articles/200532247), I get an error message and no PDF, which probably reproduces #r2evans' results in the comments. I also get a warning message that line 19 is Sweave specific (\SweaveOpts{concordance=TRUE}). Removing that line, the file processes with knitr correctly producing
If I have an R block in an Rmarkdown notebook, the code is visible in the rendered nb.html file. However, if I have a SQL block, I can't find a way to make the code visible in the rendered file.
However, if I generate an html_document (standard knitr) instead of an html_notebook, the rendered HTML does include the SQL code (and output).
Is there a way to get the notebook output to do something closer to what the knit output does?
I've also encountered this recently, Harlan, and began by asking if there's a way to get notebook output more like knit output.
I then wondered if there was a way to get knit output more like notebook output and realised that there was.
After asking the folks at RStudio, I learnt that you can add the following line to the YAML options in order to generate a html_document that, when rendered, enables the RMD to be downloaded. Specifically, use:
output:
html_document:
code_download: true
I now use that in all of my code and it works well. I hope it helps you, too.
I'm trying to produce a word document with R markdown. Usually i'm creating pdf-files with no problems. I use Latex syntax to create accents for characters for normal text like:
$\'{e}\'{e}$n
And then it produces "één" correctly when i knit my pdf. But this doesn't seem to work when i knit a word document, it will just show "$\'{e}\'{e}$n". So no good. Does anyone know how to solve this problem? Thanks!