You can't use \verbatim ... \endverbatim
inside a macro. A detailed explanation you can find here:
TeX Frequently Asked Questions - Why doesn’t verbatim work within …?
You can use packages like listings
, fancyvrb
...
Here an example with fancyvrb:
\documentclass[]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage{fancyvrb}
\DefineVerbatimEnvironment{DoxyVerb}{Verbatim}%
{fontfamily=ptm,fontseries=m,fontshape=n}
\begin{document}
\begin{DoxyVerb}
get_asd_asd
\end{DoxyVerb}
\end{document}
EDIT: Using listings
:
\documentclass[]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage{listings}
\lstnewenvironment{lstDoxyVerb}%
{\lstset{basicstyle=\fontsize{10pt}{10}\usefont{OT1}{ptm}{m}{n}}}%
{}
\begin{document}
\begin{lstDoxyVerb}
get_asd_asd
\end{lstDoxyVerb}
\end{document}
There are two problems: the first is that after
\def\sa{10}
\def\sb{20}
the text \sa and \sb
will render as
10and 20
because TeX ignores spaces after control words.
Second problem. A control sequence can consist either of
- only one non alphabetic character (control symbols); or
- a string of one or more alphabetic characters, that is
[A-Za-z]
(control words)
Spaces are not ignored after control symbols.
However definitions with \def
allow for a fairly general syntax:
\def\cs<parameter text>{<replacement text>}
Here <parameter text>
can be whatever sequence of tokens, including the argument indicators #1
to #9
to denote arguments. But if there are tokens different from the argument indicators, they must appear after \cs
. So
\def\s_a{10}
is legal and defines a command \s
which requires the two tokens _a
to follow it. If you say after this
\def\s_b{20}
the command \s
is redefined and usage of \s_a
will trigger the error message
! Use of \s doesn't match its definition.
since \s
is not followed by _b
.
To solve both problems at once, use
\def\sa/{10}
\def\sb/{20}
and then \sa/ and \sb/
will render as
10 and 20
because the required /
after the commands' names stops the space ignoring feature.
Best Answer
The documentation of the
underscore
package states that_
must be avoided in file names. However, if you do need to use an_
in the file name, there is the[strings]
package option which along with the\UnderscoreCommands
can be used to specify a list of commands where an_
is needed.Below, I have added the command
\verbatiminput
to the this list -- the others are directly from the documentation. Note that this list must be defined before the package is loaded.