For processing documents with a lot of program code and code fragments, I would like to use backticks for inline program code. So far I use the suggestions from this answer (which already declutters a lot of my texts) but now realizing that this was not good enough.
What I am searching for is a way that
backticks also handle within them all other characters like
{
}
, that is, kind of like the\verb
construct but without its limitations when handed in as parametersin particular also handle the underscore, but only within the backticks, so I still can use regular mathmode outside
backticks also can be used in titles or index entries, currently the
.toc
is then erroneous
Edit: Alternatively, a way to detect misuses of {
}
within a backquote environment would be just as good.
\verb
or a short-verb construct (regardless of the used character) the limitation that it doesn't work as intended inside of an argument will stay the same. If you don't need support for backslashes and percent characters (and are fine with#
-doubling) you could use\detokenize
, something like\newcommand\myvrb[1]{\protect\detokenize{#1}}
. Changing the category of a backtick could be done then to support that, but as @daleif points out, that has the potential to break other things (if activated at\begin{document}
could be fine depending on your document).