Hot answers tagged

8

In short, yes, using the filter module. In fact, the filter module has a specific example for using R. I'm not sure about Sweave, but the integration doesn't seem to be quite as tight as something like knitr (although I'm no filter expert either). The author of the module, Aditya, is quite active on this site so he will likely chime in with his answer. In ...


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 ...


7

One rule of LaTeX is that it is a bad idea to load packages twice and that it is an error to load the same package twice with different options. This is what happens here. You load biblatex manually in your preable.tex and then you say citation_package: biblatex in your .yml file, so the markdown conversion loads biblatex for you again. You get an error as ...


5

\documentclass[tikz]{standalone} \definecolor{grayR}{HTML}{8A8990} \definecolor{grayL}{HTML}{C4C7C9} \definecolor{blueM}{HTML}{1F63B5} \begin{document} \begin{tikzpicture} \shade [right color=grayR,left color=grayL,shading angle=60] (-3.55,0.3) .. controls (-3.55,1.75) and (-1.9,2.7) .. (0,2.7) .. controls (2.05,2.7) and (3.5,1.6) .. (3.5,0.3) .. ...


4

It is actually really easy to produce a PDF with knitr with LaTeX-code in RStudio with biblatex for citations. You have to use the option bib_engine = "biber" from the package tinytex::latexmk within knitr::knit2pdf. Just like here: knitr::knit2pdf(file.Rnw, bib_engine = "biber")


4

In RStudio it should be > Tools > Global Options... > Sweave > Check Clean auxiliary output after compile > Apply > OK but for some reason actually do not clean that files. Funnily, that happen with .Rnw but not .Rmd files, although both are finally converted to LaTeX.


3

foo.R: # ---- foo bah <- data.frame(a=c(1,2,3),b=c(4,5,6)) library(xtable) print( xtable(bah, cap="My data frame", label="footable"), table.placement="!b", booktabs = T) plot(bah$a,bah$b) a <- mean(bah$a) b <- mean(bah$b) Note: The # ---- foo is not only a comment. It is a must label, as is. ...


3

Macros like \ge is defined by default to be equivalent to \geq or ≥. However, \gt is not. Assuming it should be equivalent to >, you can just add --- # ... header-includes: - \newcommand{\gt}{>} - \newcommand{\lt}{<} # ... --- nath defines them as well \edef\lt{\mathchar\the\mathcode`<\relax} \edef\gt{\mathchar\the\mathcode`>\relax} so ...


3

You cannot use result=tex option of Sweave in a R chunk in R markdown with uses the knitr syntax, but more important, you cannot use the R chunk syntax for noweb (.Rnw) files. Thas is, some like: <<name,results='asis', option, option, ...>>= 2+2 @ Is still wrong, even if the chunk is inside the inside a LaTeX environment. Instead you must ...


3

According to the README file, the true type versions of the Bera fonts (the original Bitstream Vera fonts, as Ulrike Fischer already pointed out) are part of the GNOME project: "Bera" is a set of three PostScript Type1 font families: Bera Serif (a slab-serif Roman), Bera Sans (a Frutiger descendant), and Bera Mono (monospaced/typewriter). The fonts ...


3

If your source code comes out garbled when you reopen the file, the chances are it was saved in a different encoding from the one that it opened in. This is something you need to fix with your editor: Resave the file with the UTF-8 encoding. Make sure the default encoding in your editor is set to UTF-8 also. Since you don't say which editor you are using ...


3

A example code is worth a thousand words: \documentclass{article} \begin{document} <<echo=F,results="hide">>= set.seed(100) options(scipen=0) x <- rnorm(10, 155, 10) y <- rnorm(10, 150, 10) accept <- if (t.test(x,y)$p.value>0.05) {print("rejected")} else {print("accepted")} @ Our hypothesis that $x$ is taller than $y$ was \Sexpr{...


3

Markdown certainly supports pre- and post-citation material. I suspect that this is more common in author/year type citation schemes, so perhaps the numeric schemes don't implement it. For example if I change your style to apa.csl then the following example works fine. As Mico notes in the comments, to prevent styles from changing the capitalization on ...


3

With $$ you are entering math mode. And in math mode you should use math fonts and math switches. \[\mathit{ABC} = \mathrm{minimum}{\mathit{XYZ}, \mathit{ZYX}}\]


3

Generally, all your entries must have a unique entry key. In the shown snippet the entry key for both entries is empty. This means that the second entry is simply skipped. Technically, BibTeX allows at most one entry with an empty key, but this is a really bad idea as those entries can't be cited explicitly and Biber will choke on them. Just give your ...


2

I could not reinstall svg2tikz plugin on the new version of inkscape, but in command line on ubuntu, one can run: wget https://upload.wikimedia.org/wikipedia/commons/1/1b/R_logo.svg pip install git+git://github.com/aloisklink/svg2tikz --user svg2tikz --figonly R_logo.svg First line downloads the svg for the R logo, second installs the svg2tikz python ...


2

You are not using the calc LaTeX package. To find the list of packages required by huxtable, you can use report_latex_dependencies() from within R, then paste them or print them to your TeX file.


2

Let's assume you have the following data in a file named nameslist.csv: NAME Adolfo Akilah Amie Andree Angel Angelika Annabell Aracely Bailey Bambi Bridgett Cameron Candra Carole Carson Cassi Cecila Cecilia Ceola Chau Cherlyn Clorinda Cristal Danuta Darin Darnell Debra Denice Denise Denver Diedra Donovan Dorothea Edgar Eliza Elliott Elvira Emely Emerald ...


2

In one word: knitr. In more words: Save it as example.Rnw and compite and edit With Rstudio, then use the "Compile PDF" button. \documentclass[11pt]{article} \usepackage[paper=a4paper, top=1in,bottom=1.1in,right=0.9in,left=0.9in]{geometry} \begin{document} I want all fonts in R plots to be exactly like this one. <<dev="tikz", echo=F, fig.cap="A tikz ...


2

Just guessing… \documentclass{article} \begin{document} $y_i = \beta_0 + \beta_1 x_i + \beta_2 x_i^2 + e_i$ \end{document}


2

I would use the subcaption package: \documentclass[10pt]{book} \usepackage{float} \usepackage{subcaption} %---------------- show page layout. don't use in a real document! \usepackage{showframe} \renewcommand\ShowFrameLinethickness{0.15pt} \renewcommand*\ShowFrameColor{\color{red}} %---------------------------------------------------------------% \begin{...


2

The inline code is to show code verbatim, not to "interpret" that code. What you want is completely contradictory. So you have two options: 1. Text with `in line` $\beta$ `code` or ... 2. Text with \texttt{in line $\beta$ code}.


2

Print as verbatim is one approach, but what if you do not want the teletype font, bute the default font? In LaTeX, "_" is an active character like % or $ , so except in verbatim mode, you should use \_ to see printed a low line character (U+005F in UTF8). To pass a string from R to LaTeX, you must also escape any backslash character, so R should produce ...


2

In your example the \end{document} is missing. If I insert this, it seems to work. This report provides the results blah blah blah.\cite{edgeRRef} outputs This report provides the results blah blah blah.[1]


2

While its is good to know that every reference should have a key, a R user should not edit bib files, at least to cite the R packages used in a report. Let R work for you. Test.Rnw: \documentclass{article} \usepackage{natbib} \begin{document} <<echo=F,message=F>>= bibtex::write.bib(c("ggplot2","tools"), file='test') @ \bibliographystyle{...


2

You have indented a first level list with 4 spaces, so it is not an enumerated environment but a verbatim monospaced text. Remove the indentation and it will work as expected.


2

Since you are using results='asis' you can output additional LaTeX code with cat, e.g. cat("\\begin{center}") print(x, add.to.row=addtorow,include.colnames = FALSE, hline.after = NULL, size="\\fontsize{10pt}{12pt}\\selectfont") cat("\\end{center}") works for me when I use some standard data set.


1

It works with the knitr package, in overleaf you dont have to load it. Everything inside <<echo= F>>= #Code goes here d <- read.csv("data.csv") @ is R code. If you create objects in a chunk like this you can print and manipulate those in text with \Sexpr{head(d)}.


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