New answers tagged comments
2
As @Symbol 1 suggested in a comment, changing the catcode of % before the argument is absorbed is essential. And then making sure it is changed back when done, is equally essential.
\documentclass{article}
\newcommand{\code}{\catcode`\%=12 \codeaux}
\newcommand\codeaux[1]{\texttt{\detokenize{#1}}\catcode`\%=14}
\begin{document}
\code{%>%}
Test% if these ...
comments typewriter detokenize
answered Mar 4 at 15:59
Steven B. Segletes
199k1010 gold badges267267 silver badges516516 bronze badges
Top 50 recent answers are included
Related Tags
comments × 344environments × 33
listings × 31
macros × 24
conditionals × 13
verbatim × 11
errors × 9
pdf × 9
equations × 8
notes × 8
pdfcomment × 8
beamer × 7
spacing × 7
compiling × 7
sourcecode × 7
horizontal-alignment × 6
formatting × 6
color × 6
algorithms × 6
algorithm2e × 6
annotations × 6
texstudio × 5
editors × 5
highlighting × 5
syntax × 5