# Surprising result with “fontenc” when \detokenize is applied to -

Whether \detokenize is applied to - or -- under the fontenc package T1 fonts the results are the same.

\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}


It's as if \detokenize is allowing some kind of expansion occur before applying its magic to its argument. But I thought that's exactly what it's not supposed to do.

Could someone explain what's happening here? And, why the difference with \verb?

With both xelatex and lualatex I get the same result with or without \detokenize which is as expected as - has catcode 12 by default, so \detokenize just returns the same tokens as its argument in this case. Ligatures are not done via catcode tricks.

\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}

• But then what's going on with \verb here? I thought \verb just did catcode manipulations. – A.Ellett May 15 '15 at 13:49
• @A.Ellett Not quite: see the magic of \@noligs! – Joseph Wright May 15 '15 at 13:50
• @A.Ellett verb (in classic tex and here) makes - active and defined to insert a kern to prevent ligatures – David Carlisle May 15 '15 at 13:50