I am trying to create the following memo format in R Mardown: https://texblog.org/2012/03/07/writing-a-memo-in-latex/
---
csl: texMemo.csl
\memoto{someone}
output: pdf_document
---
I'm not sure where to put the text, whether it does in the YAML header or the body of the R Markdown. Also the Latex code does not work in the header. I'd imagine there is an easy solution but I cannot find answers. Thanks.
There is a difference between csl
and cls
. A .cls
file is a document class definition file, whereas .csl
files define citation styles.
1. Make new document class known to TeX
Following your link we get our hands on a class definition file. Usually, you would place the file in your local texmf directory tree (kind of installing it if you will) and can then create tex documents using \documentclass{texMemo}
. Check this thread on installing class definitions.
Alternatively you can simply place the .cls
file in the same directory as your RMarkdown document.
2. Create a new template
Afterwards you can set the YAML option dcoumentclass: texMemo
but you run into conflicts with the default pdf template. So what you would have to do then is to also create a pandoc template (lets call it template.tex
) and include it via the YAML option template: template.tex
. A basic template can be
\documentclass{texMemo}
\usepackage{graphicx} % needed for the logo
\memoto{$to$}
\memofrom{$from$}
\memosubject{$title$}
\memodate{$date$}
\logo{$logo$}
\begin{document}
\maketitle
$body$ % will be replaced by the content of your rmd document
\end{document}
Place it in the same directory as well.
3. Create the RMD
Finally you can create your rmarkdown document. Here is an example:
---
title: "Dinner"
to: Ralf
from: Martin
date: "`r Sys.time()`"
output:
pdf_document:
template: template.tex
logo: "\\includegraphics[width=.25\\textwidth]{unnamed.png}"
---
Let us have dinner next week.
Sidenote:
The product of such a process could be a package providing your own output format. I had some spare time and created such a package. You can install it using
devtools::install_github("martinschmelzer/rmemo")
Then you can choose the "Memorandum" template from File -> New -> RMarkdown. A logo is added using the YAML option logo: mylogo.png
. Almost all of the other YAML options documented for the default latex template work as well. So does geometry
in case you want to alter the document margins.
I took the code from Rob Oak (creator of the document class texMemo) and embetted it directly in a default latex template. If you want to make changes/imrpovements, feel free to open pull requests.