TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to include only a part of a .tex file into a different .tex file. The part I want to include is delimited by some comment tags, as it is used by catchfilebetweentags package.

I tried the solution of Will Robertson posted in \input only part of a file and it worked wonderfully ... except that the space that should appear in the output PDF file when the text jumps from one line to another in the source .tex file disappears.

The main file is the following:



while the file where I want the text from (i.e., inputfile.tex) is the following:


Some text.
Text to be included in the main file. This is the first line
and this is the second line. See the problem?


In my case, when I proccess the main file I get lineand instead of line and in the PDF file.

Where is the problem? Is it a catcode problem? I use MiKTeX 2.9 on a Windows 7 machine, if it helps.

share|improve this question
up vote 4 down vote accepted

For some reasons the author of catchfilebetweentags issues a command


that is obviously the cause of this behavior. I don't know if removing it has other side effects, but for your case it seems to work:


      %\endlinechar\m@ne % <- this is the guilty party
      \makeatletter #2%
}% \CatchFBT@Final

Instead of copying the whole definition from the package, you can use etoolbox:

  {}{\typeout{Unsuccessful patch!}}
share|improve this answer
@PeterGrill A brace was missing! :( – egreg Jan 10 '12 at 23:11

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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