0

Can someone recommend a tutorial on how to install, add, and work with LaTex/MacTex packages in rmarkdown . For example how do you install packages such as amsmath and multline? Where do you go to look for the packages that are already installed? And do you have to install packages first and then call them in the document header or can you just refer to them in-text?

I am incredibly confused and very few of the suggestions online work when I copy them, so I must be missing something absolutely fundamental but which nevertheless is not referred to anywhere online.

llewmills
  • 2,959
  • 3
  • 31
  • 58

1 Answers1

2

The correct work order would be:

  1. Install the latex packages as usual (e.g. if you have the MiKTex distribution you can use the PackageManager). If you knit your document it will use your standard latex distribution.

  2. Load your packages in the yaml header of your rmarkdown file as discribed here: How can I use latex packages in R markdown beamer? or alternativley write an latex template were you load the packages and include this (http://rmarkdown.rstudio.com/pdf_document_format.html#custom_templates).

It is indispensable that you have installed a latex distribution. Without it will not work ;) If that does not help, your code and an error message could help to figure what is wrong.

Community
  • 1
  • 1
Alex
  • 4,925
  • 2
  • 32
  • 48
  • Thank you @Alex, those links look very helpful. But I have never installed a LaTex package before. Also I know neither how to install a LaTex distribution nor even what a LaTex distribution is. A total novice I'm afraid. I use it via Rmarkdown but have no idea about fundamentals. I know this question is a bit broad but I genuinely don't know where to start. – llewmills Jun 20 '16 at 14:03
  • Do you have a windows system? – Alex Jun 23 '16 at 10:08
  • No @Alex I use a Mac with El Capitan (OSX 10.11.4). – llewmills Jun 23 '16 at 22:30
  • Yes @Alex I downloaded MacTex 2016 on the weekend. Hopefully this will fix some of the problems. So the best way to load packages is through the yaml header? Do you need to call them when you use them in the rmarkdown document via the `\usepackage{}` command? I know you don't for math equations (i assume this package is loaded by default because I have never included it in yaml or in-text). – llewmills Jun 27 '16 at 00:16