diff --git a/share/texmf/tex/latex/Rd.sty b/share/texmf/tex/latex/Rd.sty index 40646aff314..f3300cab414 100644 --- a/share/texmf/tex/latex/Rd.sty +++ b/share/texmf/tex/latex/Rd.sty @@ -206,23 +206,37 @@ \newcommand{\email}[1]{\normalfont\texttt{\textless#1\textgreater}} %% \code without `-' ligatures -{\catcode`\-=\active% - \global\def\code{\bgroup% - \catcode`\-=\active \let-\codedash% - \Rd@code}} -\def\codedash{-\discretionary{}{}{}} -\def\Rd@code#1{\normalfont\texttt{#1}\egroup} -\def\AsIs{\bgroup\let\do\@makeother\Rd@AsIs@dospecials\@noligs\@vobeyspaces\Rd@AsIsX} -\def\Rd@AsIs@dospecials{\do\$\do\&\do\#\do\^\do\_\do\%\do\~} -\def\Rd@AsIsX#1{\normalfont #1\egroup} +%{\catcode`\-=\active% +% \global\def\code{\bgroup% +% \catcode`\-=\active \let-\codedash% +% \Rd@code}} +% \def\codedash{-\discretionary{}{}{}} + +%% If we simply do +%% \DeclareRobustCommand\code{\bgroup\@noligs\@vobeyspaces\Rd@code} +%% then e.g. +%% \code{\LinkA{attr<-}{attr<.Rdash.}} +%% will give an undefined control sequence `\< error when hyperref is +%% used (so that \LinkA uses \hyperlink). +%% Hence, use a noligs list without < and > for now, and use the same +%% list for \code and \samp and their variants. +\def\Rd@nolig@list{\do\`\do\,\do\'\do\-} +\def\Rd@noligs{\let\do\do@noligs \Rd@nolig@list} + +\DeclareRobustCommand\code{\bgroup\Rd@noligs\@vobeyspaces\Rd@code} +\def\Rd@code#1{\normalfont\texttt{#1}\egroup} \let\command=\code \let\env=\code -\newcommand\samp{`\bgroup\@noligs\@vobeyspaces\@sampx} +\DeclareRobustCommand\samp{`\bgroup\Rd@noligs\@vobeyspaces\@sampx} \def\@sampx#1{{\normalfont\texttt{#1}}\egroup'} \let\option=\samp +\def\AsIs{\bgroup\let\do\@makeother\Rd@AsIs@dospecials\@noligs\@vobeyspaces\Rd@AsIsX} +\def\Rd@AsIs@dospecials{\do\$\do\&\do\#\do\^\do\_\do\%\do\~} +\def\Rd@AsIsX#1{\normalfont #1\egroup} + % This is a workaround for the old Rdconv to handle \Sexpr by echoing it % Rd2latex() should never let \Sexpr through to here. \newcommand\Sexpr[2][]{{\normalfont\texttt{\bsl Sexpr[#1]\{#2\}}}} diff --git a/src/library/grid/vignettes/grid.Rnw b/src/library/grid/vignettes/grid.Rnw index b7e2c3e3465..b2b00c172e8 100644 --- a/src/library/grid/vignettes/grid.Rnw +++ b/src/library/grid/vignettes/grid.Rnw @@ -87,7 +87,7 @@ grid.show.viewport(viewport(x = 0.5, y = 0.5, width = 0.5, height = 0.25, \caption{ \label{figure:viewport} A diagram of a simple \grid{} viewport (produced using the - \protect\code{grid.show.viewport()} function.} + \code{grid.show.viewport()} function.} \end{figure} The object returned by the \code{viewport()} function is only a @@ -524,7 +524,7 @@ popViewport(2) } \end{center} \caption{\label{figure:simpleplot} - The grid equivalent of \protect\code{plot(1:10)}.} + The grid equivalent of \code{plot(1:10)}.} \end{figure} Now consider a more complex example, where we create a barplot