StartLaTeX faqLaTeX for Beginners F.A.Q.LaTeX topicsLaTeX courseSearch

The verbatim environment and the \verb command are used to display characters that LaTeX would normally interpret as commands. For example, when presenting LaTeX code within a LaTeX document, using Verbatim or \verb prevents the code from being executed and interpreted.

However, this form of display has limitations. You cannot change the font type directly, and adjusting font size requires embedding the Verbatim environment within a font size environment.

To address these limitations, the fancyvrb package provides enhanced versions of the Verbatim environment. It offers options for customizing font types, sizes, numbering, and even enables the \verb command within footnotes.

Incorporating the Package

To include the package, simply use \usepackage{fancyvrb} without any special options. If you wish to use the \verb command within footnotes, add \VerbatimFootnotes after \begin{document}.

Simple Example

The package introduces a new Verbatim environment, distinguished by a capital 'V' instead of a lowercase 'v'.

\begin{Verbatim}
\LaTeX{}
\end{Verbatim}

Changing Font Type

You can change the font type within the Verbatim environment using options like fontfamily=tt for typewriter font, courier for courier font, or helvetica for Helvetica font.

Changing Font Size

Similarly, font size can be adjusted using options like fontsize=\tiny, \small, \large, \Large, \huge, or \Huge.

Numbering

Numbering in the Verbatim environment can be aligned left or right relative to the text. You can also customize the step number, starting value, and width of the counter.

Verbatim within Footnotes

With fancyvrb, you can now include verbatim text within footnotes using the \verb command.

Now, verbatim text can be included within footnotes.

Example

This LaTeX code demonstrates how to customize the appearance of text within a special environment called Verbatim, provided by the fancyvrb package.

\documentclass{article}
\usepackage{fancyvrb}
\begin{document}

\begin{Verbatim}[fontfamily=tt]
  Typewriter font
\end{Verbatim}

\begin{Verbatim}[fontfamily=courier]
  Courier font
\end{Verbatim}

\begin{Verbatim}[fontfamily=helvetica]
  Helvetica font
\end{Verbatim}

\begin{Verbatim}[fontsize=\tiny]
  Tiny text
\end{Verbatim}

\begin{Verbatim}[fontsize=\small]
  Small text
\end{Verbatim}

\begin{Verbatim}[fontsize=\large]
  Large text
\end{Verbatim}

\begin{Verbatim}[fontsize=\Large]
  Larger text
\end{Verbatim}

\begin{Verbatim}[fontsize=\huge]
  Huge text
\end{Verbatim}

\begin{Verbatim}[fontsize=\Huge]
  Even huger text
\end{Verbatim}

\begin{Verbatim}[numbers=left, stepnumber=2, firstnumber=5]
Test
\end{Verbatim}

\end{document}

Contact   Privacy Policy   disclosures

accept decline

This website uses cookies and pixel tags to ensure you get the best experience on our website. By using this website, you consent to the use of cookies.learn more about cookies see also our privacy policy