3

I'm curious as to whether it's possible to insert an entire separate file into a LaTeX document as an inline command. For example, I have the following LaTeX code:

\begin{Verbatim}[frame=single]
%Want to insert all the text from another file here
\end{Verbatim}

So where it says %Want to insert... I'd like to insert all of the text from another file (in the same directory) into the .tex document so that the text in the other file appears in a box in the .tex document.

I hope that's clear, if not I'll clarify in the comments.

  • Welcome to TeX.sx! No need to add thanks, simply upvote any good answers you may receive. – Peter Jansson Feb 25 '13 at 15:31
  • 1
    @Decave see my answer to "how to include data from a .txt". For example, to include text from file doc.tex, use \VerbatimInput{doc.tex}. Also, you may want to comment out (use %) the commandchars and commentchar keys until you understand what they do. – nnunes Feb 25 '13 at 16:23
  • Sorry everyone, I had to leave work early today. I will test the code on Wednesday when I'm back in the office and have access to my LaTeX file. –  Feb 25 '13 at 23:54
  • you can \usepackage{verbatim} and then \verbatiminput{frame-single}. (i use this all the time to include the source of a file in its own output with \verbatiminput{\jobname.tex}, a great way to document tests and "how to" exercises.) – barbara beeton Feb 27 '13 at 21:22
  • On page 6 of the documentation of fancyvrb you find \VerbatimInput; I'd say that \VerbatimInput[frame=single]{myfile.txt} is what you're looking for. – egreg Mar 07 '13 at 11:22

2 Answers2

2

This question is answered in the following link:

https://texfaq.org/FAQ-verbfile

David Carlisle
  • 757,742
Jostein Trondal
  • 1,165
  • 9
  • 20
-1

You can try the \input command:

\begin{Verbatim}[frame=single]
\input ANOTHER_FILE.tex
\end{Verbatim}
sdumi
  • 59
  • 4
    Have you tested your code? Witch package defines environment Verbatim? I suppose you will read only \input ANOTHER_FILE.tex instead of reading the content of the file ... – Mensch Feb 25 '13 at 19:13