1

In my code below, the table appears in a "programming" type font. If I have a larger table (like say in a text file), how can I import that table into my document without having to typing the whole table back into the document? Will the listing package be able to accomplish this? If so, how do I implement this?

\documentclass{article}
\usepackage{verbatim}

\begin{document}
I wanted the contents of the table to appear in a ``programming'' type font:
\begin{verbatim}
---------+
10 1 2 4
20 2 3 5
30 3 4 6
40 4 5 7
---------+
\end{verbatim}
\end{document}
Joe
  • 9,080

1 Answers1

2

Yes, listings is a good idea. Here's a way to do it:

\usepackage{listings}
\lstset{
    basicstyle=\ttfamily
}

\begin{document}
\lstinputlisting{table.txt}
\end{document}

If you want to customize it further (e.g. adding line numbers), check out the list of settings.

Arun Debray
  • 7,126
  • 2
  • 30
  • 54