TeX - LaTeX Asked by Migwell on August 11, 2021
Using the listings
package, we can do the following to create a |
(pipe)-delimited inline code environment:
lstMakeShortInline|
I am interested in using the minted
package instead, however it doesn’t seem to support a similar shortcut. How can I make the pipe character delimit an inline code snippet, using mintinline
.
The following provides a macro makemintedshortinline
that takes two parameters. The language which should be used and the character you want to be the shorthand.
It is not necessary to escape the character (use |
instead of |
) for every character, but since it is necessary for some (for example %
couldn't be input directly and you have to use %
instead), it doesn't hurt to use it.
It isn't checked whether the character already has a definition when it is turned active, so you can also change the language used this way, e.g., you could use makemintedshortinline{python}|
after you used it to format LaTeX code to format Python code later in your document.
documentclass{article}
usepackage{minted}
newcommandmakemintedshortinline[2]
{%
catcode`#2=13
begingroup
lccode`~=`#2
lowercase{%
endgroup
protecteddef~{mintinline{#1}~}%
}%
}
makemintedshortinline{latex}|
begin{document}
|verb+input+|
end{document}
Correct answer by Skillmon on August 11, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP