Hot answers tagged

27 votes

Export tables from R to LaTeX

Welcome! Look at ?print.xtable. This works print(xtable(newobject2, type = "latex"), file = "filename2.tex")
nebi's user avatar
  • 752
24 votes

Literate R Programming

0. tl;dr knitr is preferable to Sweave, and ezknitr is a wrapper around knitr that is probably worth using—especially if you are only building documents from the command line (but this limits you to R ...
Adam Liter's user avatar
  • 12.4k
22 votes
Accepted

How do I indent text within a tabular environment?

You could insert an \hspace{<some length>} directive at the start of cells. In the example below, I've set the length to 3mm; you're obviously free to choose a different length. \documentclass{...
Mico's user avatar
  • 479k
20 votes
Accepted

Insert R code in Latex

I'm not going to find every possible case of how R studio styles code. But maybe this will get you started. \documentclass{article} \usepackage[svgnames]{xcolor} \usepackage{listings} \lstset{...
TH.'s user avatar
  • 61.6k
19 votes
Accepted

align, aligned and R Markdown

So, just to be clear (as it says this is unanswered), just write the align (without $$): \begin{align} a_1 &= \beta_0 \\ b_1 &= \beta_1 \\ c_1 &= \beta_2 \\ d_1 &= \beta_3 \end{align} ...
John M's user avatar
  • 306
18 votes

Literate R Programming

The baseline approach is just to keep them separate. My work flow on a recent paper was as follows: I wrote an R script to calculate the statistics and generate (a) charts and (b) tables of numbers. ...
Thruston's user avatar
  • 40.9k
16 votes

How to include LaTeX package in R Markdown?

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: ...
Michael Harper's user avatar
16 votes

Using LaTeX font in R (Computer Modern)

This is how I did it in Windows: Install the extrafont package. Install Latin Modern fonts, e.g. from http://www.fontsquirrel.com/fonts/latin-modern-roman. Watch out, you need to install the TTF ...
Augustin's user avatar
  • 5,545
14 votes
Accepted

New R Logo with Tikz

The best thing is to export everything from Inkscape but here I've just exported the R letter and placed it over the ellipses via the old logo colors. You might need to adjust it properly I'm just ...
percusse's user avatar
  • 156k
12 votes

R assignment operator ("<-")

The sequence $\gets$ would do the trick.
A.Rashad's user avatar
  • 221
12 votes
Accepted

How to draw a function like sin(x)~cos(x) in tikz/pgfplots?

It is also easy with pgfplots \documentclass{standalone} \usepackage{pgfplots} \pgfplotsset{compat=1.12} \begin{document} \begin{tikzpicture} \begin{axis} \addplot+[domain=0:360,samples=101,no marks] ...
percusse's user avatar
  • 156k
12 votes
Accepted

Using biblatex with R Markdown

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 ...
moewe's user avatar
  • 171k
11 votes

Trying to include R Code with listings package

I have no sufficient reputation to comment, so I will point out that you need to include \definecolor{dkgreen}{rgb}{0,0.6,0} \definecolor{gray}{rgb}{0.5,0.5,0.5} \definecolor{mauve}{rgb}{0.58,0,0....
Cris's user avatar
  • 223
11 votes

How do I indent text within a tabular environment?

A slight improvement for the alignment of the left column (on the endash): \documentclass{article} \usepackage{booktabs} \begin{document} \noindent \begin{tabular}{@{}rccc@{}} \toprule \multicolumn{...
Bernard's user avatar
  • 269k
11 votes
Accepted

What are the key advantages of TeX over R Markdown?

As you know, a R markdown file can produce several formats but make a PDF is done via LaTeX exportation with pandocas David pointed, so in this case is equivalent to write what RStudio call a R Sweave ...
Fran's user avatar
  • 77.5k
9 votes
Accepted

How to incorporate a TEXMF tree managed by distro's package manager when using TeX Live from upstream on a GNU/Linux system?

I think the best way to achieve this is the following: Add a line TEXMFDISTRO = /usr/share/texmf to /usr/local/texlive/2015/texmf.cnf, creating it if it is not present. Copy the definition of TEXMF ...
norbert's user avatar
  • 8,030
9 votes
Accepted

How can I use Context and R together?

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 ...
ssokolen's user avatar
  • 1,693
8 votes

Workflow for converting LaTeX into Open Office / MS Word Format

Another unlisted solution is the full version of Adobe Acrobat. I tried the majority of the solutions listed here, which all failed pretty miserably. Adobe successfully converted nearly everything ...
enderland's user avatar
  • 1,624
8 votes
Accepted

Encrypt and decrypt parts of text in a LaTeX source file

Updated answer This is Enigma. Notice that Enigma is symmetric. Thus you can encode and decode at the same place. In the following example, the first input AN ENIGMA MACHINE... comes from the ...
Symbol 1's user avatar
  • 36.4k
8 votes
Accepted

Help with long table from Stargazer

A table enviroment cannot be broken across pages. Delete \begin{table}\centering and \end{table}, replace tabular with longtable, move \caption and label to immediately after \begin{longtable}{..}. ...
Torbjørn T.'s user avatar
8 votes
Accepted

Can TinyTeX replace MiKTeX or TeX Live

Yes (according to the documentation) TinyTeX can be used in place of other TeX distributions because it is essentially TeX Live. But Depending on the files you compile in TeXStudio and LyX, as ...
cfr's user avatar
  • 186k
7 votes

Howto: Set up knitr (*.Rnw compilation) from in TexStudio

Posting this is an answer which is similar to above because this will work for mac and (probably) on other linux based systems. I use OS X El Capitan (mac), and the approach is kind of same. After ...
novice's user avatar
  • 1,088
7 votes

Workflow for converting LaTeX into Open Office / MS Word Format

If all else fails (it did for me), Word 2016 can open pdfs directly. It does a decent job of converting them (I was surprised!), although equations are often converted into images.
onewhaleid's user avatar
  • 1,257
7 votes

Encrypt and decrypt parts of text in a LaTeX source file

This is not an issue related to LaTeX. You simply ask, how to encrypt parts (!) of an ASCII file. Some editors are able to do this. As an example, orgmode, a major mode of Emacs, provides encryption ...
Keks Dose's user avatar
  • 30.3k
7 votes
Accepted

Using LaTeX font in R (Computer Modern)

The selected solution. It seems to be imposible to do without installing an external library. I tried using extrafont, but then my default PDF Viewer did not have the font used. I ended up using the ...
YnkDK's user avatar
  • 341
7 votes

Literate R Programming

Are there other approaches? Yes, lazyWeave. While Sweave and knitr process LaTeX files with R chunks (R noweb files), lazyWeave can create LaTeX documents from scratch. Beside this, it is worth to ...
Fran's user avatar
  • 77.5k
7 votes
Accepted

2D correlation plot matrix with shapes

Here's a way to achieve this: \documentclass[border=5mm]{standalone} \usepackage{pgfplots} \usepgfplotslibrary{colorbrewer} \begin{document} \begin{tikzpicture} \begin{axis}[ axis equal image, % ...
Jake's user avatar
  • 230k
7 votes
Accepted

Left Quotation Marks when using RMarkdown and knitR

First of all, you need to be aware of this fact: Markdown is not LaTeX. So in general you should not expect LaTeX syntax to work in Markdown documents. The correct way to write quotes in Markdown ...
Yihui Xie's user avatar
  • 2,730
7 votes
Accepted

R Markdown/pandoc: Change how code blocks are converted to LaTeX

Thanks to @AlanMunn, I found at least 2 solutions that work for code chunks with undefined language. Both are pandoc-specific, and don't actually require rmarkdown (examples for both can be found here)...
Thunderbeef's user avatar

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