Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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
add comment

1 Answer

up vote 7 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}}
\input{footnotefile}

(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:

\documentclass[a4paper]{article}

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

\begin{document}
Text text\printfootnote1) text text text\printfootnote2) text text text.\printfootnote3) Text
\end{document}

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
add comment

Your Answer

 
discard

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.