Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how write this in verbatim latex

Tags:

latex

verbatim

i have a little question about the verbatim environment in latex..... my problem is how can i write "\end{verbatim}" inside of a verbatim environment, it supposed that everything inside a verbatim is written just like it looks but this is the string to end the environment, so how can i do this?

like image 341
mjsr Avatar asked Jun 11 '10 02:06

mjsr


People also ask

What does verbatim mean in LaTeX?

The verbatim environment is a paragraph-making environment that gets LaTeX to print exactly what you type in. It turns LaTeX into a typewriter with carriage returns and blanks having the same effect that they would on a typewriter.

How do you use verbatim in overleaf?

Verbatim-like text can also be used in a paragraph by means of the \verb command. The command \verb|C:\Windows\system32| prints the text inside the delimiters | in verbatim format. Any character, except letters and * , can be used as delimiter. For instance \verb+\ldots+ uses + as delimiter.

How do you center a verbatim in LaTeX?

You need to use \centering, not \centerline.


1 Answers

I think it might be impossible in a verbatim environment -- at least, that's what Lamport says in the LaTeX book (first paragraph on pg. 64). However, you can do it with the \verb command: \verb+\end{verbatim}+ works just fine (and in fact, you can use any character instead of + as long as you make them match).

That said, the listings package is smart enough to have an escape character. For example,

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

does exactly what you're looking for. (Again, pick a different character than + if you're already using that for something else.)

like image 107
Craig Citro Avatar answered Sep 21 '22 23:09

Craig Citro