Skip to content

Instantly share code, notes, and snippets.

@jfbu
Last active June 21, 2017 08:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jfbu/87e5bcfcc64c4199a942be1d5d51c608 to your computer and use it in GitHub Desktop.
Save jfbu/87e5bcfcc64c4199a942be1d5d51c608 to your computer and use it in GitHub Desktop.
\documentclass{article}
\newenvironment{foo}{}{}
\begin{document}
\begin{foo}
\noindent\begin{minipage}{\linewidth}
bar!
\end{minipage}
\end{foo}
There is blank line above me.
\end{document}
@davidcarlisle
Copy link

yes that's got a full width box then two spaces, \par just removes one space so you have one space that goes to the next line, but that doesn't seem connected to the stackexchange question which ends in vertical mode (due to \endtrivlist) so spaces are not an issue.

@jfbu
Copy link
Author

jfbu commented Jun 20, 2017

@davidcarlisle, actually I must admit I did not really look at the stackexchange question at all. ... hope you will be indulgent.

I am surprised by this way TeX handles the two space tokens. If I may allow myself to privatize you just a minute, how do you explain then the situation with \dimexpr\linewidth -1sp ? What is mechanism which gets rid of remaning space token? Isn't TeX's behaviour causing a blank extra line for 1sp difference a bit unsatisfactory?

@davidcarlisle
Copy link

I don't seem to get pings from this gist thing as I would from a normal github issue comment, not sure if that's just how gist is or whther my setup is wrong. anyway \par (or blank line, etc) issues one \unskip` before adding \parfillskip so in a normal situation a space from end of line at end of a paragraph will be removed, but it really is that simple, two spaces or two \hskip etc it will remove just the last. It doesn't do anything special about space characters it just does \unskip\hskip\parfillskip.

so then the fact that you get different numbers of lines if you change some space by 1sp is just the way it is, it applies to all line breaking, if you are on some cusp where line breaking makes a very full line that can not be shrunk any more, adding 1sp cause the entire paragraph linebreaking decisions to change and may end up in more or less lines.

@jfbu
Copy link
Author

jfbu commented Jun 21, 2017

@davidcarlisle, thanks. Indeed pinging does not work and I don't get pings from your comments here either.

I see now clearer: with the -1sp, the first space remains at end of line (creating an overfull hbox), which is not as bad as moving it to next line, as it would then create a way underfull last line. (an empty one actually as the space is removed, being at its start)

With the full width, there is a way underfull (empty) last line. As the \unskip removed only one space, the first one makes TeX start a new line even though it will be discarded next.

Well this is very surprising nevertheless, because one could have thought that it was perfectly legitimate too to leave a trailing space at end of full last line, making it slightly overfull. This does look to me as a deficiency of TeX's handling of spaces at end of a paragraph, but I have not digged into tex.web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment