Aparece un misterioso espacio en blanco en el texto cuando se alinea el entorno seguido del entorno de la figura

Aparece un misterioso espacio en blanco en el texto cuando se alinea el entorno seguido del entorno de la figura

Cuando se utiliza un alignentorno y posteriormente un figureentorno en código Latex, en el pdf resultante aparece de repente un espacio en blanco donde en el código reside la figura del entorno.

¿Por qué pasó esto? ¿Como arreglarlo?

MWE:

\documentclass{article}
\usepackage{todonotes}
\usepackage{amsmath}

\begin{document}
\section{My Chapter}
Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test.
\begin{align}
 a = b
\end{align}
\begin{figure}
 \centering
 \missingfigure[figwidth=6cm]{Testing a long text string}
 \caption{Test1.}
\end{figure}
Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test.
\end{document}

Respuesta1

Normalmente el final de la línea después\end{figure} no produce un espacio visible. En realidad, el código llevará un posible espacio en blanco proveniente deantesel entorno, añadiendo un espacio normal si figurese inicia en modo párrafo y antes no había espacio \begin{figure}.

Entonces

Before\begin{figure}
<code>
\end{figure}
Test

producirá un regular

Antes de la prueba

así como

Before
\begin{figure}
<code>
\end{figure}
Test

Sin embargo, estamos al final de un despliegue matemático y esto tiene como consecuencia que terminamos en un caso similar a Before\begin{figure}, que agrega un espacio.

El alignmedio ambiente no es relevante para el tema: el documento

\documentclass{article}
\usepackage{todonotes}    

\begin{document}
\begin{equation}
text
\end{equation}
\begin{figure}
 \centering
 \missingfigure[figwidth=6cm]{Testing a long text string}
 \caption{Test1.}
\end{figure}
Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test Test.
\end{document}

muestra el mismo comportamiento.

En general, mi consejo es escribir siempre figurelos tableentornos rodeados de líneas en blanco, para que el problema no pueda aparecer en primer lugar.

En su caso, me temo que la única forma alternativa es escribir

\end{figure}%

información relacionada