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}
  • 3
    \verbatiminput{}? – cfr Oct 4 '15 at 0:55
  • 1
    Use \lstinputlisting. If you want to mimic the style of the verbatim environment, see this. – jub0bs Oct 4 '15 at 0:57
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.