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.

This is a follow-up to my earlier question Merge separate footnotes into text.

I now have a similar case, where I need to check whether there actually are footnotes relating to a particular number:

\documentclass[a4paper]{article}

\usepackage{lipsum}
\newcommand{\mylips}[1]{\printfootnote#1 \lipsum[#1]}

\def\printfootnote#1{\footnote{\csname extfootnote#1\endcsname}}
\def\definefootnote#1 #2\endfootnote{%
  \expandafter\def\csname extfootnote#1\endcsname{#2}}
\input{footnotefile}


\begin{document}
 \mylips{1}
 \mylips{2}
 \mylips{3}
 \mylips{4}
 \mylips{5}
 \mylips{6}
 \mylips{7}
\end{document}

footnotefile.tex would be

\definefootnote1 Some footnote\endfootnote
\definefootnote3 Another footnote\endfootnote
\definefootnote7 And another footnote\endfootnote 

The challenge is that I don't want the empty notes to appear at all.

How would I write a test for whether the result of a certain \printfootnote\arabic{somecounter} will be empty?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Well, your \printfootnote should check whether the footnote was defined:

\def\printfootnote#1{%
  \expandafter\ifx\csname extfootnote#1\endcsname\relax % by default \csname FOO\endcsname is \relax
 \stepcounter{footnote}\else % Even if we do not produce footnote, we step the number
 \footnote{\csname extfootnote#1\endcsname}\fi}

This works for me in your example.

enter image description here

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.