New Latex Team

I would like to define a new team like this

\newcommand{\bob}[1]{\excerpt \begin{lstlisting} {#1} \end{lstlisting}} 

and then use it like this:

 \bob{abcd} 

but I get the following latex error.

 text dropped after begin of listing latex 

EDIT:

I tried the following

 \newcommand{\boy}[1] {{% \begin{Verbatim} % { #1 } % \end{Verbatim} }} 

And I still get the error message when I try to use it.

 \boy{abc} 
+4
source share
3 answers

You might be looking for a \newenvironment macro.

In this case, you will use it as follows

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

and later

 \begin{bob} abcd \end{bob} 
+4
source

The medium {listing} is special and magical; it cannot be used inside such a team. The transition to installing \newenvironment , as described in dmckee, should work. If you cannot complete this work, check out fancyvrb .

+1
source

Try the lstnewenewvironment package package.

+1
source

All Articles