0

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 parameters

  • in 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.

2
  • That might be hard as ` has special meaning in TeX.
    – daleif
    Commented Sep 14, 2023 at 8:09
  • 2
    No matter whether you use \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).
    – Skillmon
    Commented Sep 14, 2023 at 8:43

0

You must log in to answer this question.

Browse other questions tagged .