TL;DR: Is there a package that allows writing the text of a footnote after the position where the mark should be inserted? Note that I'm asking about positioning of source code, not about positioning of the note in the output document.

When writing LaTeX I find the inline character of footnote source somewhat distracting.

This is some text\footnote{That for
whatever reason contains a long 
footnote. The main text becomes split 
apart} so far that it is barely readable. 

Doing tricks with newlines like

This is some text\footnote{
  That for whatever reason contains a long
  footnote. The main text becomes split
so far that it is barely readable.

Also helps only so much. I'd much prefer to write

This is some text\fn{1} that contains a
couple\fn{2} footnotes yet remain readable.

\text{1}{Here is the text of the first
footnote, conveniently readable while reading
the main source, yet not disrupting it.}


I know that some tricks are possible with \footnotemark and \footnotetext. When having more than one footnote in a paragraph however this would require manually changing the footnote counter, which is too inconvenient to make this a sensible alternative. Also if I'm not mistaken, it carries the risk of causing footnotes to be displayed on the wrong page, when the paragraph stretches to the next page but the \footnotemark is in text on the current page.

+---------------+  +---------------+
|...            |  |end of the page|
|               |  |...            |
|               |  |               |
|some text with²|  |—————          |
|footnote on the|  |²The FNText    |
+---------------+  +---------------+

Is there maybe some package that automates such a style?

As a quick hack I sometimes used constructs like

\fnlater\myfnI{The footnote text must be
defined before the paragraph.}
Here is some textparagraph\myfnI that refers
to the previously defined footnote. 

Sadly this custom solution has two major flaws:

  1. It requires defining the footnote before using it, while intuitively footnotes are expected after the surrounding text.

  2. It should cause a compilation error, when the footnote is accidentially used twice.

  3. It should also cause a compilation error, when the footnote isn't used at all.

Since I don't think that these issues are easily fixed, especially the requirement to define the footnote before the surrounding text, using custom hacks is undesireable.

If such a package exists for LaTeX, availability of a corresponding module for LyX would be even better.

As a minimal compileable example put any of these code examples into a skeleton

  • LyX already provide this functionality in its editor; that is, to code-fold a footnote so it's not distracting you from reading the footnote mid-text. Just click on foot 1. I assume you're asking whether an additional package that does this sort of magic should be used by a LyX module rather than the default footnote module. – Werner May 27 '14 at 16:24
  • I know, but its insufficient. I need to SEE the footnote (without folding and unfolding all the time), yet also not to disturb the main text too much. But yes, if there is such a LaTeX package, I'd like to also have a module in LyX that enables that package with insets. Though such a module would probably be easier to write than the corresponding LaTeX package, which likely would need auxilliary-file magic. – kdb May 27 '14 at 16:26

I managed to put this together. It only allows clear text in the footer, but apart from that it should do all you wanted. No error is raised if a label is undefined, however, as that would give an error every time a new footnote is added.

Edit: Now it supports formatting thanks to \detokenize :D

Footnotes are defined anywhere in the document with \definefootnote{label}{footnotetext} and used anywhere else in the document with \usefootnote{label}.


        {\expandafter\gdef\csname footnote@#1\endcsname{#2}%
        % Check if footnote is unused
            {\expandafter\ifx\csname footnoteused@#1\endcsname\relax%
                \errmessage{Error: Footnote #1 never used!}%


    {% Check if footnote has been defined earlier
    \expandafter\ifx\csname footnotedefd@#1\endcsname\relax
        \expandafter\def\csname footnotedefd@#1\endcsname{}%
        \errmessage{Error: Footnote #1 defined twice!}
    {% Check if footnote is defined
    \expandafter\ifx\csname footnote@#1\endcsname\relax
        % not yet defined, give warning?
        % always happens first time used, of course
        \expandafter\def\csname footnoteused@#1\endcsname{}%
        % Check if footnote has been used
        \expandafter\ifx\csname footnoteused@#1\endcsname\relax
            \footnote{\csname footnote@#1\endcsname}%
            \expandafter\def\csname footnoteused@#1\endcsname{}%
            \errmessage{Error: Footnote #1 used twice!}




  • \immediate\write18 ? – 1010011010 May 27 '14 at 17:58
  • That didn't work :/ – Jonas Granholm May 27 '14 at 18:03
  • \newrobustcmd{\WriteNow}{\immediate\write\@auxout{\string <stuff to write>}} I used something like this.. but I always use counters so I don't know about actual name tags – 1010011010 May 27 '14 at 20:29
  • I got the aux file working :D (Although only in \AtEndDocument) – Jonas Granholm May 27 '14 at 23:07
  • But bottom line "there is no such package"? I want to avoid "per file" solutions, since there's a good chance that they cause me to not understand my own documents later. Otherwise though, it is a very educational example :) With some counter usage one may make labels obsolete too and raise an error when the number of used and defined footnotes doesn't match up at the end of e.g. a section. – kdb May 28 '14 at 12:17

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.