I want to have some code (or package, or documentclass) that I can put in the header of the Latex document so that when compiling it reads certain commands in verbatim.
For example: all cross references like \cref \eqref etc should be displayed in verbatim if I turn that code on, but if I remove it, I compile the document including these control sequences. Ideally that would work for the inline math environment, too.
It feels like their must be an easy way to do, yet I am unable to find it.
UPDATE: For lack of a better solution after 2.5 years, I posted my workaround as an answer.
Some background: I want to hand the paper to someone that operates in MS Word. If she suggests changes (using MS Word track cahnges), I want to copy paste entire paragraphs back into the latex file. I am aware that Latex/Word compatibility is not the best, but there is no other way.
I am looking for an efficient way to get comments on the text into latex without losing crossreferences or control sequence from the copy-pasting exercise.
My workaround so far is flagging all in line commands putting \$ in front of it and then replacing them one by one afterwards. But that seems ineffecient.
\stringeverything when in proof mode, and not when in final mode:\documentclass{article} \newcommand{\prm}{\string}%proof %\newcommand{\prm}{}%final \begin{document} \prm\part{Part Title} \prm\section{Section Text} \end{document}. Detokenizing the whole document is possible but loses formatting (lines, paragraphs, ..), so not practical. – Cicada Feb 26 '20 at 12:36\section{Section Text}as the output. Instead I getsectionSection Text.The closest I got so far was using the
\renewcommand{\command}[1]{\textbackslash command\{#1\}}option. Yet there I have two problems:- if there are optional arguments (more than 1 in particular) it seems to get messed up.
- if I had e.g.
– johaschn Feb 26 '20 at 13:52\section{section_text}I cannot get around the math interpretation ofsection_text\documentclass{article} \newif\ifprm \prmtrue \newcommand{\prm}{\string}%proof \newcommand\verbit[1]{\ifprm\detokenize{#1}\else#1\fi} \begin{document} \catcode{=12\catcode}=12\relax\prm\part{Part Title}\catcode{=1\catcode`}=2\verb+\section{Text 1}+
\detokenize{\section{Text 2}}
\verbit{\section{Text 3}}
\prmfalse\verbit{\section{Text 3a}}\end{document}`
– Cicada Feb 27 '20 at 12:45\catcode``{=12. – Cicada Feb 27 '20 at 12:50