# Footnote, non-inline syntax?

I would like to use footnotes without cluttering the container paragraph. Something like:

This is a very long complex\footnote[a] sentence.

\foottext[a]{So complex that I would prefer to pull out the footnote text.}


The idea comes from the [linktext][1], [1]: http://url.com markdown syntax.

• \footnotemark and \footnotetext? Nov 14 '13 at 9:50
• Doesn't this implies manual numbering? Nov 14 '13 at 9:53
• Nov 14 '13 at 10:11
• @OlivierBlanvillain no, it doesn't. And it works fine with hyperref too.
– user4686
Nov 14 '13 at 13:09
• Can you like or provide a footnotemark\footnotetext example? What is saw here seems kind of manual to me. Nov 14 '13 at 14:15

The sepfootnotes package might do the trick, but the footnote content has to come before it's usage:

\documentclass{scrartcl}
\usepackage{sepfootnotes}
\newfootnotes{A}
\begin{document}

\Anotecontent{a}{So complex that I would prefer to pull out the footnote text.}

This is a very long complex\Anote{a} sentence.

\end{document}

• Unfortunately, it seems not possible to first state Anote, and then provide Anotecontent, which is a more natural writing flow. Sep 28 '15 at 13:17

The following code defines a macro \longfootnote[fn-label]{footnote text}, which produces a footnote and assigns it a label which can be cross-referenced in the usual way using \ref to produce a footnote mark.

\makeatletter
\def\longfootnote[#1]{%
\stepcounter{footnote}%
\@bsphack
\protected@write\@auxout{}%
{\string\newlabel{#1}{{%
\string\begingroup
\string\c@footnote \number\c@footnote\string\relax
\string\unrestored@protected@xdef\string\@thefnmark{%
\string\thefootnote}%
\string\endgroup
\string\@footnotemark
}{\thepage}}}%
\@esphack
\protected@xdef\@thefnmark{\thefootnote}
\@footnotetext}
\makeatother


This code is effectively a composition of of the code from \label and \@xfootnotemark from latex.ltx, writing a label to the auxiliary file which consists of a footnotemark for the new footnote. If you use an editor which recompiles whenever the labels change, you should quickly obtain a new document in which references to the long footnotes appear properly.

Sample document.

\documentclass{article}
\usepackage[left=5mm,right=5mm,paperheight=55mm, paperwidth=62mm]{geometry}
\thispagestyle{empty}
\makeatletter
\def\longfootnote[#1]{%
\stepcounter{footnote}%
\@bsphack
\protected@write\@auxout{}%
{\string\newlabel{#1}{{%
\string\begingroup
\string\c@footnote \number\c@footnote\string\relax
\string\unrestored@protected@xdef\string\@thefnmark{%
\string\thefootnote}%
\string\endgroup
\string\@footnotemark
}{\thepage}}}%
\@esphack
\protected@xdef\@thefnmark{\thefootnote}
\@footnotetext}
\makeatother

\begin{document}
\section{A demonstration}

Here\footnote{foo} is\ref{c} a\ref{a} test\footnote{bar} paragraph.\ref{b}

\longfootnote[a]{baz}
\longfootnote[b]{gleep}
\longfootnote[c]{glorp}
\label{sec:test}

This text\footnote{fie} is a part of Section~\ref{sec:test}.
\end{document}


Result.

The long footnotes should not interfere with any other cross-referencing, as illustrated above.

• i really like your solution, but it seems incompatible with hyperref package. If you have a fix -- please provide, thanks!! Jul 16 '15 at 16:44

You might also just define a new command and use it inside the regular \footnote command, e.g.,

\newcommand{\fnOne}{A footnote.}
\newcommand{\fnTwo}{Another footnote.}

A text\footnote{\fnOne} with some\footnote{\fnTwo} footnotes.


Which produces the expected:

One issue with this approach is that you cannot use numbers within command names, which might or might bother you in this case.

That said, I agree that using the setfootnotes package might be the more canonical answer and @Neil de Beaudrop 's answer is more flexible and useful in some scenarios. I'm just providing an alternative.

Adding to OlivierBlanvillain's answer, the sepfootnotes package also provides the \sepfootnotecontent and \sepfootnote commands out of the box:

\documentclass{article}
\usepackage{sepfootnotes}
\begin{document}

\sepfootnotecontent{a}{So complex that I would prefer to pull out the footnote text.}
This is a very long complex\sepfootnote{a} sentence.

\end{document}


Result: