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.

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?

share|improve this question
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 Nov 7 '13 at 15:06
1  
Seems you've reinvented the sepfootnotes package ;) –  cgnieder Nov 7 '13 at 18:00
    
@cgnieder I would accept your comment as an answer. I was not aware of that package. –  A.Ellett Nov 7 '13 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 Nov 8 '13 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 Nov 8 '13 at 20:14

2 Answers 2

up vote 9 down vote accepted

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

share|improve this answer
    
I think this is nice. What extension does the file with the footnotes have to have? .cpy? –  Guido Jorg Nov 7 '13 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 Nov 7 '13 at 21:08

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}
share|improve this answer

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.