Created
June 20, 2017 14:52
-
-
Save jfbu/2f3d04414359f716f98ea64dac91eb0e to your computer and use it in GitHub Desktop.
illustration of a peculiarity of TeX paragraph building
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass{article} | |
\usepackage{mwe} | |
\begin{document} | |
% or anything filling the line with less than inter-word space shrinkability | |
\noindent\rule{\linewidth}{1pt} % <-- we deliberately leave a space token here | |
\begin{figure}[htbp] | |
\centering | |
% only by way of example, close to real life examples | |
\includegraphics[height=1cm]{example-image-a} | |
\caption{Hello, is there extra space above figure env?} | |
\end{figure} | |
\noindent\rule{\linewidth}{1pt} | |
\begin{figure}[htbp] | |
\centering | |
\includegraphics[height=1cm]{example-image-a} | |
\caption{This one doesn't have any...} | |
\end{figure} | |
\end{document} |
\hskip@savsk % ADDED
\ifdim\lastskip=\z@
for example can't be right as written as the test will never be true (that's probably fixable but this is a very delicate area, and early on in 2e we tried several variants all broke something)
@davidcarlisle Yes of course, the \ifdim
will never be true, I just dropped the extra line in for checking it worked in my use case, I should I have put it after but didn't like the \nobreak, and didn't think twice
about figure at end of paragraph, the \ignorespaces it still there. It does make the issue go away in my testing. the ignorespaces is not relevant here. It works without it. (see next comment)
for example with
AAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA AAAAAAAA IIII.
\begin{figure}[htbp]
\centering
x
\caption{Hello, is there extra space above figure env?}
\end{figure} {} {}
and the modified sphack, there is no issue.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
well true but anyway adding an extra unskip would break the intention of bsphack, that's what I meant. bspack/espack is supposed to leave a space if there is a space before or a space after, it would probably have been better if it removed the space from the start and re-inserted at the end but a bit scary to change that now it's been the way it is since the dawn of time, and in your case with a figure at the end of a paragraph it wouldn't help as you'd still end up with two spaces (perhaps, depending on details of unwritten code)