1

For my typesetting purposes I need to check if the "footnote tag" appears in the same page of (the beginning of) the "footnote text". Sometimes indeed, it happens that, e.g., I have the footnote tag in a page and the footnote text in the next page.

Currently I do this check visually... and this is very boring and error prone.

I figured out to (temporarily) redefine the \footnote command to make it print the "tag page" and the "text page" in the .aux file that I would parse with an elisp script but, honestly I don't have any idea how to do that (I mean the LaTeX part of the trick).

To better exlain my idea, I'd like to have in the .aux file a string like this:

"Foonote1: footnotemarkePage=X, footnotetextPage=Y"  

Could anyone help me?

Is there a better solution to do that?

I'm not able to provide a MWE but I hope this can help:

\documentclass[11pt]{article}

\begin{document}

I need to print this footnote mark.\footnote{Footnote text.} page 
and the related footnote text page in the ``.aux'' file.

\end{document}

Here a screenshot of a real case.

enter image description here

Note. I'm not asking a solution to solve the problem but to "detect" it.

Note added. Sometimes the footnote text splits into two (or more) pages. It would be helpful a trick to detect this with an automatic solution.

Work in progress:

Using an egreg solution related to a similar issue I tried this:

\documentclass[12pt]{article}

\usepackage{blindtext}

\usepackage{etoolbox}
\usepackage{hyperref}

\makeatletter
\AtBeginDocument{%
  \renewcommand{\NR@setref}[1]{%
    \ref@page@write{#1}%
    \begingroup\@safe@activestrue\expandafter\endgroup
    \expandafter\NR@@setref\csname r@#1\endcsname
  }%
}
\newcommand{\ref@page@write}[1]{%
  \protected@write\@auxout{}{\string\ref@page{#1}{\thepage}}%
}
\newcommand{\ref@page}[2]{}
\makeatother

\newcounter{MyFootnote}

\let\MyOldFootnote\footnote
\renewcommand{\footnote}[1]{\stepcounter{MyFootnote}\label{FOOTNOTE\arabic{MyFootnote}}\MyOldFootnote{\ref{FOOTNOTE\arabic{MyFootnote}}#1}}

\begin{document}

\setcounter{section}{4}

\section{Section}

I need to print this footnote mark.\footnote{Footnote text.} page and the related footnote text page in the ``.aux'' file.

\blindtext
\blindtext
\blindtext
\blindtext

I need to print this footnote mark.\footnote{Footnote text.} page and the related footnote text page in the ``.aux'' file.

\blindtext
\blindtext
\blindtext
\blindtext

I need to print this footnote tag.\footnote{Footnote text.} page and the related footnote text page in the ``.aux'' file.

\end{document}

Now in the .aux file I get:

\newlabel{FOOTNOTE1}{{5}{1}{Section}{section.5}{}}
\ref@page{FOOTNOTE1}{1}
\newlabel{FOOTNOTE2}{{5}{2}{Section}{section.5}{}}
\ref@page{FOOTNOTE2}{2}
\newlabel{FOOTNOTE3}{{5}{3}{Section}{section.5}{}}
\ref@page{FOOTNOTE3}{3}

So I can compare the page the label is referred to (and where the footenotemark appears) with the page on which the footnotetext appears. The only problem with this solution is that it adds an extra string at the beginning of the foootnote text.

In the case of the screenshot I have:

\newlabel{FOOTNOTE11}{{4.2.3}{29}{xxxxxxxxxx}{equation.4.25}{}}
\ref@page{FOOTNOTE11}{31}

where "29" in the footnotemark's page number and "31" is the footnotetext page number. Please, keep in mind that the redefinition of the \footenote command is intended to be temporary.

Gabriele
  • 1,815
  • Please help us (and also you) and add a minimal working example (MWE), that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass and ending with \end{document}. Just a try: see Footnote appears on next page. Why? – Bobyandbob Jul 21 '17 at 09:59
  • @Bobyandbob I'm not able to reproduce the problem on a MWE and the files I'm working on are copyrighted material. I'll provide anyway a minimal working code. – Gabriele Jul 21 '17 at 10:07
  • 1
    You could use dummy text manually or with lipsum or blindtext. https://texblog.org/2011/02/26/generating-dummy-textblindtext-with-latex-for-testing/. It is importent to see your problem. Pleace try to reprocude your problem with manimial and not copyrighted text – Bobyandbob Jul 21 '17 at 10:15
  • Is it a standard \footnote or something like \footnotemark and \footnotetext? – egreg Jul 21 '17 at 10:43
  • @egreg Always standard \footnote. I hoped in your help 'cause you fixed a similar issue in the past: https://tex.stackexchange.com/a/365954/33634 ;-) – Gabriele Jul 21 '17 at 10:47
  • 2
    I'm not sure how a standard footnote can get detached from its marker. Something more detailed is needed. – egreg Jul 21 '17 at 10:58
  • @egreg. It doesn't matter for my purposes. Once I detect the problem I can easily fix it. In this specific case the problem is caused by a \afterpage{\FloatBarrier} string. But I would find a way to automatically detect this problems (e.g. with a script). – Gabriele Jul 21 '17 at 11:09
  • 1
    @GabrieleNicolardi Using \afterpage in a production environment is not recommended. – egreg Jul 21 '17 at 12:11
  • @egreg I really thank you for you help but my problem is not the \afterpage package (that I use carefully). I encountered this kind of problem with the footnotes layout in different contexts. I'm not finding a way to avoid them but to detect them. Please let's stay on the topic. – Gabriele Jul 21 '17 at 12:45
  • 2
    @GabrieleNicolardi This is on topic. About the (wrong) problem: the footnotes are added during the output routine and their text and formatting has already been done. – egreg Jul 21 '17 at 12:48
  • @egreg I've already fixed it. I'm searching for a way to detect this kind of problems in the future. – Gabriele Jul 21 '17 at 12:51
  • 2
    I've never had LaTeX put the footnote mark on a different page from the footnote. @egreg What's the problem with \afterpage? – cfr Jul 21 '17 at 13:49

1 Answers1

1

Ok, this works for my purposes:

I'll compile with:

latex '\AtBeginDocument{\newcounter{MyFootnote} \let\MyOldFootnot  \footnote \renewcommand{\footnote}[1]{\stepcounter{MyFootnote}\label{FootnoteMark\arabic{MyFootnote}}\MyOldFootnote{\label{FootnoteText\arabic{MyFootnote}}#1}}} \input{Footnotes.tex}'

And I'll get in the .aux file:

\newlabel{FootnoteMark1}{{5}{1}}
\newlabel{FootnoteText1}{{1}{1}}
\newlabel{FootnoteMark2}{{5}{2}}
\newlabel{FootnoteText2}{{2}{2}}
\newlabel{FootnoteMark3}{{5}{3}}
\newlabel{FootnoteText3}{{3}{3}}

so I can compare (with a script) the page numbers of footnotemark and footenotetext.

I know it is not the most beautiful solution but it works for me.

Gabriele
  • 1,815