Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting documentclass in Rmarkdown v2

I would like to write my master thesis in RMarkdown v2 and I would be very glad if I could use a prepared LaTeX class.

Also I'd like to put some lines in the header and somehow add an abstract.

Can any1 knows how to do that?

Lines I'd be happy to have before \begin{document} are typically:

\usepackage[utf8]{inputenc}
\usepackage{polski}

\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{amsthm}

\usepackage{tikz}
\usepackage{float} %pakiet do obsługi obrazków
\usepackage{graphicx} %pakiet do dodawania obrazków
\usepackage{tabularx} %pakiet do utrzymywania szerokości tabel równo z szerokością tekstu
\usepackage[T1]{fontenc} %przełączamy sie na fonty EC
\usepackage{dsfont}
% \usepackage[latin2]{inputenc} %kodowania polskich znakow ISO-8859-2  - mamy utf wyzej
\usepackage{xcolor} %pakiet do nadawania kolorów w \definecolor
\usepackage{listings} %pakiet do robienia tła jak w programie R
\lstset{language=R,%    
  % numbers=left,%
   tabsize=3,%
   numberstyle=\footnotesize,%
   basicstyle=\ttfamily \footnotesize \color{black},%
   escapeinside={(*@}{@*)}}

\usepackage{longtable}


\definecolor{ListingBackground}{rgb}{0.95,0.95,0.95}
\definecolor{ListingRule}{rgb}{0.7,0.7,0.7}

\lstdefinestyle{incode}  %definiowanie stylu tła dla pisania kodu w R
{
basicstyle={\ttfamily\footnotesize},
backgroundcolor={\color{ListingBackground}},
frame={lr},
rulecolor={\color{ListingRule}},
framerule={2pt}
}


\usepackage{hyperref} %pakiet do dodawania hiperłącz
\hypersetup{colorlinks=true,
            linkcolor=blue,
            citecolor=blue,
            urlcolor=blue}


%------------------------------------------------------------------------------%
\title{ o }
\author{Marcin Kosiński}
\supervisor{prof. dr hab. Michał Nowak}
\type{magisters}
\discipline{matematyka}
\monthyear{lipiec 2015}
\date{\today}
\album{123456}

And if possible after \begin{document} .

\begin{abstract}

some text
\end{abstract}

\tableofcontents
\listoffigures 
\listoftables

Thanks for help in advance :) ! I'm aware I'll need to specify setting somehow in the begging of the Rmarkdown v2 document

---
title: "Magisterka"
author: "Marcin Kosiński"
date: "Tuesday, July 29, 2014"
output: pdf_document
documentclass: mini
includes:
      in_header: headerMgr.tex
---

EDIT:

The soultion is good YAML specification:

---
title: "Magisterka"
author: "Marcin Kosiński"
date: "Tuesday, July 29, 2014"
output:
  pdf_document:
    includes:
      in_header: header.tex
      before_body: doc_prefix.tex
---
like image 913
Marcin Kosiński Avatar asked Jul 29 '14 11:07

Marcin Kosiński


People also ask

Can you write LaTeX in R Markdown?

rmarkdown supports LaTeX style equation writing. This section introduces the two types equations, inline, and display form, and how to number equations.

What is the format for Documentclass command?

Class option are to be inserted in between square brackets, [], before the curly braces, {}, that define the class to be used. Multiple options are to be separated by a comma. Options available to the user are as follows: 10pt, 11pt, 12pt - Sets the size of the main font in the document.

Where do you put the preamble?

The preamble is the first section of an input file, before the text of the document itself, in which you tell LaTeX the type of document, and other information LaTeX will need to format the document correctly.

How do I make a PDF in R Markdown?

To transform your markdown file into an HTML, PDF, or Word document, click the “Knit” icon that appears above your file in the scripts editor. A drop down menu will let you select the type of output that you want. When you click the button, rmarkdown will duplicate your text in the new file format.


1 Answers

Based on this http://rmarkdown.rstudio.com/pdf_document_format.html, you need to include those lines:

---
title: "Magisterka"
author: "Marcin Kosiński"
date: "Tuesday, July 29, 2014"
output:
  pdf_document:
    includes:
      in_header: header.tex
      before_body: doc_prefix.tex
---

You need to remember to put all of the files (.Rmd, and all of .tex) in the same folder.

like image 83
Jot eN Avatar answered Sep 21 '22 05:09

Jot eN