Fußnoten innerhalb einer Miniseite vor einer To-do-Notiz mit Randnotiz landen am Ende der To-do-Notiz

Fußnoten innerhalb einer Miniseite vor einer To-do-Notiz mit Randnotiz landen am Ende der To-do-Notiz

Innerhalb einer Miniseite verwende ich Fußnoten, die am Ende der Miniseite gedruckt werden sollen. Ich verwende marginnoteund definiere auch neu \marginparin \marginnote, weil ich sie innerhalb anderer Floats (hauptsächlich Abbildungs-Floats) verwende. Außerdem verwende ich, um, todonotesnun ja, Aufgaben am Rand zu drucken.

Wenn ich alles zusammen verwende, „schluckt“ eine Todonote in einer Minipage alle bereits getippten, aber noch nicht gedruckten Fußnoten und druckt die Fußnoten an ihrem eigenen Ende, also am unteren Ende der Todonote.

MWE

\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}

Die Ausgabe:

Falsch platzierte Fußnote

Wie korrigiere ich dieses Verhalten? Nb, ich brauche oder verwende keine Fußnoten in einer Todo-Notiz oder einer anderen Randnotiz. Eine praktikable Lösung könnte daher darin bestehen, Fußnoten für Randnotizen zu deaktivieren, sofern dies möglich ist.

Erweitertes MWE zur Fehlerbehebung der folgenden Antwort

Derursprünglich vorgeschlagene Antwort(siehe unten) weist einige Fehler auf, wie das folgende erweiterte MWE aufzeigt: a) Es wird auch dann eine Trennlinie gezeichnet, wenn die Minipage keine Fußnote enthält. b) Die Fußnoten gehen vollständig verloren, wenn innerhalb der Minipage eine Listenumgebung verwendet wird.

\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}

Ergebnis:

erweitertes MWE

Antwort1

Offensichtlich \todowird eine Miniseite anstelle einer verwendet \parbox. Dasselbe passiert beim Verschachteln von Miniseiten mit Fußnoten.

Diese Lösung speichert die Fußnote vorher \todound stellt sie nachher wieder her.

Beachten Sie, dass \@mpfootinsglobal gespeichert wird, sodass Fußnoten aus Gruppen herauskommen können. Da es aber \footsavelokal gespeichert wird, kann man diesen Ansatz verwenden, um verschachtelte Miniseiten allgemein zu reparieren.

\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}

verwandte Informationen