Take the 2-minute tour ×
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 noticed that if I've got something like this:

one::two::three::four one::two::three::four one::two::three::four

something weird happen:

%                      the right page margin would be here |
%                                                          |
%                                                          v
one::two::three::four one::two::three::four one::two::three::four

the page margin is where I marked, but the line doesn't get broken, ::four goes out of the page, although it is aligned so that the first colon is exactly after the margin, like if it had to be splitted.

Why doesn't the line gets broken between one::two::three and ::four?
And then why does it get aligned that way, so that ::four goes out of the page?

share|improve this question
add comment

3 Answers 3

up vote 5 down vote accepted

It doesn't get broken there because TeX breaks lines only at white space, hyphenation points, or at explicitly inserted invocations of \discretionary. You could put \discretionary{}{}{} before each double colon if you wish to allow a line break there. If you need this a lot, make a shorter macro for it.

share|improve this answer
    
Yeah, need it quite a lot, will create a command for it, thanks! Anyway why does LaTeX put ::four after the right page margin, rather than putting the whole word (one::two::three::four) on a new line? That looked quite weird to me. –  peoro Jan 15 '11 at 13:23
    
@peoro: I'm pretty sure it's coincidence. –  Hendrik Vogt Jan 15 '11 at 13:27
    
@peoro: I guess that you typeset your text justified and that TeX couldn't find an acceptable solution for line-breaking (putting the whole third "word" on a new line would have created too much whitespace in the first line). –  lockstep Jan 15 '11 at 13:35
    
Uh, yeah, it looks like you guys are right. I am such a newbie with LaTeX, although I'm using it quite a lot... –  peoro Jan 15 '11 at 15:17
add comment

You could define

\def\::{\discretionary{:}{:}{::}}

Now just write \:: and :: would be splitted into : and : at the end of a line. You could easily change it to behave differently, such as

\def\::{\discretionary{::}{}{::}}

That's a benefit of a LaTeX macro: once you defined and used it, you might easily change it consistently.

A minimal example, as requested in a comment:

\documentclass{article}
\def\::{\discretionary{::}{}{::}}
\begin{document}
one\::two\::three\::one\::one\::two\::three\::one\::two\::three\::
four::one\::two\::three\::four\::one\::two\::three\::four 
\end{document}
share|improve this answer
    
Thanks, I'm using your second directive, the result is exactly what I wanted. –  peoro Jan 15 '11 at 15:18
    
@Stefan Thanks a lot! –  Yiannis Lazarides Jan 15 '11 at 19:04
1  
@peoro Could you mark this as the "selected" answer then? :) –  mpr Oct 30 '11 at 4:28
    
It should be remarked that this overrides the definition of \:, which might be used for spacing in math formulas. –  egreg Jan 14 '12 at 21:18
add comment

Just to add to Harald's answer. TeX will hyphenate at a space or at a letter in a word that is an acceptable hyphenation point as per the patterns provided for the language.

There are no patterns that would allow a colon in a word, as no such words exist in English! For example the following non-sense word will hyphenate. Remember also that the very first word is never hyphenated.

\documentclass{article}
\begin{document}
The very first word is not hyphenated at all fortymenpageturnthreeonefouronetwothreefour
\end{document}
share|improve this answer
    
Yeah, that is what I meant by “hyphenation point”. Sorry, I tend to be overly terse sometimes. –  Harald Hanche-Olsen Jan 15 '11 at 16:21
add comment

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.