-
Notifications
You must be signed in to change notification settings - Fork 1
/
latex4research.Rmd
61 lines (45 loc) · 3.96 KB
/
latex4research.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
---
title: LaTeX for Research
---
[LaTeX](https://en.wikipedia.org/wiki/LaTeX) is a document markup language (think something like HTML) that is widely used in academia.[^pronunciation]
Its primary advantages over Word (and word processors) are the separation of content and presentation and its formatting of mathematical equations.
In addition to papers, it is often used for academic slides; many talk slides are prepared with [beamer](https://en.wikipedia.org/wiki/Beamer_(LaTeX)).
[^pronunciation]: TeX is pronounced as "teck" because the X is a Greek chi. The pronunciation of
of LaTeX is thus lah-teck or lay-teck. It is not pronounced like the rubber compund.
See this [StackExchange](http://tex.stackexchange.com/questions/17502/what-is-the-correct-pronunciation-of-tex-and-latex) question on the pronunciation of LaTeX.
## Learning LaTeX
Here are some links to get started learning LaTeX:
- [Overleaf Free & Interactive Online Introduction to LaTeX](https://www.overleaf.com/latex/learn/free-online-introduction-to-latex-part-1)
- [LaTeX Tutorial](https://www.latex-tutorial.com/tutorials/) has interactive lessons
- [ShareLaTeX Documentation](https://www.sharelatex.com/learn/)
- [Overleaf Example Templates](https://www.overleaf.com/latex/templates/) has many different examples of LaTeX documents.
- [LaTeX Wikibook](https://en.wikibooks.org/wiki/LaTeX)
- [Not So Short Introduction to LaTeX](https://tobi.oetiker.ch/lshort/lshort.pdf) is a classic, but not as as newby friendly as the others.
## Writing LaTeX
- Use an online service such as [Overleaf](https://www.overleaf.com/) or [ShareTeX](https://www.sharelatex.com/). These are great for collaboration, but become inflexible
when you want to customize your workflow.
- Write it with a specialized editor such as [TeXmaker](http://www.xm1math.net/texmaker/), [TeXStudio](http://www.texstudio.org/), or [TeXshop](http://pages.uoregon.edu/koch/texshop/). These generally have
built ways to insert text, and also live preview. I would stay away from editors such as [LyX](https://www.lyx.org/) that are WYSWYG.
- Write it with an general purpose editor such as [Atom](https://atom.io/) or [Sublime Text](https://www.sublimetext.com/).[^1] Most editors have a plugin
to make writing LaTeX easier. For Atom there is [LaTeXTools](https://atom.io/packages/latextools), and for Sublime Text, [LaTeXTools](https://github.com/SublimeText/LaTeXTools)
[^1]: And of course [Vim](http://www.vim.org/) or [Emacs](https://www.gnu.org/software/emacs/).
## LaTeX with R
This is pretty easy. Rnw, also called Sweave, documents allow you to mix R chunks with LaTeX.
This is similar to R markdown, but with LaTeX instead of markdown.[^2]
[knitr](http://yihui.name/knitr/).
Many packages, such as xtable](https://cran.r-project.org/package=xtable), [stargazer](ttps://cran.r-project.org/package=stargazer), or [texreg](ttps://cran.r-project.org/package=texreg) produce formatted output in LaTeX.
When you use these programs, do not copy and paste the output. Instead, save it to a file,
and use `\input{}` to include the contents in your document.
[^2]: And [Sweave](https://www.statistik.lmu.de/~leisch/Sweave/) files preceded R markdown and knitr by many years.
## Useful Packages
TODO
## My workflow
At the moment, I use emacs with [AucTeX](http://www.gnu.org/software/auctex/) for writing pure LaTeX documents.
However, I've started using Atom more and more as a general text editor.
I use RStudio for writing Rnw files.
For papers, I haven't moved to using (R) markdown and pandoc yet, because I find the layout and reference support still too
limiting; I end up writing enough LaTeX that I figure I might as well write the whole thing in LaTeX.
I've been using Overleaf for coauthoring in a couple of cases.
I often build my document using [Makefiles](https://en.wikipedia.org/wiki/Make_(software)).
For smaller papers, I'll use Rnw files with knitr, but for larger projects, I'll separate the R code into scripts
and include the output into