Latex new command

latex, macros

Solution

Perhaps you are looking for the `\newenvironment` macro.

In this case you would use it like this

\newenvironment{bob}{%
\excerpt \begin{lstlisting}}{%
\end{lstlisting}}

and later

\begin{bob}
abcd
\end{bob}

Problem

I would like to define a new command like this ``` \newcommand{\bob}[1]{\excerpt \begin{lstlisting} {#1} \end{lstlisting}} ``` and then use it like this ``` \bob{abcd} ``` but i get the following error in latex. ``` text dropped after begin of listing latex ``` EDIT: I tried the following ``` \newcommand{\boy}[1] {{% \begin{Verbatim} % { #1 } % \end{Verbatim} }} ``` And I still get an error when I try to use it. ``` \boy{abc} ```

Original source