2

I wrote the following code:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath, amssymb, amsfonts}
\usepackage{footnote}
\usepackage[italian]{babel}
\usepackage{soul}
% serve (forse insieme a graphicx) per aggiungere freccia e testo/equazione sopra segno uguale =
\usepackage{mathtools}
% serve per plottare freccia grande, vuota, ruotata (vedi file: quadrato con frecce)

\newcommand{\eqstackrel}[1]{\stackrel{\substack{\mathclap{#1}\\[0.5ex]\displaystyle\uparrow\\ ~}}{ = } }
%serve per aggiungere testo sopra segno uguale =


\title{\textbf{Elementi di Calcolo delle Probabilità}}
\author{}
\date{}

\begin{document}
\maketitle  %serve per stampare il titolo ed eventualmente altro

Ecco del testo\footnote{Ecco una nota al testo.}

\begin{align}
P(R_2 | B_1) &= \left( 1 - P(R_1 | R_2) \right) \frac{P(R_2)}{1 - P(R_1)}
\eqstackrel{P(B | A) = P(B) \quad \text{rel. 126 a pag. 49}}
\\
&= \left( 1 - P(R_1) \right) \frac{P(R_2)}{1 - P(R_1)} \\
&= P(R_2)
\eqstackrel{\text{per hp\footnotemark}}
\\
&= \frac{R}{R + B}
\end{align}
\footnotetext{aaa}


\end{document}

The problem is that the footnote has a wrong number; in particular the previous footnote has the number 1, instead the footnote introduced by footmark has the number 4. How can I fix it?

5
  • 1
    You should put a complete MWE, with the \documentclass, the \usepackage used, etc. so that we could compile directly... Oct 9 '21 at 16:01
  • Hello @F.Pantigny thank you Oct 9 '21 at 16:17
  • Not related: You should use \bigl( and \bigr) instead of \left( and \right) in your case. Oct 10 '21 at 8:17
  • Hi @F.Pantigny what is the difference? Oct 10 '21 at 8:34
  • 1
    In mathematical notations, when brackets are nested within other brackets, the surrounding brackets must be bigger. Here with \left( and \right), the exterior brackets have the same size as the interior ones. For a good mathematical notation, you have to fix the sizes of the brackets 'by hand'. Oct 10 '21 at 8:37
2

The culprit is \mathclap. I suggest not using \mathclap (but \clap).

\documentclass{article}
\usepackage{amsmath, amssymb, amsfonts}
\usepackage{footnote}
\usepackage[italian]{babel}
\usepackage{mathtools}

\newcommand{\eqstackrel}[1]{\stackrel{\substack{
\clap{$\scriptstyle #1$}\\[0.5ex]\displaystyle\uparrow\\ ~}}{ = } }

\begin{document}
Ecco del testo\footnote{Ecco una nota al testo.}

\begin{align}
P(R_2 | B_1) &= \left( 1 - P(R_1 | R_2) \right) \frac{P(R_2)}{1 - P(R_1)}
\eqstackrel{P(B | A) = P(B) \quad \text{rel. 126 a pag. 49}}
\\
&= \left( 1 - P(R_1) \right) \frac{P(R_2)}{1 - P(R_1)} \\
&= P(R_2)
\eqstackrel{\text{per hp\footnotemark}}
\\
&= \frac{R}{R + B}
\end{align}
\footnotetext{aaa}

\end{document}

Output of the above code


Since you have loaded footnote, I suggest to put the {align} in a {savenotes} and use \footnote directly. However, the command \footnote must not be put in the command \text but just after.

\documentclass{article}
\usepackage{amsmath, amssymb, amsfonts}
\usepackage{footnote}
\usepackage[italian]{babel}
\usepackage{mathtools}

\newcommand{\eqstackrel}[1]{\stackrel{\substack{
\clap{$\scriptstyle #1$}\\[0.5ex]\displaystyle\uparrow\\ ~}}{ = } }

\begin{document}
Ecco del testo\footnote{Ecco una nota al testo.}

\begin{savenotes}
\begin{align}
P(R_2 | B_1) &= \left( 1 - P(R_1 | R_2) \right) \frac{P(R_2)}{1 - P(R_1)}
\eqstackrel{P(B | A) = P(B) \quad \text{rel. 126 a pag. 49}}
\\
&= \left( 1 - P(R_1) \right) \frac{P(R_2)}{1 - P(R_1)} \\
&= P(R_2)
\eqstackrel{\text{per hp}\footnote{aaa}}
\\
&= \frac{R}{R + B}
\end{align}
\end{savenotes}

\end{document}
1
  • thank you very much for your precious help Oct 9 '21 at 20:21
1

Strictly speaking, this is not an answer to the question but, since the OP searches a way to add explanations to a calculus, I will suggest to use {DispWithArrows} of witharrows. The footnotes are correctly extracted (by use of the package footnote or, if you prefer, footnotehyper).

\documentclass{article}
\usepackage[italian]{babel}
\usepackage[footnote]{witharrows}


\begin{document}
Ecco del testo\footnote{Ecco una nota al testo.}

\begin{DispWithArrows}[fleqn,displaystyle]
P(R_2 | B_1) &= \left( 1 - P(R_1 | R_2) \right) \frac{P(R_2)}{1 - P(R_1)}
\Arrow{$P(B | A) = P(B)$ \\ rel. 126 a pag. 49}
\\
&= \left( 1 - P(R_1) \right) \frac{P(R_2)}{1 - P(R_1)} \\
&= P(R_2)
\Arrow{per hp\footnote{aaa}}
\\
&= \frac{R}{R + B}
\end{DispWithArrows}

\end{document}

Output of the above code

5
  • I like this alternative Oct 10 '21 at 8:35
  • F.Pantigny is there a way to get the same result but with a single number on the right side? Oct 10 '21 at 8:46
  • 1
    In nicematrix, you have a environment {WithArrows} which is similar to {aligned} of amsmath. That environment may be inserted in an environment {equation} and you will have only one number. Oct 10 '21 at 8:57
  • The solution with \usepackage[footnote]{witharrows} has the drawback that you should compile two times the code in order to see the arrows correctly (I tested it in Texmaker) Oct 10 '21 at 9:46
  • 1
    You are right. However, you won't have to compile twice if you only do a modification of another part of your document. Moreover, there is tools such as latexmk which do the right number of compilations directly. For instance, Overleaf uses latexmk (afaik). Oct 10 '21 at 9:56

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.