| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/pdf_document.R |
| 3 |
\name{pdf_document} |
| 4 |
\alias{pdf_document} |
| 5 |
\alias{latex_document} |
| 6 |
\alias{latex_fragment} |
| 7 |
\title{Convert to a PDF/LaTeX document} |
| 8 |
\usage{ |
| 9 |
pdf_document( |
| 10 |
toc = FALSE, |
| 11 |
toc_depth = 2, |
| 12 |
number_sections = FALSE, |
| 13 |
fig_width = 6.5, |
| 14 |
fig_height = 4.5, |
| 15 |
fig_crop = "auto", |
| 16 |
fig_caption = TRUE, |
| 17 |
dev = "pdf", |
| 18 |
df_print = "default", |
| 19 |
highlight = "default", |
| 20 |
template = "default", |
| 21 |
keep_tex = FALSE, |
| 22 |
keep_md = FALSE, |
| 23 |
latex_engine = "pdflatex", |
| 24 |
citation_package = c("default", "natbib", "biblatex"), |
| 25 |
includes = NULL, |
| 26 |
md_extensions = NULL, |
| 27 |
output_extensions = NULL, |
| 28 |
pandoc_args = NULL, |
| 29 |
extra_dependencies = NULL |
| 30 |
) |
| 31 |
|
| 32 |
latex_document(...) |
| 33 |
|
| 34 |
latex_fragment(...) |
| 35 |
} |
| 36 |
\arguments{ |
| 37 |
\item{toc}{\code{TRUE} to include a table of contents in the output} |
| 38 |
|
| 39 |
\item{toc_depth}{Depth of headers to include in table of contents} |
| 40 |
|
| 41 |
\item{number_sections}{\code{TRUE} to number section headings} |
| 42 |
|
| 43 |
\item{fig_width}{Default width (in inches) for figures} |
| 44 |
|
| 45 |
\item{fig_height}{Default height (in inches) for figures} |
| 46 |
|
| 47 |
\item{fig_crop}{Whether to crop PDF figures with the command |
| 48 |
\command{pdfcrop}. This requires the tools \command{pdfcrop} and |
| 49 |
\command{ghostscript} to be installed. By default, \code{fig_crop = TRUE} |
| 50 |
if these two tools are available.} |
| 51 |
|
| 52 |
\item{fig_caption}{\code{TRUE} to render figures with captions} |
| 53 |
|
| 54 |
\item{dev}{Graphics device to use for figure output (defaults to pdf)} |
| 55 |
|
| 56 |
\item{df_print}{Method to be used for printing data frames. Valid values |
| 57 |
include "default", "kable", "tibble", and "paged". The "default" method |
| 58 |
uses a corresponding S3 method of \code{print}, typically |
| 59 |
\code{print.data.frame}. The "kable" method uses the |
| 60 |
\code{\link[knitr:kable]{knitr::kable}} function. The "tibble" method uses |
| 61 |
the \pkg{tibble} package to print a summary of the data frame. The "paged" |
| 62 |
method creates a paginated HTML table (note that this method is only valid |
| 63 |
for formats that produce HTML). In addition to the named methods you can |
| 64 |
also pass an arbitrary function to be used for printing data frames. You |
| 65 |
can disable the \code{df_print} behavior entirely by setting the option |
| 66 |
\code{rmarkdown.df_print} to \code{FALSE}. See |
| 67 |
\href{https://yihui.org/rmarkdown/html-document.html#data-frame-printing}{Data |
| 68 |
frame printing section} in bookdown book for examples.} |
| 69 |
|
| 70 |
\item{highlight}{Syntax highlighting style passed to Pandoc. |
| 71 |
|
| 72 |
Supported built-in styles include "default", "tango", "pygments", "kate", |
| 73 |
"monochrome", "espresso", "zenburn", "haddock", and "breezedark". |
| 74 |
|
| 75 |
Two custom styles are also included, "arrow", an accessible color scheme, |
| 76 |
and "rstudio", which mimics the default IDE theme. Alternatively, supply a |
| 77 |
path to a \samp{.theme} file to use |
| 78 |
\href{https://pandoc.org/MANUAL.html#syntax-highlighting}{a custom Pandoc |
| 79 |
style}. Note that custom theme requires Pandoc 2.0+. |
| 80 |
|
| 81 |
Pass \code{NULL} to prevent syntax highlighting.} |
| 82 |
|
| 83 |
\item{template}{Pandoc template to use for rendering. Pass "default" to use |
| 84 |
the rmarkdown package default template; pass \code{NULL} to use pandoc's |
| 85 |
built-in template; pass a path to use a custom template that you've |
| 86 |
created. See the documentation on |
| 87 |
\href{https://pandoc.org/MANUAL.html}{pandoc online documentation} for |
| 88 |
details on creating custom templates.} |
| 89 |
|
| 90 |
\item{keep_tex}{Keep the intermediate tex file used in the conversion to PDF. |
| 91 |
Note that this argument does not control whether to keep the auxiliary |
| 92 |
files (e.g., \file{.aux}) generated by LaTeX when compiling \file{.tex} to |
| 93 |
\file{.pdf}. To keep these files, you may set \code{options(tinytex.clean = |
| 94 |
FALSE)}.} |
| 95 |
|
| 96 |
\item{keep_md}{Keep the markdown file generated by knitting.} |
| 97 |
|
| 98 |
\item{latex_engine}{LaTeX engine for producing PDF output. Options are |
| 99 |
"pdflatex", "lualatex", "xelatex" and "tectonic".} |
| 100 |
|
| 101 |
\item{citation_package}{The LaTeX package to process citations, \code{natbib} |
| 102 |
or \code{biblatex}. Use \code{default} if neither package is to be used, |
| 103 |
which means citations will be processed via the command |
| 104 |
\command{pandoc-citeproc}.} |
| 105 |
|
| 106 |
\item{includes}{Named list of additional content to include within the |
| 107 |
document (typically created using the \code{\link{includes}} function).} |
| 108 |
|
| 109 |
\item{md_extensions}{Markdown extensions to be added or removed from the |
| 110 |
default definition of R Markdown. See the \code{\link{rmarkdown_format}} for |
| 111 |
additional details.} |
| 112 |
|
| 113 |
\item{output_extensions}{Pandoc extensions to be added or removed from the |
| 114 |
output format, e.g., \code{"-smart"} means the output format will be |
| 115 |
\code{latex-smart}.} |
| 116 |
|
| 117 |
\item{pandoc_args}{Additional command line options to pass to pandoc} |
| 118 |
|
| 119 |
\item{extra_dependencies}{A LaTeX dependency \code{latex_dependency()}, a |
| 120 |
list of LaTeX dependencies, a character vector of LaTeX package names (e.g. |
| 121 |
\code{c("framed", "hyperref")}), or a named list of LaTeX package options |
| 122 |
with the names being package names (e.g. \code{list(hyperef = |
| 123 |
c("unicode=true", "breaklinks=true"), lmodern = NULL)}). It can be used to |
| 124 |
add custom LaTeX packages to the .tex header.} |
| 125 |
|
| 126 |
\item{...}{Arguments passed to \code{pdf_document()}.} |
| 127 |
} |
| 128 |
\value{ |
| 129 |
R Markdown output format to pass to \code{\link{render}} |
| 130 |
} |
| 131 |
\description{ |
| 132 |
Formats for converting from R Markdown to a PDF or LaTeX document. |
| 133 |
} |
| 134 |
\details{ |
| 135 |
See the \href{https://yihui.org/rmarkdown/pdf-document.html}{online |
| 136 |
documentation} for additional details on using the \code{pdf_document} |
| 137 |
format. |
| 138 |
|
| 139 |
Creating PDF output from R Markdown requires that LaTeX be installed. |
| 140 |
|
| 141 |
R Markdown documents can have optional metadata that is used to generate a |
| 142 |
document header that includes the title, author, and date. For more details |
| 143 |
see the documentation on R Markdown \link[=rmd_metadata]{metadata}. |
| 144 |
|
| 145 |
R Markdown documents also support citations. You can find more information on |
| 146 |
the markdown syntax for citations in the |
| 147 |
\href{https://pandoc.org/MANUAL.html#citations}{Bibliographies |
| 148 |
and Citations} article in the online documentation. |
| 149 |
|
| 150 |
Many aspects of the LaTeX template used to create PDF documents can be |
| 151 |
customized using metadata. For example: |
| 152 |
|
| 153 |
\tabular{l}{ |
| 154 |
\code{---} \cr |
| 155 |
\code{title: "Crop Analysis Q3 2013"} \cr |
| 156 |
\code{fontsize: 11pt} \cr |
| 157 |
\code{geometry: margin=1in} \cr |
| 158 |
\code{---} |
| 159 |
} |
| 160 |
|
| 161 |
Available metadata variables include: |
| 162 |
|
| 163 |
\describe{ |
| 164 |
\item{\code{lang}}{Document language code (e.g. "es", "fr", "pt-BR")} |
| 165 |
\item{\code{fontsize}}{Font size (e.g. 10pt, 11pt, 12pt)} |
| 166 |
\item{\code{documentclass}}{LaTeX document class (e.g. article)} |
| 167 |
\item{\code{classoption}}{Option for \code{documentclass} (e.g. oneside); may be repeated} |
| 168 |
\item{\code{geometry}}{Options for geometry class (e.g. margin=1in); may be repeated} |
| 169 |
\item{\code{mainfont, sansfont, monofont, mathfont}}{Document fonts (works only with xelatex and lualatex, see the \code{latex_engine} option)} |
| 170 |
\item{\code{linkcolor, urlcolor, citecolor}}{Color for internal, external, and citation links (red, green, magenta, cyan, blue, black)} |
| 171 |
\item{\code{linestretch}}{Options for line spacing (e.g. 1, 1.5, 3)} |
| 172 |
} |
| 173 |
} |
| 174 |
\examples{ |
| 175 |
\dontrun{ |
| 176 |
library(rmarkdown) |
| 177 |
|
| 178 |
# simple invocation |
| 179 |
render("input.Rmd", pdf_document()) |
| 180 |
|
| 181 |
# specify an option for latex engine |
| 182 |
render("input.Rmd", pdf_document(latex_engine = "lualatex")) |
| 183 |
|
| 184 |
# add a table of contents and pass an option to pandoc |
| 185 |
render("input.Rmd", pdf_document(toc = TRUE, "--listings")) |
| 186 |
} |
| 187 |
} |