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.

1 Answer 1


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!}}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .