Сноски внутри мини-страницы перед заметкой о задачах, использующей сноску на полях, оказываются в нижней части заметки о задачах.

Сноски внутри мини-страницы перед заметкой о задачах, использующей сноску на полях, оказываются в нижней части заметки о задачах.

Внутри мини-страницы я использую сноски, которые должны быть напечатаны в конце мини-страницы. Я также использую marginnoteи переопределяю, \marginparчтобы быть \marginnote, потому что я использую их внутри других плавающих элементов (в первую очередь, плавающих элементов рисунков). Более того, я использую todonotesдля печати, ну, todos на полях.

Если я использую все вместе, todonote на мини-странице «поглощает» все уже набранные, но еще не напечатанные сноски и печатает их у себя внизу, т. е. внизу todonote.

МВЭ

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}

\usepackage{marginnote} % Enhanced marginpar
\usepackage{todonotes}

%
% We need to redefine \marginpar.
% \marginpar does not work inside floats, but \marginnote does.
% Also \todo uses \marginpar internally and this way it actually uses \marginnote.
% See manual for marginnote and sec. 1.6.8 in the manual for todonotes.
%
\renewcommand{\marginpar}{\marginnote}

\begin{document}

\begin{figure}[htbp]\centering
\begin{minipage}{.5\linewidth}
This is a sentence with a footnote.\footnote{It only serves as an example.}
Now a sentence with \todo{The footnote ends up in the margin.}a \texttt{todo}-note follows.
However, the last footnote is printed at the end of the minipage\footnote{Because it is inserted after the \texttt{todo}-note.}.
\end{minipage}
\end{figure}

\end{document}

Выход:

Неправильно размещенная сноска

Как мне исправить это поведение? Nb, я не нуждаюсь или не использую сноски внутри todonote или любой другой заметки на полях. Следовательно, приемлемым решением может быть отключение сносок для заметок на полях, если это возможно.

Расширенный MWE для исправления ошибки в ответе ниже

Theпервоначально предложенный ответ(см. ниже) имеет некоторые ошибки, на которые указывает следующий расширенный MWE: а) Он также рисует разделительную линию, если мини-страница не содержит сносок. б) Сноски полностью теряются, если внутри мини-страницы используется среда списка.

\documentclass[american]{article}

\usepackage[TS1,T1]{fontenc}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}
\usepackage{marginnote}
\usepackage{todonotes}

%
% We need to redefine \marginpar.
% \marginpar does not work inside floats, but \marginnote does.
% Also \todo uses \marginpar internally and this way it actually uses \marginnote.
% See manual for marginnote and sec. 1.6.8 in the manual for todonotes.
%
\renewcommand{\marginpar}{\marginnote}

\newsavebox{\mpfootsave}

\makeatletter

\newcommand{\mytodo}[1]{%
\setbox\mpfootsave=\vbox{\unvbox\@mpfootins}%
\todo[caption={}]{#1}%
\setbox\@mpfootins=\vbox{\unvbox\mpfootsave}%
}

\makeatother

\begin{document}

\begin{figure}[htbp]\centering
\begin{minipage}{.7\linewidth}
This is a sentence with a footnote.\footnote{It only serves as an example.}
Now a sentence with \mytodo{The footnote ends up in the margin.}a \texttt{todo}-note follows.
However, the last footnote is printed at the end of the minipage\footnote{Because it is inserted after the \texttt{todo}-note.}.
\end{minipage}
\end{figure}

\begin{figure}[htbp]\centering
\begin{minipage}{.7\linewidth}
The solution works only partially, if there is no footnote after the last \mytodo{Like this}\texttt{todo}-note.
The seperation line is printed even if there is no footnote at all.
\end{minipage}
\end{figure}

\begin{figure}[htbp]\centering
\begin{minipage}{.7\linewidth}
  \begin{enumerate}
    \item
      Even with an enumeration, the \mytodo{Another todo}solution works.
      But only if the footnote comes last.\footnote{It only serves as an example.}
  \end{enumerate}
\end{minipage}
\end{figure}

\begin{figure}[htbp]\centering
\begin{minipage}{.7\linewidth}
  \begin{enumerate}
    \item
      But the solution\footnote{Actually, the proposed solution.} fails in combination with an enumeration, if a \mytodo{Yet another todo}\texttt{todo}-note appears after the last footnote.
  \end{enumerate}
\end{minipage}
\end{figure}

\end{document}

Результат:

расширенный МВЭ

решение1

Очевидно, \todoиспользует мини-страницу вместо \parbox. То же самое происходит при вложении мини-страниц со сносками.

Это решение сохраняет сноску до \todoи восстанавливает ее после.

Обратите внимание, что \@mpfootinsсохраняется глобально, что позволяет сноскам выходить за рамки групп. Но поскольку \footsaveсохраняется локально, можно использовать этот подход для исправления вложенных мини-страниц в целом.

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[utf8]{inputenc}

\usepackage{marginnote} % Enhanced marginpar
\usepackage{todonotes}

%
% We need to redefine \marginpar.
% \marginpar does not work inside floats, but \marginnote does.
% Also \todo uses \marginpar internally and this way it actually uses \marginnote.
% See manual for marginnote and sec. 1.6.8 in the manual for todonotes.
%
\renewcommand{\marginpar}{\marginnote}

\newsavebox{\footsave}

\makeatletter
\newcommand{\mytodo}[2][]{% same arguments as \todo
  \setbox\footsave=\box\@mpfootins
  \todo[#1]{#2}%
  \global\setbox\@mpfootins=\box\footsave}
\makeatother

\begin{document}

\begin{figure}[htbp]\centering
\begin{minipage}{.7\linewidth}
This is a sentence with a footnote.\footnote{It only serves as an example.}
Now a sentence with \mytodo{The footnote ends up in the margin.}a \texttt{todo}-note follows.
However, the last footnote is printed at the end of the minipage\footnote{Because it is inserted after the \texttt{todo}-note.}.
\end{minipage}
\end{figure}

\begin{figure}[htbp]\centering
\begin{minipage}{.7\linewidth}
The solution works only partially, if there is no footnote after the last \mytodo{Like this}\texttt{todo}-note.
The seperation line is printed even if there is no footnote at all.
\end{minipage}
\end{figure}

\begin{figure}[htbp]\centering
\begin{minipage}{.7\linewidth}
  \begin{enumerate}
    \item
      Even with an enumeration, the \mytodo{Another todo}solution works.
      But only if the footnote comes last.\footnote{It only serves as an example.}
  \end{enumerate}
\end{minipage}
\end{figure}

\begin{figure}[htbp]\centering
\begin{minipage}{.7\linewidth}
  \begin{enumerate}
    \item
      But the solution\footnote{Actually, the proposed solution.} fails in combination with an enumeration, if a \mytodo{Yet another todo}\texttt{todo}-note appears after the last footnote.
  \end{enumerate}
\end{minipage}
\end{figure}

\end{document}

Связанный контент