Text Formattingcenter several lines in verbatim

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
Tie
Posts: 9
Joined: Tue Dec 22, 2009 4:10 pm

center several lines in verbatim

Post by Tie »

Hello all,

I just have several lines in verbatim:

\begin{verbatim}
line 1 ...
___line 2 ...
______line 3 ...
\end{verbatim}

I would like to center all the 3 lines together without deleting the spaces in front of line 2 and 3. It seems that \center, \centerline, \certering do not work here.

Does anyone know how to solve this problem?

Thanks and regards

Tie CHENG

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

Re: center several lines in verbatim

Post by Juanjo »

Put the verbatim environment inside a minipage with a suitable width and then center the minipage. You can also try more involved verbatim environments, like those of the fancyvrb package.
The CTAN lion is an artwork by Duane Bibby. Courtesy of www.ctan.org.
Post Reply