Tabular in dtx documentation

How to make table in .dtx documentation with vertical bars?

% \begin{tabular}{c|c}
%   |sf| & \emph{mathsf}\\
% \end{tabular}


fails, because |foo| is magic for verbatim.

• Add \DeleteShortVerb{\|} before the tabular and \MakeShortVerb{\|} after it; use \verb|sf| inside. Or just don't use ruled tables. – egreg May 28 '13 at 20:41

The correct answer would be "don't use ruled tables", so the problem is avoided altogether.

If you insist in using vertical rules in your tables (you shouldn't and have been warned ;-)), then the only way is to remove the special meaning of | before the table and restoring it afterwards:

% \DeleteShortVerb{\|}
% \begin{tabular}{c|c}
%   \verb|sf| & \emph{mathsf}\\
% \end{tabular}
% \MakeShortVerb{\|}


Note that inside the table you have to use \verb and not the shorthand.

• Can you tell more, why not? How else can I accomplish the same result? – KAction May 28 '13 at 22:10
• @KAction If the question refers to "don't use ruled tables", read the documentation of the booktabs package. It's illuminating; you should have it on your system; here's an online link – egreg May 28 '13 at 22:13