3

I know how I can change the font size of a verbatim text. For example:

\begin{tiny}
\begin{verbatim}
My verbatim text is tiny in size
\end{verbatim}
\end{tiny}

Is there a way to specify that all my verbatim text in the current document should have a tiny font-size so that I avoid enclosing each of my verbatim text in \tiny?

Thanks!

2

2 Answers 2

8

Changing \verbatim@font might be the solution, but it would also change the font for inline \verb.

Better adding \scriptsize (or \tiny if you want your readers to hate you) when verbatim starts.

\documentclass{article}

\AtBeginEnvironment{verbatim}{\scriptsize}% or whatever

\begin{document}

This is text to show the \verb|font size|
\begin{verbatim}
This is smaller
\end{verbatim}
Some other text

\end{document}

enter image description here

With an older LaTeX release you might need \usepackage{etoolbox}.

5

Adding the below will change the font size of verbatim in the entire document to, for example, \tiny.

\makeatletter
\def\verbatim@font{\tiny\ttfamily}
\makeatother

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .