How to write it in verbatim latex

I have a little question about the verbatim environment in latex ..... my problem is how can I write "\ end {verbatim}" inside the verbatim environment, he suggested that everything inside the verbatim is written as if it looks, but this is the line to end the environment, so how can I do this?

+5
source share
5 answers

I think this may not be possible in the environment verbatim- at least what Lamport says in LaTeX (first paragraph on page 64). However, you can do this with the command \verb: it \verb+\end{verbatim}+works just fine (and in fact you can use any character instead +, as long as you match them).

However, the package listingsis smart enough to have an escape character. For instance,

\begin{lstlisting}[escapechar=+]
+\verb!\end{lstlisting}!+
\end{lstlisting}

does exactly what you are looking for. (Again, choose a different character than +if you are already using this for something else.)

+3
source
 \\end{verbatim}

Must do this by making the original \a literal backslash.

+1
source

fancyvrb verbatim .

+1

. , \expandafter\string\csname end{verbatim}\endcsname.

: .

0

I have a simpler solution. Write inextricable space in Emacs it Cx 8 SPC (Windows, although I have not tried this Alt+0160 (on numeric keypad)). So you can do this:

\begin{verbatim}
\_end{verbatim}
\end{verbatim}

where the first \end{verbatim}has this "_", an inextricable character.

0
source

All Articles