0

I have the following code in a knitr doc:

\title{Metrics for \Sexpr{display_name}}

where display_name was set by some previous code.

If that name has special characters (e.g., Mary & Sue Industries), then latex barfs:

! Misplaced alignment tab character &.
\@title ->Metrics for Mary &
                              Sue Industries

I've seen a couple of questions about quoting special characters (expandafter, also this, also perl), but I don't understand how to apply them to my situation. Is there any knitr or latex function or macro I can use?

I'm using knitr 1.26 and pdfTeX 3.14159265-2.6-1.40.20 (TeX Live 2019).

dfrankow
  • 233

0 Answers0