Take the 2-minute tour ×

Useing a Finite Element Program that outputs data in txt fils. And this data i want to input in my latex. Is there a way to input the data fils so that they appear as the program output den.

Program output data file: enter image description here

Latex code:



Latex output:

enter image description here

share|improve this question
Does \verbatiminput{Data/shearwall_only_bc_A.txt} do what you need? Requires \usepackage{verbatim}. –  egreg Dec 2 '12 at 13:16
Maybe, can be also helpful the listings package... –  FormlessCloud Dec 2 '12 at 13:34
@MaltheEisum does any of the solutions below answer your question? –  nnunes Dec 18 '12 at 21:17
add comment

3 Answers

up vote 7 down vote accepted

In addition to listings, the fancyvrb package is equally suitable for this purpose.

This package provides the \VerbatimInput command (similar to \verbatiminput), which can be customised using various parameters (e.g., reducing font size).




% redefine \VerbatimInput
 frame=lines,  % top and bottom rule only
 framesep=2em, % separation between frame and text
 commandchars=\|\(\), % escape character and argument delimiters for
                      % commands within the verbatim
 commentchar=*        % comment character




enter image description here


  • specifying | and (/) as the escape character and argument delimiters means these symbols cannot appear as part of the verbatim text (or in this case, the contents of data.txt);
  • the line of asterisks in data.txt was removed by specifying * as the comment character (similar to % in LaTeX);
  • the line highlighted in green was obtained by modifying it as follows:

(|color(Green) 8 400.519E-33 -12. 17.1429 27.3494E+03)

share|improve this answer
To overwrite the value of previous parameters at any point, use the optional argument of \VerbatimInput, e.g., \VerbatimInput[fontsize=\small]{data.txt}. –  nnunes Dec 2 '12 at 15:39
add comment

Tanks egreg.

Adding the following to the preamble


And useing

    \verbatiminput{<file path>}

To input does the tick !! thanks !!

share|improve this answer
add comment

You can also make the font size smaller in a verbatim environment by making a new environment I call \verbatimprog, which uses the \footnotesize font size.

Place the lines below in the preamble (before \begin{document}):


Then, to use the new environment, say


(your program output here)

share|improve this answer
Yes, but Malthe Eisum's question was about reading the contents of a text file automatically with a command like \input, and not copying the contents of the first. –  nnunes Dec 2 '12 at 18:13
add comment

Your Answer


