2

I am using the footmisc package to reference for footnotes. The problem I have is that when I refer to a footnote on a different page, latex does not reproduce the footnote on that page, I want it to reproduce it so that there is no need to return to that page to see the footnote.

\documentclass{article}
\usepackage{footmisc}
\begin{document}
Example\footnote{\label{test}Some footnote}
\newpage
Example\footref{test}
\end{document}

For example, the above text creates a document with 2 pages and I want the footnote to appear on every page. Here I have forced a new page, but in my document, a page break can happen anywhere.

  • it seems that you do not want a reference simply use \newcommand\footnoteA{\footnote{some footnote}} and then use \footnoteA whenever you need a copy of that note. – David Carlisle Aug 25 '18 at 14:40
  • If ever I use \footnoteA on the same page, will that note create two similar foonotes ? – Noor Aug 25 '18 at 14:41
  • yes, it would . – David Carlisle Aug 25 '18 at 14:42
  • That would be redundant then, what I want is that if its on the same page, it reuses an existing footnote with a label and if ever an existing footnote is referenced on a different page, it recreates it – Noor Aug 25 '18 at 14:44
  • 1
    That's possible but I don't know of any off-the shelf package that offers that and is more code than I have time to suggest in an answer today, but someone may answer (or know of a package that does that already). – David Carlisle Aug 25 '18 at 14:53
2

I think this does what you want.

The basic idea is to make custom \footnote and \footref macros. The custom \footnote macro saves the current page number and footnote text before inserting the footnote. Then the custom \footref checks whether the current page is different to the page the footnote first appears on. If it's different, it inserts a new footnote with the right number, otherwise it just inserts the reference.

\documentclass{article}
\usepackage{etoolbox}
\usepackage{refcount}
\usepackage{footmisc}
% temporary counter to save footnote number
\newcounter{foottmpcnt}
% custom \footnote command
% #1: label
% #2: footnote text
\newcommand{\myfootnote}[2]{%
  \csgdef{footnote@text@#1}{#2}%
  \global\newcounter{footnote@page@#1}%
  \setcounter{footnote@page@#1}{\value{page}}%
  \footnote{\label{#1}#2}}
% custom \footref command
% #1: label
\newcommand{\myfootref}[1]{%
  \footref{#1}%
  \ifnumcomp{\value{footnote@page@#1}}{=}{\value{page}}
    {}
    {\setcounter{foottmpcnt}{\value{footnote}}%
     \setcounter{footnote}{\getrefnumber{#1}}%
     \footnotetext{\csuse{footnote@text@#1}}%
     \setcounter{footnote}{\value{foottmpcnt}}%
     \setcounter{footnote@page@#1}{\value{page}}}}
\begin{document}
Example\myfootnote{testa}{Some footnote}

Example\myfootnote{testb}{Some footnote}

Example\myfootref{testa}
\newpage
Example\myfootnote{testc}{Some footnote}

Example\myfootref{testa}

Example\myfootnote{testd}{Some footnote}

Example\myfootref{testc}

Example\myfootref{testa}
\newpage
Example\myfootref{testa}

Example\myfootref{testc}
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.