4

I'm trying this:

\documentclass{article}
\usepackage{fancyvrb}
\fvset{commandchars=\|}
\begin{document}
\begin{Verbatim}
Hello, |\textbf{world}|!
\end{Verbatim}
\end{document}

However, I'm getting this:

! Improper alphabetic constant.
<to be read again>
                   \relax
l.5 \begin{Verbatim}

I need to have an ability to place any TeX syntax inside the |...| escape. What is the right way to do this?

yegor256
  • 12,021

1 Answers1

6

The key commandchars requires three tokens as value; the first one denotes the escape character, the other two the open and close argument delimiters.

\documentclass{article}
\usepackage{fancyvrb}

\fvset{commandchars=|{}}

\begin{document}

\begin{Verbatim} Hello, |textit{world}! \end{Verbatim}

\end{document}

Note that you don't use | before and after, but it replaces the backslash.

enter image description here

As far as I know, there is no escapeinside feature in fancyvrb or fvextra.

egreg
  • 1,121,712