![Verbatim 環境内で TeX コマンドをエスケープするにはどうすればよいですか?](https://rvso.com/image/472697/Verbatim%20%E7%92%B0%E5%A2%83%E5%86%85%E3%81%A7%20TeX%20%E3%82%B3%E3%83%9E%E3%83%B3%E3%83%89%E3%82%92%E3%82%A8%E3%82%B9%E3%82%B1%E3%83%BC%E3%83%97%E3%81%99%E3%82%8B%E3%81%AB%E3%81%AF%E3%81%A9%E3%81%86%E3%81%99%E3%82%8C%E3%81%B0%E3%82%88%E3%81%84%E3%81%A7%E3%81%99%E3%81%8B%3F.png)
私はこれを試しています:
\documentclass{article}
\usepackage{fancyvrb}
\fvset{commandchars=\|}
\begin{document}
\begin{Verbatim}
Hello, |\textbf{world}|!
\end{Verbatim}
\end{document}
しかし、私はこれを受け取っています:
! Improper alphabetic constant.
<to be read again>
\relax
l.5 \begin{Verbatim}
エスケープ内に任意の TeX 構文を配置できる必要があります|...|
。これを行う正しい方法は何ですか?
答え1
キーcommandchars
には値として 3 つのトークンが必要です。最初のトークンはエスケープ文字を示し、他の 2 つは引数の開始と終了の区切り文字を示します。
\documentclass{article}
\usepackage{fancyvrb}
\fvset{commandchars=\|\{\}}
\begin{document}
\begin{Verbatim}
Hello, |textit{world}!
\end{Verbatim}
\end{document}
before と afterは使用せず|
、バックスラッシュを置き換えることに注意してください。
私の知る限り、または にescapeinside
はそのような機能はありません。fancyvrb
fvextra