3

When working with LaTeXe commands integrated in German sentences many times a hyphen will be used. The problem is that this hyphen should always be a break point. LuaLaTeX unfortunately does not do that by default. To show what I mean:

hyphenation not working

as the LuaLaTeX output vs. the (correct) pdfLaTeX output:

pdflatex is right

That example would work the way I want it if you change the - after \LaTeXe or \href{}{} to e.g. a \- (then it breaks correctly).

Question: How to automatically (in the best case I do not want to change the input) convert a hyphen after a command into a hyphen which breaks, but stays if there's no break in LuaLaTeX?

\documentclass{scrreprt}
\usepackage{showframe}
\usepackage[english,main=ngerman]{babel}
\usepackage{hyperref}

\begin{document}
test test test test test test test test test test test test test test test test test \LaTeXe-Dokument test test test test test test test test test test test test test test test test test test te \href{https://en.wikipedia.org/}{\mbox{Wiki}}-Seite test test test test test test test test test test test test test test test test Test-Dokument
\end{document}
  • Actually, the fact that you use LuaLaTeX is crucial here -- the output would look different if pdfLaTeX were used. – Mico Oct 29 '17 at 17:26
  • Hmm, maybe a weird thing. This is not happening neither wIth latex, nor with pdflatex, nor with xelatex. It's only happening with lualatex. – nickie Oct 29 '17 at 17:27
  • @Mico I've added the tag. Do you know why it behaves this way? – TeXnician Oct 29 '17 at 17:30
  • To get a hard hyphen, i.e., one that will shown up both in the interior of a line and at the end, use the babel shorthand "=, not "-. – Mico Oct 29 '17 at 17:31
  • @TeXnician - I'm afraid I have no insights into why the behavior under LuaLaTeX is so different from that under pdfLaTeX. – Mico Oct 29 '17 at 17:32
3

You can try changing \hyphenationbounds, 1 seems a good value in this case.

\documentclass{scrreprt}
\usepackage{showframe}
\usepackage[english,main=ngerman]{babel}
\usepackage{hyperref}
\hyphenationbounds=1
\begin{document}
test test test test test test test test test test test test test test test test test \LaTeXe-Dokument test test test test test test test test test test test test test test test test test test te \href{https://en.wikipedia.org/}{\mbox{Wiki}}-Seite test test test test test test test test test test test test test test test test Test-Dokument
\end{document}
  • What does this mean? The luatex docs say "strict start", but what effect would a change have on e.g. a normal book that has only some of those constructions? – TeXnician Oct 29 '17 at 18:02
  • @TeXnician my answer is intentionally vague, I don't think anyone has really experimented to see the best settings of this parameter which controls whether luatex sees tex constructs as preventing hyphenation in the following or preceding text. The \hbox in \LaTeX counts= as hlist in that description in the luatex manual. – David Carlisle Oct 29 '17 at 18:08
  • Should this be reported somewhere else then? Or is LuaLaTeX just the wrong choice when it comes to such hyphenation problems? – TeXnician Oct 29 '17 at 18:11
  • 1
    @TeXnician there's nothing to report really, classic tex has a fixed heuristic for when it tries to hyphenate a string of letters and when it will skip to try the next word, luatex parametrises that in various ways which means that tweaking the parameters to get the best effect is expected. But \LaTeX is a very special case, presumably most documents do not have such a construct mid-sentence. – David Carlisle Oct 29 '17 at 18:13
  • As I said, it happens also with \href and \gls constructions which I suspect some documents to use mid-sentence. But for now this seems to get rid off the main problem. – TeXnician Oct 29 '17 at 18:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.