| 1 |
% Generated by roxygen2: do not edit by hand |
| 2 |
% Please edit documentation in R/header.R |
| 3 |
\name{set_header} |
| 4 |
\alias{set_header} |
| 5 |
\title{Set the header information} |
| 6 |
\usage{ |
| 7 |
set_header(...) |
| 8 |
} |
| 9 |
\arguments{ |
| 10 |
\item{...}{Header components; currently possible components are |
| 11 |
\code{highlight}, \code{tikz} and \code{framed}, which contain the |
| 12 |
necessary commands to be used in the HTML header or LaTeX preamble. Note that |
| 13 |
HTML output does not use the \code{tikz} and \code{framed} components, since |
| 14 |
they do not make sense in the context of HTML.} |
| 15 |
} |
| 16 |
\value{ |
| 17 |
The header vector in \code{opts_knit} is set. |
| 18 |
} |
| 19 |
\description{ |
| 20 |
Some output documents may need appropriate header information. For example, |
| 21 |
for LaTeX output, we need to write \samp{\\usepackage{tikz}} into the |
| 22 |
preamble if we use tikz graphics; this function sets the header information |
| 23 |
to be written into the output. |
| 24 |
} |
| 25 |
\details{ |
| 26 |
By default, \pkg{knitr} will set up the header automatically. For example, if |
| 27 |
the tikz device is used, \pkg{knitr} will add \samp{\\usepackage{tikz}} to |
| 28 |
the LaTeX preamble, and this is done by setting the header component |
| 29 |
\code{tikz} to be a character string: \code{set_header(tikz = |
| 30 |
'\\usepackage{tikz}')}. Similary, when we highlight R code using the |
| 31 |
\pkg{highlight} package (i.e. the chunk option \code{highlight = TRUE}), |
| 32 |
\pkg{knitr} will set the \code{highlight} component of the header vector |
| 33 |
automatically; if the output type is HTML, this component will be different |
| 34 |
-- instead of LaTeX commands, it contains CSS definitions. |
| 35 |
|
| 36 |
For power users, all the components can be modified to adapt to a customized |
| 37 |
type of output. For instance, we can change \code{highlight} to LaTeX |
| 38 |
definitions of the \pkg{listings} package (and modify the output hooks |
| 39 |
accordingly), so we can decorate R code using the \pkg{listings} package. |
| 40 |
} |
| 41 |
\examples{ |
| 42 |
set_header(tikz = "\\\\usepackage{tikz}") |
| 43 |
opts_knit$get("header") |
| 44 |
} |