4

I have an ambitious plan to annotate and comment a fairly lengthy book that is in the public domain. I plan on doing this through extensive footnoting, but I was wondering if there is any way, once footnotes are added, to print the original document sans footnotes.

Basically, I just want a command that can tell the interpreter to ignore all of the footnotes.

The first thought that comes to mind would be to use the comment package and create a command that redefines \footnote:

\let\Oldfootnote\footnote
\renewcommand\footnote[1]{\begin{comment}#1\end{comment}}

But this doesn't work.

I feel like this is a problem that must already have a really simple solution, but I couldn't find it.

2
  • 1
    Welcome to TeX SE! 'doesn't work' isn't much to go on. Could you be more specific e.g. 'when I use this my computer orders pizza at my expense and the guinea pig goes on strike'. (Admittedly this seems rather unlikely or you'd probably have mentioned it but you get the idea.) Do you get error messages? Or do you just get footnotes?
    – cfr
    Apr 25, 2015 at 4:02
  • 3
    Have you tried \renewcommand\footnote[2][]{\relax}?
    – cfr
    Apr 25, 2015 at 4:04

1 Answer 1

7

The wrapping of \begin{comment}#1\end{comment} as something that eats up the content of a footnote does not work due to the very sophisticated way the comment package is handling all content within comment environment (or \comment...\endcomment pair) (it eats up even # parameters.

Another breakdown is the fact that \footnote in fact has two arguments. The first one is optional and is designed for a user-defined footnote mark, the second one is mandatory, having the real footnote text.

The most simple way is to \renewcommand footnote and \relax the content.

If it's necessary to relax only some footnotes in a region of a document and enable it after I decided to add a command \EnableFootNotes and \DisableFootnotes respectively.

The optional argument of \footnote 'requires' a \LetLtxMacro approach (using Heiko Oberdiek's letltxmacro package)

\documentclass{article}

\usepackage{letltxmacro}

\LetLtxMacro\Oldfootnote\footnote

\newcommand{\EnableFootNotes}{%
  \LetLtxMacro\footnote\Oldfootnote%
}

\newcommand{\DisableFootNotes}{%
  \renewcommand{\footnote}[2][]{\relax}
}


\usepackage{blindtext}
\begin{document}


With footnotes:

\blindtext\footnote{first}

\blindtext\footnote[5]{second}

Without footnotes:\DisableFootNotes
\blindtext\footnote{third}

\blindtext\footnote[6]{fourth}

Enabling again:\EnableFootNotes
\blindtext\footnote{fifth}

\blindtext\footnote[10]{sixth}



\end{document}

enter image description here

3
  • \relax is it necessary?
    – touhami
    Apr 25, 2015 at 6:11
  • @touhami: No, not really, but safer?
    – user31729
    Apr 25, 2015 at 7:53
  • Thanks, works perfectly! I figured there was a simple solution...and good call on the \EnableFootNotes and DisableFootNotes commands. Also, I didn't know about the letltxmacro package before. So much to learn...
    – Kyle A.
    Apr 25, 2015 at 19:53

You must log in to answer this question.

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