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?


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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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