1

When creating a custom glossary (nomenclature) with a longtable, the system only uses automatic word braking for cells with more than one word. The column is a p{...}-column and it works flawlessly in cells with more than one word. When I do manual word hyphenation via \- the correct line break is being created. For cells with more than one word the hyphenation is placed automatically.

Update: As suggested here compiling with LuaLaTeX solves the problem although I'm not happy with it. I also don't understand why the solution given by @DavidCarlisle didn't work.

Update 2: Problem is solved. The word being the first word in the paragraph was indeed the problem. Because I was defining a glossary style I had to add \hspace*{0pt}to the template of the column instead of the column definition. In my case this means that

\renewcommand*{\glossentry}[2]{%  Change the displayed items
    \boldmath\ensuremath{\glossentrysymbol{##1}}
    & \glstarget{##1}{\hspace*{0pt}\glossentryname{##1}} %
    & \glossentrydesc{##1}
    & \glsentryunit{##1}\tabularnewline
 }%

works, while

\setglossarystyle{long4col}% base this style on the list style
 \renewcommand{\glsgroupskip}{}%avoids grouping the elements by alphabetical order
 \renewenvironment{theglossary}{% Change the table type --> 4 columns
  \renewcommand*{\arraystretch}{1.5}
  \begin{longtable*}{>{\centering}p{.1\textwidth} >{\arraybackslash\hspace*{0pt}}p{.225\textwidth} p{.475\textwidth}>{\centering\arraybackslash}p{.1\textwidth}}}%
  {\end{longtable*}}%

did not work.

  • 1
    tex never hyphenates the first word of a paragraph: load array package then use >{\hspace{0pt}}p{..} so there is a zero width space before the word – David Carlisle Apr 12 '21 at 08:05
  • @DavidCarlisle I have just tried your suggestion. Unfortunately it does not work as it should. – Pauluuus Apr 12 '21 at 08:17
  • @Pauluuus - A quick follow-up on David Carlisle's comment. Formally, each cell in a tabular structure consists of one or more paragraphs; even a cell with a single word constitutes a paragraph. pdfTeX and XeTeX never hyphenate the first "object" (usually a word) in a paragraph. (Hence the advice to insert \hspace{0pt}, to ensure that the first word in the cell isn't the first object.) If you're free to use Lua(La)TeX, a nice side benefit of making the switch is that even the first word of a paragraph can get hyphenated withouth having to go through various contortions. – Mico Apr 12 '21 at 08:17
  • @Pauluuus - Please edit your posting to provide more detail on what exactly you're doing. – Mico Apr 12 '21 at 08:18
  • @Mico thank you for the answer. I had just found one of your previous comments on another question and updated my question. – Pauluuus Apr 12 '21 at 08:27
  • 1
    @Pauluuus - What about LuaLaTeX aren't you happy with? (LuaLaTeX is, with few exceptions, pretty much a superset of pdfLaTeX. If a document compiles without errors under pdfLaTeX, it should compile -- subject, possibly, to some minor adjustments -- under LuaLaTeX as well.) Regarding David Carlisle's suggestion to change p{...} to >{\hspace{0pt}}p{...} -- what exactly isn't working? Are you receiving error and/or warning messages? If so, what do they say? Incidentally, did you make sure to load the array package? – Mico Apr 12 '21 at 08:37
  • @Mico I do not have a problem with LuaLaTeX. I just don't like not understanding a problem and just avoiding it. – Pauluuus Apr 14 '21 at 07:51
  • @Pauluuus - I would not say that LuaTeX "just avoids" the problem. Rather, I'd say that the setting of TeX (subsequently preserved in pdfTeX and XeTeX) of never hyphenating the very first word of a paragraph was a bug that, once discovered, was declared to be a feature. A rather ugly feature, if you ask me, one which requires a kludgy workaround. LuaTeX finally made the (in my view) courageous choice to no longer support this "feature". – Mico Apr 14 '21 at 10:08

0 Answers0