Moving footnote text within source without moving labels

I often write documents with fairly lengthy discursive footnotes to discuss tangents or secondary issues without interrupting the flow of the main text. However, this can make it difficult to edit, since the body of the text is broken by sometimes-quite-long notes. What I would like is a way to move the text of the footnote (while still keeping it within the same file) away from the footnote mark without breaking the default placement rules for footnotes.

I have tried using \footnotemark and \footnotetext, like so:

Paragraph containing a footnote\footnotemark and some more text afterward.
\footnotetext{A very long footnote that now doesn't have to appear in the middle of a
sentence in my source file.}


However, this causes my footnote text to sometimes appear on a page following the footnote mark rather than always appearing on the same page as the mark. (Also it gets a bit messy when I have multiple notes in a paragraph.)

Is there a way to separate the footnote text from the location of the footnote mark within the source code while having the output come out as though the \footnote{was in the middle of the text}? (And preferably allowing for multiple footnotes per paragraph?) Apologies if there is an obvious answer; I've been searching around for a while now I and haven't found anything.

MWE (edited to wrap lines):

\documentclass{article}
\begin{document}

A paragraph that has a footnote\footnote{Like this one here but even longer and more
intrusive so that it makes reading and editing the text very difficult. It probably goes
on and on and might even have \\ multiple \\ long \\ paragraphs inside of it.} in the
middle of it. The footnote is placed correctly, but the source is difficult to read and
edit.

A paragraph with a footnote in the middle of it\footnotemark{} that then continues onto a
new page. The source is easy to read and edit, but the footnote lands in the wrong place.
\newpage
\footnotetext{A footnote that I would like to have appear on the same page as the
footnote mark, but without having the footnote text in the middle of my paragraph in the
source.}

\end{document}

• Here's what I do: Put all footnotes at the end of a sentence. Use a new line for each sentence. For any footnotes longer than a single line, use the Footnote environment from my package, semantic-markup. This way the note is in its own space and can be moved and edited easily. It does still disrupt the text, but this is a good reminder to me that the footnote will disrupt the text for the reader and that I should try to avoid long, discursive footnotes! – musarithmia Aug 24 '19 at 2:23

A simple solution without packages is to define the footnote somewhere outside of the paragraph in a command and use this command as argument to \footnote. The disadvantage is that it is required to define the command before it is used, otherwise you will get an undefined control sequence error. This is also an issue when using the sepfootnotes package as mentioned in the other answer, although in that case there is only a warning instead of an error (but the footnote is not printed if it is defined after using it).

In order to define a footnote after use it can be stored in the .aux file, using for example the globalvals package. This requires two compilations of the .tex file, similar to labels and references.

MWE:

\documentclass{article}
\usepackage{globalvals}
\begin{document}
% simple \def without packages, needs to be defined before use
\def\firstlongnote{Like this one here but even longer and more
intrusive so that it makes reading and editing the text very difficult. It probably goes
on and on and might even have \\ multiple \\ long \\ paragraphs inside of it.}

A paragraph that has a footnote\footnote{\firstlongnote} in the
middle of it. The footnote is placed correctly, but the source is difficult to read and
edit.

% using the globalvals package, use the footnote first and define later
A paragraph with a footnote in the middle of it\footnote{\useVal{longnote}} that then continues onto a
new page. The source is easy to read and edit, but the footnote lands in the wrong place.
\defVal{longnote}{A footnote that I would like to have appear on the same page as the
footnote mark, but without having the footnote text in the middle of my paragraph in the
source.}

\end{document}


Result:

• Thank you! This is exactly what I was looking for -- I much prefer being able to put the notes after the text; it makes the source file very readable. – Rusty Sep 6 '19 at 16:52

It seem that the package sepfootnotes does exactly what your are searching for.

According to its documentation, the package separates footnotes (or endnotes) input from their usage. It provides one command to define the content of a note, and another command to insert the note in the document.

You may group footnote definition any particular order, either in the preamble, at the beginning of chapters or sections, before a paragraph or even in a separate file.

In addition, you may interchangeably use sepfootnotes and standard \footnote in the same document. The package is uploaded to CTAN.

If sepfootnotes does not suites you, it is possible to make the source more readable by using formatting, in particular if you have an advanced editor.

A paragraph that has a footnote\footnote{%
Like this one here but even longer and more intrusive
so that it makes reading and editing the text very difficult.
It probably goes on and on and might even have \\ multiple
\\ long \\ paragraphs inside of it.}%
\ in the middle of it. The footnote is placed correctly, but the source is