5

We have now updated our Linux system and therefore upgraded as well to lualatex 1.18.0. Somehow the definition of nobreak seems to have changed - or at least the handle of it. Since we're running Unit-tests I can see there is an additional space introduced when using the nobreak command. MWE

\documentclass[a4paper,11pt,british]{article}
\usepackage[margin=2.5cm]{geometry}
\usepackage[shorthands=off]{babel}
\newcommand{\nbsp}{\nobreak%
    \hspace{.16667em plus .08333em}
}
\usepackage{xltabular}
\usepackage{booktabs} % for rules within a table
\begin{document}
\begin{xltabular}{\textwidth}{ X X}
    \midrule[1pt]
    \bfseries Lorem ipsum test &\nbsp{}\\
    \midrule[1pt]
    {\selectlanguage{naustrian}Ein Vergleich mit der alten Version}
    &\nbsp{}\\
    \midrule[1pt]
    \addlinespace[1pt]\midrule[1pt]
\end{xltabular}
\end{document}

The command nbsp should introduce just a single space which is not allowed to break the content before and after. The given definition worked perfectly in 1.17, running in 1.18 I get an extra line introduced (marked with red). enter image description here

When I comment the nobreak command than the layout seems fine, i.e. no additional line introduced. Honestly I have not enough skills to pinpoint to the source of this problem - either xltabular or LaTeX or... I would guess this is a bug and not a feature ;-)

Anyway is there a way to fix with the current version? Just using \penalty 10000 won't change anything.

7
  • 2
    This is user error, \nobreak is not a latex commandreally it is a holdover from plain tex and if used in vertical mode (as here in some versions) it prevents page breaking not line breaking. use \leavevmode\nolinebreak also note that a final skip in a tabular cell is always removed so you may want to use a guard after the skip. why define \nobsp rather than the standard \nobreakspace or ~ ? Commented Apr 2 at 16:03
  • I'm aware that updating a given example is normally not a very good idea. Honestly I don't know if posting a newer post would clarify the issue more. :-/ The problem persists when now using babel package. The suggested solutions to use nobreakspace won't work neither. For the table itself I agree I could use the other commands - but when using babel than ???
    – LeO
    Commented Apr 2 at 16:37
  • nobreakspace starts \leavevmode so I'd expect it to work Commented Apr 2 at 16:44
  • It works - same as \nobreakspace or ~ - when changing the definition of the macro. But as soon as I change the language a line break is introduced. Which was not there in 1.17
    – LeO
    Commented Apr 2 at 16:49
  • 2
    Updating an example is bad if it invalidates existing answers. If the update you're thinking of wouldn't change the question all that much, then I'd say go for it.
    – Teepeemm
    Commented Apr 2 at 17:27

1 Answer 1

5

\nobreak (which shouldn't be used in latex, it's just carried over from plain tex, has not changed. What has changed is that more often at the start of p columns tex is in vertical mode. In vmode \break prevents page breaking not line breaking so does nothing useful here. You could prefix by \leavevmode so that the penalty always occurs in hmode and prevents line breaks, or (better) use the standard \nobreakspace command rather than defining a substitute.

\documentclass[a4paper,11pt,british]{article}
\usepackage[margin=2.5cm]{geometry}
\usepackage[shorthands=off]{babel}
\newcommand{\nbsp}{\leavevmode\nobreak%
    \hspace{.16667em plus .08333em}%<<<<<<<
}
\usepackage{xltabular}
\usepackage{booktabs} % for rules within a table
\begin{document}
\begin{xltabular}{\textwidth}{ X X}
    \midrule[1pt]
    \bfseries Lorem ipsum test &\nbsp{}\\
    \midrule[1pt]
    {\leavevmode\selectlanguage{naustrian}Ein Vergleich mit der alten Version}
    &\nbsp{}\\
    \midrule[1pt]
    \addlinespace[1pt]\midrule[1pt]
\end{xltabular}
\end{document}

Produces

enter image description here

without the \leavevmode you get

enter image description here

UPDATE Using \leavevmode before \selectlanguage in this example prevents adding an additional line before Ein Vergleich mit der alten Version.

9
  • Thx for summarizing your solution. My only persisting problem is that the empty line before Ein Vergleich mit der alten Version was NOT there in 1.17
    – LeO
    Commented Apr 2 at 18:17
  • @LeO you didn't ask about that space (which has the same solution, put \leavevmode before it) Commented Apr 2 at 18:24
  • Hmmm... first of all thx for your help and providing a solution. For me the title of this topic was clear enough - namely that with the new version the behaviour is changed. Could be a fix for something which was broken before OR could be a newly introduced bug. I don't know and I am unable to determine.
    – LeO
    Commented Apr 2 at 18:37
  • Using the command nobreakspace sounds reasonable. Adding \leavemode sucks - since it adds complexity for my conversion. Anyway - I've read that nobreak is deprecated in LaTeX - fine. Is this bit of information somewhere accessible or is it just because you're knowing the code (quite well)? More or less: Where can I find that kind of info on my own?
    – LeO
    Commented Apr 2 at 18:38
  • 1
    I’m not sure, but I think it’s related to github.com/latex3/babel/issues/284. Commented Apr 2 at 18:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .