13

Sometimes I find footnotes either annoying or distracting when trying to edit the body of a text: particularly one which is heavily annotated with footnotes. One solution I've come up with is to gather my footnotes together into files organized to mirror to the file/directory structure I'm using for the overall document.

Each footnote is given its own unique(ish) macro. Here is an example of the sort of code I use to define a footnote macro:

\makeatletter
%% #1 = footnote identifier     
%% #2 = footnote content
\long\def\setfootnote#1#2{%%
  \expandafter\long\expandafter\def\csname ae@footnote@#1@ftnt@\endcsname{#2}}
\def\aefootnote#1{\footnote{\csname ae@footnote@#1@ftnt@\endcsname}}
\makeatother

This is a bit flattened from how I typically define my footnote commands, but my file/directory structure is beyond the scope of this question and would unduly complicate this example.

For the MWE I have three files:

footnote.tex

\setfootnote{first footnote}{This is just an example footnote.}
\setfootnote{another footnote}{sf;ksdf  sf;lskf s;df spewr po s;fksf; sdkf.}

main_matter.tex

\input{footnotes}

Here is an illustration of using my footnotes.\aefootnote{first footnote}
This is another footnoted sentence.\aefootnote{another footnote}

master_doc.tex

\documentclass{article}
\makeatletter
%% #1 = footnote identifier 
%% #2 = footnote content
\long\def\setfootnote#1#2{%%
  \expandafter\long\expandafter\def\csname ae@footnote@#1@ftnt@\endcsname{#2}}
\def\aefootnote#1{\footnote{\csname ae@footnote@#1@ftnt@\endcsname}}
\makeatother
\begin{document}

\input{main_matter}

\end{document}

This works pretty well for me. It cleans up the content of the master document. I can see where the footnotes are, but I don't have to be distracted by their content when writing and editing the main matter.

But memory-wise this is an extremely wasteful approach. If I have a long document, then I'm forcing LaTeX to know and remember my footnotes for the entire life of the document.

I could implement a garbage collection system. That is, I could track the macros for my footnotes by the file currently being compiled by storing their names in a macro such as \ae@garbage@collection. When I'm done compiling that file I could then do something along the following lines

\expandafter\let\csname ae@footnote@.....@ftnt@\endcsname\ae@undefined@macro

where ..... is the identifier for each footnote note macro I'm deleting. This could be automated through a macro \ae@delete@garbage.

In other words, I'm saying I know ways to get around cluttering up LaTeX's memory with things it only really needs once.

What I'm interested in knowing is whether someone has suggestions for a better approach. Is there a more efficient way of managing footnotes which nevertheless avoids cluttering up the source file(s) for the master document?

5
  • 2
    Use emacs (with AUCTeX): M-x TeX-fold-mode to get started, then C-c C-o C-b to fold all foldable items in the current buffer according to TeX-fold-type-list (notably footnotes); C-c C-o C-r does 'region', and C-c C-o C-p does paragraph. See the AUCTeX page on folding.
    – jon
    Commented Nov 7, 2013 at 15:06
  • 2
    Seems you've reinvented the sepfootnotes package ;)
    – cgnieder
    Commented Nov 7, 2013 at 18:00
  • @cgnieder I would accept your comment as an answer. I was not aware of that package.
    – A.Ellett
    Commented Nov 7, 2013 at 18:55
  • Neither the clipboard package nor the sepfootnotes package (which are from the same author, by the way) change the memory point, though. The clipboard package provides simple wrappers around \input, \@namedef and \@nameuse. The sepfootnotes package also saves each footnote as a macro. I'm not convinced that memory really is a big issue, or is it?
    – cgnieder
    Commented Nov 8, 2013 at 20:02
  • @cgnieder Yes indeed. After looking into the implementation of those two packages last night, I realized that neither clipboard nor sepfootnotes resolved the memory issue. But, as you say, memory is probably not such a big issue. I hadn't been aware of either of these packages previously. Of the two, sepfootnotes is very similar to my approach. As for `clipboard, I'm not so sure I like the idea of having to compile two files.
    – A.Ellett
    Commented Nov 8, 2013 at 20:14

3 Answers 3

12

A easier option could be clipboard:

The file with the footnotes: (for example footnotes.tex)

\documentclass{article}
\usepackage{clipboard}
\newclipboard{myfootnotes}
\begin{document}
\Copy{lore}{\footnote{This is a footnote.}}
\Copy{ipsum}{\footnote{This is a more long footnote.}}
\Copy{dolor}{\footnote{\emph{Neque porro quisquam est qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit}.}}
\end{document}

The file with the main text: (for example main.tex)

\documentclass[a5paper,12pt]{article}
\usepackage[bmargin=14cm]{geometry}
\usepackage{clipboard}
\openclipboard{myfootnotes}
\begin{document}
This is the main text with a footnote,\Paste{lore}
another footnote \Paste{ipsum}  and one Cicero quote.
\Paste{dolor}
\end{document}

Notes:

The file names are irrelevant, but obviously both files must share the name of the clipboard.

Because content of footnote.tex is copied (to a temporal myfootnotes.cpy) and pasted into main.tex, you must compile first footnote.tex and after that, compile main.tex.

The original purpose of this package is to reuse the text of one stand alone document into anothers, but if the first file is only to maintain the clipboards, alternatively you can write directly myfootnotes.cpy, including only commands with this format:

\clipboard{name}{text}

But obviously, if you use \newclipboard{myfootnotes} in any .tex file, this .cpy file will be overwritten!

The result:

MWE

4
  • I think this is nice. What extension does the file with the footnotes have to have? .cpy? Commented Nov 7, 2013 at 20:58
  • 1
    @GuidoJorg No, both are just .tex files, so you can use something like footnotes.tex (the file name is irrelevant). This make a temporal myfootnotes.cpy.
    – Fran
    Commented Nov 7, 2013 at 21:08
  • \Copy{lore}{\footnote{...}} is odd. And this is actually duplicating the sepfootnotes package. It's much simpler to go \sepnotecontent{lore}{...} and then \sepnote{lore}.
    – n.r.
    Commented Sep 2, 2015 at 16:46
  • @nicolai.rostov I not think it's very relevant the different complexity or oddity of both solutions. After all both packages are easy to use with a similar syntax (not surprising because both are of the same author). The main point is that sepfootnotes is specific for the problem of the footnotes but worth knowing clipboard because is a general solution for any type of chunk code that must be reused or might disrupt the flow of reading.
    – Fran
    Commented Sep 2, 2015 at 20:28
7

Yep. This is precisely what the sepfootnotes package does, as cgnieder has remarked above:

\documentclass{article}
\usepackage{sepfootnotes}
\newfootnotes{x}
\xnotecontent{key}{content}
\begin{document}
bla bla bla\xnote{key}
\end{document}
2

My solution :

1.file Notes.tex:

\documentclass[8pt]{article}

\begin{document}
%<*notes004>
\footnote{La mia footnotes è questa.}
%</notes004>

\end{document}

2. in the main.tex file:

\usepackage{catchfilebetweentags}
\newcommand{\loadnote}[1]{%
    \ExecuteMetaData[notepie.tex]{notes#1}%
}
  1. for example in the masterdom.tex insert

I want to explain what is the method to insert footnotes in an external file, to know it is necessary to follow the instructions\loadnote{004}

ps : I did not know the existence of this post and I wrote another post

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .