Text Formatting ⇒ center a text in verbatim
center a text in verbatim
I just have one line in verbatim:
\begin{verbatim}
the line
\end{verbatim}
And i would like to center it. It seems that \center, \centerline do not work here. I do not want to use minipage because the length of the line could change.
By the way, the reason why i insist to envelop a line within a verbatim is that i have other similar lines/paragraphs handled by verbatim. I would like to align their font size and face, etc.
Does anyone know the answer?
Thanks and regards
Tie CHENG
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
- Stefan Kottwitz
- Site Admin
- Posts: 10324
- Joined: Mon Mar 10, 2008 9:44 pm
center a text in verbatim
you could use \verb:
Code: Select all
\documentclass[a4paper,10pt]{article}
\begin{document}
\centering
\verb|the line|
\end{document}
Re: center a text in verbatim
center a text in verbatim
- Ijon Tichy
- Posts: 640
- Joined: Mon Dec 24, 2018 10:12 am
center a text in verbatim
Code: Select all
\documentclass[a4paper,10pt]{article}
\usepackage{verbatim}
\makeatletter
\newenvironment{centeredverbatim}{\expandafter\verbatim\centering}{\endverbatim}
\makeatother
\begin{document}
\begin{centeredverbatim}
Bimm
Verbatim
using
automatic \centering
This
Lines
\end{centeredverbatim}
\end{document}
