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

A text (written by someone else) has numbered footnote insertion points:

Text text1) text text text2) text text text.3) Text ... 

The actual footnote-texts are in a second file:

1) text of note one
2) text of note two
3) text of note three

Manually putting each note where it belongs would be a nuisance; using endnotes instead of footnotes is unfortunately not an option. Using \footnotemark[num] and \footnotetext[num] gives me the right numbering but not the right distribution over the pages.

I was wondering whether I could define one numbered macro per note (e.g. \newcommand{\sepfootnote1}{\footnote{text of note one}} and calling each macro at the appropriate point in the text but as macro names may not contain numbers this wouldn't be possible with a simple RegEx.

Is there another way to make LaTeX do the tedious work?

share|improve this question
Cf my follow-up question: Print only existing footnotes / suppress empty footnotes – Florian Nov 3 '11 at 19:38
up vote 8 down vote accepted

If doing text substitutions is not a problem, you can prepend \printfootnote to all expressions such as 1) or 2) in the text and \definefootnote in the footnote file; append also \endfootnote at the end of each footnote text. Then

\def\printfootnote#1){\footnote{\csname extfootnote#1\endcsname}}
\def\definefootnote#1) #2\endfootnote{%
  \expandafter\def\csname extfootnote#1\endcsname{#2}}

(where footnotefile.tex is the file containing the footnote text) should do the trick, at least if the footnote file is not extremely big.

Here is main.tex:


\def\printfootnote#1){\footnote{\csname extfootnote#1\endcsname}}
\def\definefootnote#1) #2\endfootnote{%
  \expandafter\def\csname extfootnote#1\endcsname{#2}}

Text text\printfootnote1) text text text\printfootnote2) text text text.\printfootnote3) Text

And here is footnotefile.tex:

\definefootnote1) First footnote\endfootnote
\definefootnote2) Second footnote\endfootnote
\definefootnote3) Third footnote\endfootnote

Note: use \def and not \newcommand, as the trick involves delimited arguments.

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.