Closed nstanger closed 8 years ago
Relevant things from The TeXbook:
\ifvmode
test for vertical mode.\unskip
is something like \lastbox
, except that it applies to glue instead of to boxes. If the last thing on the current list is a glue item (or leaders, as explained below), it is removed. You can’t remove glue from the current page by using \unskip
in vertical mode, but you can say \vskip-\lastskip
, which has almost the same effect.”\unskip
(such as it is).The \vskip-\lastskip
approach seems to work fine.
Ah, an interesting wrinkle: it only fails if there is a blank line following the verbatim
environment and there is text before the verbatim
. No text or whitespace before the verbatim
doesn’t trigger the problem, regardless of following whitespace. The solution is still the same regardless.
After upgrading to TeX Live 2015, the \vskip-\lastskip
solution has stopped working. The document builds fine, but the marks are no longer pulled back to the previous line if there’s space. The breakage with \unskip
and verbatims still holds.
It looks like \lastskip
is now always zero for some reason. Switching back to \unskip
with a \leavevmode
in front of it seems to work OK, except perhaps for too much vertical space after an itemize
.
Discovered by Mark George. If the very last thing in a question is some sort of verbatim environment (
verbatim
,lstlisting
, etc.) following by a blank line, thenouexam
crashes when attempting to insert the number of marks:I’m guessing the verbatim environment is putting TeX into vertical mode (they do tend to screw around with things quite a lot).
Things to note:
\verb
is fine.Minimal (not) working example:
Remove the blank line after
\end{verbatim}
and it’s fine.