Tell me more ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I just had a problem with a linebreak after a word ending with a hyphen which was followed by a comma.

This example shows the problem:
(The example is constructed, but this just occurred to me in a real text!)

    \documentclass[11pt, a4paper]{scrartcl}

\usepackage[ngerman]{babel}

\begin{document}

aaDas ist ein Absatz. Das ist ein Absatz. Das ist ein Absatz. Es gibt zeit-, temperatur-,  und weggesteuerte Verfahren ein Absatz. Das ist ein Absatz.Das ist ein Absatz. Das ist ein Absatz.Das ist ein Absatz. Das ist ein Absatz.Das ist ein Absatz. Das ist ein Absatz.Das ist ein Absatz. Das ist ein Absatz.

    \end{document}

example image

As I can not imagine any scenario where a comma at the beginning of a line could make sense, I wonder how I could tell LaTeX to absolutely avoid that.

share|improve this question
2  
The problem, I suspect, is not so much with the comma as with the hyphen. There should be some way of producing a hyphen without TeX interpreting it as a valid place to break a word across a line. – Niel de Beaudrap Sep 29 '11 at 9:58
@NieldeBeaudrap: you're absolutely right. I just put it this way, as IMHO a comma should be never typeset at the beginning of a line, at least I could not imagine a case that makes sense at the moment. – Martin Sep 29 '11 at 10:26
If you use LuaTeX, we could provide you a solution that forbids a line break before a comma. – dıʞsdoʇ Sep 29 '11 at 10:27
3  
Notice that this is incorrect punctuation. In German, there is no comma before “und” in enumerations. (Unless they changed that with the Rechtschreibreform but I doubt that.) – Konrad Rudolph Sep 29 '11 at 15:52
1  
@KonradRudolph While it's true that the comma is incorrect before "und", this is unrelated to OP's LaTeX problem. – Jan Sep 29 '11 at 16:56
show 3 more comments

3 Answers

up vote 18 down vote accepted

You should use "~ for that. See the documentation for babel (texdoc babel).

aaDas ist ein Absatz. Das ist ein Absatz. Das ist ein Absatz. Es gibt zeit"~, temperatur"~, und weggesteuerte Verfahren ein Absatz.
Das ist ein Absatz.Das ist ein Absatz. Das ist ein Absatz.Das ist ein Absatz. Das ist ein Absatz.Das ist ein Absatz. Das ist ein
Absatz.Das ist ein Absatz. Das ist ein Absatz.
share|improve this answer

Use my macro \nobreakseq

\def \nobreakseq {\nobreak \hskip 0pt \hbox}

Es gibt zeit\nobreakseq{-,} temperatur\nobreakseq{-,}  und weggesteuerte Verfahren ein Absatz.

It is better than \hbox{temperatur-,} or \mbox{temperatur-,} beacuse of \hbox{temperatur-,} does not allow any hyphenation.

share|improve this answer
2  
I would have thought that avoiding hyphenation in temperatur would be a good thing in this case... – Seamus Sep 29 '11 at 9:34
@Seamus: indeed, two hyphens in a word is to be avoided I think. – ℝaphink Sep 29 '11 at 10:06

Enclosing the offending word in an \mbox works:

\mbox{temperatur-,}

I assume there is a neater way if there are lots of these hyphens where you don't want to allow breaks...

share|improve this answer
1  
thanks - as you're writing, this is a one-time-workaround. However as I consider this (=comma at beginning of line) a total no-go, it should be just "forbidden" globally, IMHO. – Martin Sep 29 '11 at 9:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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