Support for non-Sweave concordances.
defSconcordance.Rd
Sweave automatically inserts concordances into the output file,
so they will be embedded in the .dvi
or .pdf
output using the LaTeX macro \Sconcordance
from
the Sweave.sty
style file.
Other vignette processing engines (e.g. knitr) do not
use Sweave.sty
, so defSconcordance
defines the macro explicitly.
The useknitr
function is specific to knitr documents.
If writeMacro
is TRUE
, it calls defSconcordance
to write the macro definition to the output file. If writeMacro
is not specified, it guesses the value by looking for
\begin{document}
somewhere in the first 100 lines of the
file.
It always writes the \input
line for the concordances into the file.
Details
This function is not necessary when using Sweave, it is only for other vignette engines.
With knitr, the concordances would be written to a file with a
name typically be of the form basename-concordance.tex
, where
the input file was basename.Rnw
. You would insert it with code like
<<results="asis">>=
patchDVI::useknitr()
@
If the document does use the Sweave.sty
style, or if it
is being included in another larger document, do
not use defSconcorance
: this can be forced by
calling patchDVI::useknitr(writeMacro = FALSE)
.
Examples
defSconcordance()
#>
#> \newcommand{\Sconcordance}[1]{%
#> \ifx\pdfoutput\undefined%
#> \csname newcount\endcsname\pdfoutput\fi%
#> \ifcase\pdfoutput\special{#1}%
#> \else%
#> \begingroup%
#> \pdfcompresslevel=0%
#> \immediate\pdfobj stream{#1}%
#> \pdfcatalog{/SweaveConcordance \the\pdflastobj\space 0 R}%
#> \endgroup%
#> \fi}