
Dentro de una minipágina utilizo notas a pie de página que deben imprimirse al final de la minipágina. También uso marginnote
y redefino \marginpar
to be \marginnote
, porque los uso dentro de otros flotadores (principalmente, flotadores de figuras). Además, suelo todonotes
imprimir, bueno, todos en el margen.
Si uso todo junto, una nota todo en una minipágina "traga" todas las notas al pie que ya se han escrito pero que aún no se han impreso e imprime las notas al pie en su propia parte inferior, es decir, en la parte inferior de la nota todo.
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}
La salida:
¿Cómo corrijo este comportamiento? Nb, no necesito o uso notas a pie de página dentro de una nota todo o cualquier otra nota al margen. Por lo tanto, una solución viable podría ser desactivar las notas al pie de las notas al margen, si esto es posible.
MWE extendido para corregir errores en la respuesta a continuación
Elrespuesta propuesta originalmente(ver más abajo) tiene algunos errores como lo señala el siguiente MWE extendido: a) También dibuja una línea de separación, si la minipágina no contiene ninguna nota al pie. b) Las notas a pie de página se pierden por completo, si se utiliza un entorno de lista dentro de la minipágina.
\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}
Resultado:
Respuesta1
Evidentemente \todo
utiliza una minipágina en lugar de un archivo \parbox
. Lo mismo ocurre al anidar minipáginas con notas a pie de página.
Esta solución guarda la nota al pie antes \todo
y la restaura después.
Tenga en cuenta que \@mpfootins
se guarda globalmente, lo que permite que las notas a pie de página salgan de los grupos. Pero como \footsave
se guarda localmente, se podría utilizar este enfoque para arreglar minipáginas anidadas en general.
\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}