Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Font Size in verbatim

2,353 views
Skip to first unread message

David Rasmussen

unread,
Jul 21, 2004, 4:31:27 PM7/21/04
to
How do I control the font size in a verbatim environment?

/David

Vilar Camara Neto

unread,
Jul 21, 2004, 5:18:47 PM7/21/04
to
"David Rasmussen" <david.r...@gmx.net> escreveu na mensagem
news:40fed2a0$0$161$edfa...@dtext02.news.tele.dk...

> How do I control the font size in a verbatim environment?
>
> /David

You can use the Verbatim environment (uppercase "V" -- it's part of the
fancyvrb package), which allows some options, including font size control:

\usepackage{fancyvrb}

\begin{Verbatim}[fontsize=\small]
... verbatim material ...
\end{Verbatim}

Regards,
Vilar Camara Neto


Donald Arseneau

unread,
Jul 21, 2004, 8:25:01 PM7/21/04
to
David Rasmussen <david.r...@gmx.net> writes:

> How do I control the font size in a verbatim environment?

There are reasons for using extended verbatim, but this
is not one of them. With straight LaTeX:

\makeatletter
\renewcommand\verbatim@font{\large\normalfont\ttfamily}
\makeatother

Donald Arseneau as...@triumf.ca

Will Robertson

unread,
Jul 22, 2004, 12:30:33 AM7/22/04
to
David Rasmussen <david.r...@gmx.net> wrote in message news:<40fed2a0$0$161$edfa...@dtext02.news.tele.dk>...

> How do I control the font size in a verbatim environment?
>
> /David

\documentclass{article}
\begin{document}
\noindent David Rasmussen wants to change the font size of the verbatim environment.
{
\small
\begin{verbatim}
Surely he knows that to change font sizes,
he simply needs a preceeding font size changing command.
\end{verbatim}
}
\noindent Perhaps lshort.pdf would be a good reference for him.
\end{document}

David Rasmussen

unread,
Jul 22, 2004, 5:24:28 AM7/22/04
to
Will Robertson wrote:
>
> \documentclass{article}
> \begin{document}
> \noindent David Rasmussen wants to change the font size of the verbatim environment.
> {
> \small
> \begin{verbatim}
> Surely he knows that to change font sizes,
> he simply needs a preceeding font size changing command.
> \end{verbatim}
> }
> \noindent Perhaps lshort.pdf would be a good reference for him.
> \end{document}

Thanks :)

I actually tried something along those lines after asking here, but it
didn't work. With small. It works with other sizes, so I conclude that
the verbatim font size is "small" (my document is 12pt). Or?

/David

Robin Fairbairns

unread,
Jul 22, 2004, 7:07:25 AM7/22/04
to

or something (verbatim font size is normally that of surrounding
text). try it with \tiny in place of \small to see the effect to its
starkest extent.

what's wrong here, and may be putting you off, is that the code as
written applies the \baselineskip appropriate to \small to the
paragraph above the verbatim (see
http://www.tex.ac.uk/cgi-bin/texfaq2html?label=baselinepar). what tex
sees is

text at 10pt
open group
\small, implying \baselineskip change
\par (inside verbatim code)
verbatim stuff
\par (inside verbatim code)
close group, restoring \baselineskip
more text

since the \baselineskip changes before the end of the first paragraph,
it affects the whole of the paragraph. at the point the paragraph
after the verbatim happens, the size is back to normal and (other
things being equal) the paragraph is set to the correct \baselineskip.
--
Robin (http://www.tex.ac.uk/faq) Fairbairns, Cambridge

Heiko Oberdiek

unread,
Jul 22, 2004, 7:40:26 AM7/22/04
to
wi...@guerilla.net.au (Will Robertson) wrote:

> David Rasmussen <david.r...@gmx.net> wrote in message news:<40fed2a0$0$161$edfa...@dtext02.news.tele.dk>...
> > How do I control the font size in a verbatim environment?
> >
> > /David
>
> \documentclass{article}
> \begin{document}
> \noindent David Rasmussen wants to change the font size of the verbatim environment.
> {
> \small
> \begin{verbatim}

\begin{verbatim} closes the current paragraph. Now TeX is typesetting
the previous paragraph with current settings, i.e. a smaller
baselineskip.

> Surely he knows that to change font sizes,
> he simply needs a preceeding font size changing command.
> \end{verbatim}
> }

Also the closing group after \end{verbatim} is problematic, so that
you have to specify \noindent to suppress indentation.

> \noindent Perhaps lshort.pdf would be a good reference for him.
> \end{document}

Solutions: packages verbatim, alltt, fancyvrb, listings, ...

Yours sincerely
Heiko <ober...@uni-freiburg.de>

0 new messages