Currently, using shortvrb
, it's possible to define a single character to start, by itself, an inline verbatim command:
\documentclass{article}
\usepackage{shortvrb}
\begin{document}
\MakeShortVerb{\|}
foo |this is verbatim|
\end{document}
or similarly, with fancyvrb
,
\documentclass{article}
\usepackage{fancyvrb}
\begin{document}
\DefineShortVerb{\|}
foo |this is verbatim|
\end{document}
In both cases -- as with \verb!some verbatim text!
-- the symbol is required again to end the verbatim portion. If it's left out, an error similar to "\verb ended by end of line" is produced.
Is there a way to (re)define \MakeShortVerb
or similar, such that the newline will merely end the command, rather than producing an error? Ideally, one could then write something like:
\DefineAsymmetricVerb{\|}
This is some regular text.
Now some verbatim code that only needs a symbol at the start of the line, like:
| if 1 == 1
| print 'All is well'
This would allow blocks (or single lines) of verbatim text without the clutter of
| if 1 == 1 |
| print 'All is well' |
or
\begin{verbatim}
if 1 == 1
print 'All is well'
\end{verbatim}
\begin{verbatim}...\end{verbatim}
?\begin
instead of\end