[R-pkg-devel] Using the amsmath package in a vignette.

Göran Broström gor@n@bro@trom @end|ng |rom umu@@e
Thu Mar 4 07:39:31 CET 2021


Hi Rolf,

On 2021-03-04 03:51, Rolf Turner wrote:
> 
> I am trying to create a vignette in a package (basically just using 
> LaTeX code; no R calculations or data are involved).
> 
> The LaTeX code involves the use of the align* environment from the
> amsmath package.  When I try to run Sweave() on the *.Rnw file I get
> a corresponding *.tex file, but then when I run pdflatex on that file
> I get an error:
> 
>> ! LaTeX Error: Command \iint already defined. Or name \end...
>> illegal, see p.192 of the manual.
>> 
>> See the LaTeX manual or LaTeX Companion for explanation. Type  H
>> <return>  for immediate help. ...
>> 
>> l.649 ...d{\iint}{\DOTSI\protect\MultiIntegral{2}}
> 
> which is completely opaque to me.

Shouldn't be; the amsmath package defines \iint, and the error message 
says that it was already defined, probably in another package you have 
loaded. Easily found by googling. My first hit was

https://tex.stackexchange.com/questions/356599/command-iint-already-defined

> If I don't have \usepackage{amsmath} in the *.Rnw file, I get 
> (unsurprisingly) an error message to the effect that the align* 
> environment is undefined.
> 
> Is there any way to make use of amsmath facilities in a vignette?

Absolutely, I am doing it with no problem. I have in one preamble


\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
% \VignetteIndexEntry{Parametric duration models}
\newcommand{\btheta}{{\ensuremath{\boldsymbol{\theta}}}}
\newcommand{\bbeta}{{\ensuremath{\boldsymbol{\beta}}}}
\newcommand{\bz}{\ensuremath{\mathbf{z}}}
and so forth

> 
> Alternatively, is there any way to simply use the pdf output
> obtained by processing an ordinary LaTeX file as a vignette?  I have
> done a bit of web searching on this, but all of the hits that I get
> seem to be substantially out of date.  They refer to putting
> vignettes in /inst/doc and I'm pretty sure that this is no longer how
> it's done. (But I find all of the vignette business rather
> bewildering and confusing.)
> 
> Grateful for any advice.

Have you read the "Writing R Extensions"? There 'inst/doc' is mentioned 
under 'Non-Sweave vignettes'.

Best, Göran Broström
> 
> cheers,
> 
> Rolf Turner
>



More information about the R-package-devel mailing list