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 created a file version.tex with a git log message. This .tex-file is then included in my main.tex file like this:

  Author Name,
  Title of my Book,  %

because footsnippy is used by the document class to print the current date, author, title -- and now the git log -- onto each page.

But: LaTeX now is slowed down quite a bit, because it seems that the \input is now executed on every page. Hrm...


) [11] (./version.tex) [12] (./version.tex) [13] (./version.tex) [14]
(./version.tex) [15] (./version.tex) [16] (./version.tex) [17] (./version.tex)
[18] (./version.tex) [19] (./version.tex) [20] (./version.tex) [21]
(./version.tex) [22]) (./wikitex/00Vorwort.tex (./version.tex) [23]
(./version.tex) [24]) (./version.tex) [25] (./wikitex/teil01beginn.tex
(./version.tex) [26]

Is there any way I can circumvent that the file is read again and again?

share|improve this question
You can save the input in a savebox. – Marco Daniel Aug 20 '14 at 19:35
@MarcoDaniel Thanks, got it working with this tip and googling. If you make it an answer, you have the chance to get the credit for it. – towi Aug 20 '14 at 19:58
up vote 10 down vote accepted

You can load the file just once, the key is the catchfile package:


  \ifcsname gitinput#1\endcsname
    \global\expandafter\let\csname gitinput#1\endcsname\temp
  \csname gitinput#1\endcsname

  Author Name,
  Title of my Book,

When you do \gitinput{version} the first time, the macro \gitinputversion is defined, expanding to the contents of the version.tex file. Then the \gitinputversion command is performed at any call of \gitinput{version}; but the file is not read in more than once.

This has an advantage over setting a reusable box, because the present method will respect the surrounding font shape and font size conditions.

share|improve this answer
Indeed "respect the surrounding font shape and font size conditions" is the advantage. I use the savebox in this specific instance now, but I can imagine, I need your solution another time. Since I had to write the other answer myself, there is no doubt, that your answer is the one to be accepted :-) – towi Aug 21 '14 at 12:01

Without any package I used a savebox as @MarcoDaniel suggested.


    Author Name,
    Title of my Book,

As you can see, I had to add the formatting \tiny into the savebox, because the box itself is saved, not only the loaded file content. This means, that the formatting that was previously done inside the footsnippy command on the \input{version} text does not apply anymore with savebox. So i have to apply it inside the savebox.

share|improve this answer

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.