# Tag Info

93

I think this is the easiest option! --- title: "Title" author: "Me" header-includes: - \usepackage{bbm} output: pdf_document --- (Edited to have three, instead of four, hyphens to open and close the YAML front-matter)

35

As per this page on the R Markdown website, you can add whatever you want to the preamble via the in-header option in the YAML header; e.g., ---- title: "Titre" date: Fecha output: pdf_document: includes: in_header: mystyles.sty ---- In mystyles.sty, located in the same directory as the .Rmd, you could have a whole list of ...

33

Background There is a bug (or possibly multiple related bugs) in Yosemite with respect to environment variables. When a program is launched in Finder by double-clicking, it will inherit a default set of environment variables from its parent process (I believe this is launchd currently, but that's not relevant). GUI programs do not inherit variables from ~/....

27

Try adding fig_caption: yes to the YAML header of your .Rmd file. It will look something like this: --- title: "Untitled" author: "Nicholas" date: "20/09/2014" output: pdf_document: fig_caption: yes --- There's more information here: http://rmarkdown.rstudio.com/pdf_document_format.html

13

(Upgraded from a comment.) Just use library("knitr"); knit("file.Rnw") in the console (where "file.Rnw" is the name of your Sweave file, of course). This will produce "file.tex" in the working directory.

10

Ulrike Fischer's comment is correct. In RStudio for Windows, I can do this: Sys.setenv(PATH = paste(Sys.getenv("PATH"), "C:\\RMathew\\PortableApps\\MikTeX\\miktex\\bin", sep=.Platform$path.sep)) which will let me use pdfLaTeX for that session. For some reason, RStudio seemed to forget this command each time I started RStudio, but this will work when you ... 8 As of rmarkdown version 1.4 it has been possible to use the extra_dependencies parameter to list a character vector of LaTeX packages. This is useful if you need to load multiple packages: --- title: "Untitled" output: pdf_document: extra_dependencies: ["bbm", "threeparttable"] --- If you need to specify options when loading the package, you can add ... 3 This is coming late, and you may already have solved the problem - but I am posting a reply in case others encounter it. I am not sure why RStudio throws this error - but i suspect it is how it configures SWeave - which also uses pdfLateX Anyway, there is an acceptable work-around - which is to first create the tex file using msaPrettyPrint, and then use ... 3 There are basically two things causing errors in your sample code: By default, knitr prefixes R output with ##, which can't be present in your TeX file. You have to substitute something else for it. Code chunks can't be indented, so you'll have to excuse your OCD self and flush the chunk to the left of your source code. So this alone makes improves your ... 3 The character # in the link defined in the caption needs to be escaped with a double backslash. Try this: \documentclass{article} \usepackage{hyperref} \begin{document} <<TestPlot, fig.cap="\\href{http://amor.cms.hu-berlin.de/~schulzgu/gentri/\\#mieteaenderung}{If you escape the character \\# in the link with a double backslash, then everything is ... 3 The problem occurred because of an apparently faulty copy of framed.sty in the directory where basic.tex was stored. This faulty copy was not removed in any reinstalls as it was in the folder in which my .tex file was run from, not in Program Files etc. This explains why I had the same problem on my computers at work and home - I was running from the same ... 3 The compile sequence for a file using LaTeX and R code which is to be processed through knitr is as follows where * is your filename without extension. I would recommend that you run these using TeXworks (bundled with MikTeX) and R before you diagnose the problem in RStudio. RStudio in the past was very picky on setup of supporting programs (I have not ... 2 Thanks @daroczig for resolving this for me! As mentioned in his comment, by using pander() rather than print(pandoc.table()), I get the desired results. Additionally, there is no need to specify results = 'asis' in the chunk options when using this method. Below is the modified code: {r echo=F} library('pander') tab1 <- data.frame(foo=c('dog', 'cat', '... 2 knit() relies on knit_patterns to insert things into a document as it is being processed. The default patterns that knitr relies on are defined in the list all_patterns, which you can view by just typing all_patterns into an R session (assuming you have loaded knitr). If you do this, you will see the following somewhere in the output.$tex\$header.begin [1] ...

2

sudo ln -s /usr/texbin/pdflatex /usr/bin/pdflatex this worked for me. the upgrade to yosemite broke the link and it needs to redone :) you may first check for pdflatex in /usr/bin/. This is where rStudio looks. cd /usr/bin/ ls -a

2

just move the preamble of the file to be included to the main document, and just leave the body of the document to be included in the file to be input: \documentclass[12pt,a4paper]{article} \usepackage{amssymb} \usepackage{amsfonts} \usepackage{multirow} \usepackage{lscape} \usepackage{graphicx} \usepackage{hyperref} \usepackage{lettrine} \usepackage{...

2

With Rstudio using knitr, your code as is can be compiled showing the plots, but you have to add echo=FALSE to hide the R code and fit the three images in a page. Of course, the \usepackage{Sweave} is not necessary (nor using Sweave with Rstudio). You can omit also any text outside the float. If you need to stay with Sweave then you should care of the ...

2

The error is that you have indented the Sweave block, you must unindent the block. Sweave seems to be sensitive to indentation. \documentclass{article} \usepackage{subcaption} \usepackage{graphicx} \usepackage{pdfpages} \usepackage{Sweave} \begin{document} \begin{figure} \centering \begin{subfigure}[b]{0.55\textwidth} <<fig=TRUE>>= all.lab <-...

2

Sweave processes the source file by ignoring all LaTeX code and executing the R code. This means that code in a LaTeX loop will be executed only once by R. In the generated .tex code any \Sexpr variables are substituted by the value after the single run, in this case \Sexpr{x} is replaced by the string 2. When running LaTeX afterwards, the loop is executed ...

2

Your problem comes from using the "%" symbol in the RChunk. When compiled by either knitr or sweave the "%" is passed through to LaTeX and then interpreted as the beginning of a comment, there by causing the rest of that line in the TeX file to be ignored. Here is the revised code followed by the output. (Note: I also turned off the echo of the R code in ...

2

After some helpful pointers I examined latex code and looked at several different options to work with tables in R-Markdown. I tried using pander package, but the results were not as straightforward as with xtable, and I like xtable producing straight latex output - there is no intermediate markdown step, which I think there is with pander. But pander would ...

2

On Mac OSX systems, XeLaTeX should be able to use any font that is visible to Font Book.app. If the font you have is not visible in the list, find it in the Finder, and open it with Font Book. You should get a small preview of the font with an "Install Font" button, that you should press to install the font. You might need to do this for each variant of ...

2


2

After help of @nebi, it was possible to complete the table as desired. Just delete all "NA" and "clear" manually in latex. --- output: pdf_document --- {r, results='asis',message=FALSE,warning=FALSE} library(knitr) library(xtable) url <- 'https://cdn.rawgit.com/fsbmat/StackOverflow/master/' dt1 <- read.table(paste0(url, 'sim50.txt'), header = ...

2

The following works for me for PDF output --- title: "BEACH Formalisms" header-includes: \usepackage{mathtools} output: pdf_document: citation_package: natbib word_document: default bibliography: packages.bib --- `{r include=FALSE} # automatically create a bib database for R packages knitr::write_bib(c( .packages(), 'knitr', 'rmarkdown' ), '...

2

The "use a different approach" solution. As DG' mentiones one cannot use LaTeX commands in Word output. However, one can use standard RMarkdown syntax and let pandoc handle the translation to LaTeX: --- title: "BEACH Formalisms" header-includes: \usepackage{mathtools} output: pdf_document: citation_package: natbib keep_tex: yes word_document: ...

2

Yes, I made TinyTeX exactly for that purpose: https://yihui.name/tinytex/ It is minimal and should work well for converting R Markdown to PDF by default. Since you are a Ubuntu user, make sure to read FAQ 9: https://yihui.name/tinytex/faq/

Only top voted, non community-wiki answers of a minimum length are eligible