逐字打印 LaTeX3 字符串

逐字打印 LaTeX3 字符串

我找不到逐字打印 LaTeX3 字符串和/或文本内容的方法(或者更准确地说,我找到了一种解决方案,即将内容写入文件,然后逐字显示该文件的内容,但它看起来真的很丑):

在此处输入图片描述

\documentclass{article}
\ExplSyntaxOn

\NewDocumentCommand{\printMeVerbatim}{m}{
%% Don’t know what to put here: I managed to write it in a file to write its content verbatim,
%% but it sounds really dirty
#1
}

\ExplSyntaxOff

\begin{document}

I would like to print this string verbatim: ``\printMeVerbatim{Hello $\delta$.}'' like:
\begin{verbatim}
Hello $\delta$.
\end{verbatim}
ideally using LaTeX3 syntax.

\end{document}

答案1

在此处输入图片描述

vltcmd为此类用途而提供。

\documentclass{article}
\ExplSyntaxOn

\NewDocumentCommand{\printMeVerbatim}{v}{%%%%%
%% Don’t know what to put here: I managed to write it in a file to write its content verbatim,
%% but it sounds really dirty
\begin{flushleft}\ttfamily%
#1%%%%%
\end{flushleft}
}

\ExplSyntaxOff

\begin{document}

I would like to print this string verbatim: ``\printMeVerbatim{Hello $\delta$.}'' like:
\begin{verbatim}
Hello $\delta$.
\end{verbatim}
ideally using LaTeX3 syntax.

\end{document}

相关内容