![当 \detokenize 应用于 `-` 时,“fontenc” 的结果令人惊讶](https://linux22.com/image/311459/%E5%BD%93%20%5Cdetokenize%20%E5%BA%94%E7%94%A8%E4%BA%8E%20%60-%60%20%E6%97%B6%EF%BC%8C%E2%80%9Cfontenc%E2%80%9D%20%E7%9A%84%E7%BB%93%E6%9E%9C%E4%BB%A4%E4%BA%BA%E6%83%8A%E8%AE%B6.png)
无论\detokenize
是应用于字体包-
还是--
在其下,结果都是相同的。fontenc
T1
\documentclass[border=10pt]{standalone}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\begin{document}
\begin{tabular}{lcl}
Command & applied to & result \\\hline
Verb & two minus signs & \verb=--= \\
Detokenize & two minus signs & \ttfamily\detokenize{--} \\
Detokenize & one minus sing & \ttfamily\detokenize{-} \\
Detokenize & three minus signs & \ttfamily\detokenize{---} \\
\end{tabular}
\end{document}
这就像是\detokenize
在将其魔法应用于其论点之前允许某种扩展发生。但我认为这恰恰是它不应该做的。
有人能解释一下这里发生了什么吗?为什么会有区别\verb
?
答案1
使用 xelatex 和 lualatex 时,无论是否使用,我都会得到相同的结果,\detokenize
这与-
默认情况下 catcode 12 的预期一致,因此\detokenize
在这种情况下只返回与其参数相同的标记。连字不是通过 catcode 技巧完成的。
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\begin{document}
\begin{tabular}{lcl}
Command & applied to & result \\\hline
Verb & two minus signs & \verb=--= \\
Detokenize & two minus signs & \ttfamily\detokenize{--} \\
Detokenize & one minus sing & \ttfamily\detokenize{-} \\
Detokenize & three minus signs & \ttfamily\detokenize{---} \\
\end{tabular}
\begin{tabular}{lcl}
Command & applied to & result \\\hline
Verb & two minus signs & \verb=--= \\
Detokenize & two minus signs & \detokenize{--} \\
Detokenize & one minus sing & \detokenize{-} \\
Detokenize & three minus signs & \detokenize{---} \\
\end{tabular}
\begin{tabular}{lcl}
Command & applied to & result \\\hline
Verb & two minus signs & \verb=--= \\
Detokenize & two minus signs & \ttfamily{--} \\
Detokenize & one minus sing & \ttfamily{-} \\
Detokenize & three minus signs & \ttfamily{---} \\
\end{tabular}
\begin{tabular}{lcl}
Command & applied to & result \\\hline
Verb & two minus signs & \verb=--= \\
Detokenize & two minus signs & {--} \\
Detokenize & one minus sing & {-} \\
Detokenize & three minus signs & {---} \\
\end{tabular}
\end{document}