# Welcome to the UK List of TeX Frequently Asked Questions on the Web

## Including a file verbatim in LaTeX

A good way is to use Rainer Schöpf’s verbatim package, which provides a command \verbatiminput that takes a file name as argument:

\usepackage{verbatim}
...
\verbatiminput{verb.txt}


Another way is to use the alltt environment, which requires the alltt package. The environment interprets its contents ‘mostly’ verbatim, but executes any (La)TeX commands it finds:

\usepackage{alltt}
...
\begin{alltt}
\input{verb.txt}
\end{alltt}


of course, this is little use for inputting (La)TeX source code…

The moreverb package extends the verbatim package, providing a listing environment and a \listinginput command, which line-number the text of the file. The package also has a \verbatimtabinput command, that honours TAB characters in the input (the package’s listing environment and the \listinginput command also both honour TAB).

The sverb package provides verbatim input (without recourse to the facilities of the verbatim package):

\usepackage{sverb}
...
\verbinput{verb.txt}


The fancyvrb package offers configurable implementations of everything verbatim, sverb and moreverb have, and more besides. It is nowadays the package of choice for the discerning typesetter of verbatim text, but its wealth of facilities makes it a complex beast and study of the documentation is strongly advised.

The memoir class includes the relevant functionality of the verbatim and moreverb packages.

alltt.sty
Part of the LaTeX distribution.
fancyvrb.sty
macros/latex/contrib/fancyvrb (or browse the directory); catalogue entry
memoir.cls
macros/latex/contrib/memoir (or browse the directory); catalogue entry
moreverb.sty
macros/latex/contrib/moreverb (or browse the directory); catalogue entry
sverb.sty
Distributed as part of macros/latex/contrib/mdwtools (or browse the directory); catalogue entry
verbatim.sty
Distributed as part of macros/latex/required/tools (or browse the directory); catalogue entry

Go to previous question, or next question

Go to FAQ home.

URL for this question: http://www.tex.ac.uk/cgi-bin/texfaq2html?label=verbfile

Comments, suggestions, or error reports? - see “how to improve the FAQ”.

This is FAQ version 3.27, released on 2013-06-07.