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
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
- Stefan Kottwitz
- Site Admin
- Posts: 10360
- 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}
