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 know this is a common question.

I want to stop LaTeX splitting the word "Byte".

I already searched for the problem and found the solution with \hyphenation.

I thought \hyphenation{Byte} would solve my problem. But unfortunately it doesn't work. I think it has something to do that he probably just uses this for "byte" and not for words that contain it (German example: "Bytestrom", LaTeX splits it By-testrom).

The second solution which I found was using \mbox with \newcommand. I don't like this solution very much.

So my questions are:

  • Why does \hyphenation{byte} not work?
  • Is there another way to solve my problem?

Example added by Jake:

\documentclass[a5paper]{article}
\usepackage[german]{babel}
\begin{document}
Trying to determine how a special word is hyphenated: Bytestrom.
\end{document}

share|improve this question
    
Welcome to TeX SE. You can highlight code by using the backtick character. Enjoy your stay here! :) –  zeroth Sep 27 '12 at 13:51
    
LaTeX should not split a word that is 4 letters long. There must be something else wrong. Please, provide a Minimal Working Example. –  tohecz Sep 27 '12 at 13:54
    
(Sorry, I misread the question) –  tohecz Sep 27 '12 at 13:57
    
I think you gave the answer to your first question already yourself: the \hyphenation command does not expand its arguments to longer words that contain a word defined in \hyphenation. Unfortunately I don't have any answer to your second question. –  Benedikt Bauer Sep 27 '12 at 13:58
    
To answer your first question: the command \hyphenation applies to complete words only. It is designed for English, which does not have compound words in the abundance found in German. –  Andrew Swann Sep 27 '12 at 14:00

4 Answers 4

Quoting the TeXbook, p. 452:

\hyphenation{man-u-script man-u-scripts ap-pen-dix}

[...] tells TeX how to hypenate the words 'manuscript' , 'manuscripts', and 'appendix'. Notice that both singular and plural forms of 'manuscript' were entered, since the exception dictionary affects hyphenation only when a word agrees completely with an exceptional entry.

In other words, the answer to your question is to enter both Byte and Byte-strom into the exception list.

\documentclass[a5paper]{article}
\usepackage[german]{babel}
\hyphenation{Byte Byte-strom}
\begin{document}
Trying to determine how a special word is hyphenated: Bytestrom.
\end{document}

enter image description here

share|improve this answer
    
Hi thank you for your reply. As Benedikt Bauer said, this would mean, that i have to go through the text and find every word that contains this (and also repeat this for similar problems). I thought there is maybe an easier solution. –  JustCoding Sep 27 '12 at 14:22
2  
With any capable text editor, searching for "byte" shouldn't be too onerous. –  lockstep Sep 27 '12 at 14:26

There is a way to solve the problem, but it is not for the faint hearted. \hyphenation is designed for minor corrections to the global rules, for specific words. You however want to change the global rules, and for that you need \patterns not \hyphenation.

\patterns may only be used at initex time when making a format and reads a patterns list that looks something like

% dehyphn-x-2012-05-30.pat

\message{German Hyphenation Patterns (Reformed Orthography, 2006) `dehyphn-x' 2012-05-30 (WL)}

% TeX-Trennmuster für die reformierte (2006) deutsche Rechtschreibung
%
%
% Copyright (C) 2007, 2008, 2009, 2011, 2012 Werner Lemberg <wl@gnu.org>
%
% This program can be redistributed and/or modified under the terms
% of the LaTeX Project Public License Distributed from CTAN
% archives in directory macros/latex/base/lppl.txt; either
% version 1 of the License, or any later version.
%
%
% The word list is available from
%
%   http://repo.or.cz/w/wortliste.git?a=commit;h=7915938d035684993f8c363729f963eec71c85b1
%
% The used patgen parameters are
%
%   1 1 | 2 5 | 1 1 1
%   2 2 | 2 5 | 1 2 1
%   3 3 | 2 6 | 1 1 1
%   4 4 | 2 6 | 1 4 1
%   5 5 | 2 7 | 1 1 1
%   6 6 | 2 7 | 1 6 1
%   7 7 | 2 13 | 1 4 1
%   8 8 | 2 13 | 1 8 1

\patterns{%
.ab1a
.abi4
.ab3l
.abo2
.ab3ol
.ab1or
.ack2
.ag4n
.ag4r
...

As you may guess these things are normally constructed mechanically (traditionally using the patgen program)

The TeXBook says

...since patterns are supposed to be prepared by experts who are paid well for their expertise....

However you want to change the hyphenation of words beginning with byte so if you change the name of the file as required by LPPL You can probably add a pattern of the form

.b4y4t4e

where . denotes the beginning of the word and the numbers between letters encourage (odd) or discourage (even) hyphenation.

Note I haven't tested this and I haven't actually used the \pattern command this millennium. But something like this would probably work.

share|improve this answer
\hyphenation{Byte-strom}


works as expected. \hyphenation{Byte} refers only to the single word Byte, You can try a setting like

\AtBeginDocument{\lefthyphenmin=3}

in the preamble.

share|improve this answer
    
But his Problem is that @JustCoding is using a whole bunch of words that are combined from the word "byte" and some additional words (a quite common thing in german). Therefore it would be necessary to add a hyphenation pattern for every combination. It would of course be much nicer if one could just say something like "never hyphenate any word containing 'byte' between 'y' and 't'". Of course this could have some unwanted side effects. –  Benedikt Bauer Sep 27 '12 at 14:06
2  
@BenediktBauer The word "Derbytermin" should be hyphenated between "y" and "t". :-) –  lockstep Sep 27 '12 at 14:10
    
This is exactly what I meant with "unwanted side effects", I just couldn't find an example while writing my comment ;-) –  Benedikt Bauer Sep 27 '12 at 14:11
    
a simple solution in this special case is: \AtBeginDocument{\lefthyphenmin=3} in the preamble and Byte maybe not hyphenated. However, Byte is an english word and a hyphenation in german between t and e is possible! –  Herbert Sep 27 '12 at 14:15
1  
\AtBeginDocument{\lefthyphenmin=3} is a bad idea for German texts IMO because it will prevent hyphenation after common prefixes like "Ab" and "Zu". –  lockstep Sep 27 '12 at 14:23

Some comments.

  • The correct left and right hyphen minimum values for German are 2. Setting \lefthyphenmin to 3, however, is a very good idea, except for typesetting in very small columns. While some prefixes like »ab« and »zu« are indeed skipped then, it improves the global layout usually.

  • If you use the experimental German hyphenation patterns for the post-1996 hyphenation rules, »Bytestrom« gets correctly hyphenated as »Byte-strom«:

    \RequirePackage[ngerman=ngerman-x-latest]{hyphsubst}
    \documentclass{article}
    \usepackage[T1]{fontenc}
    \usepackage[ngerman]{babel}
    
    \begin{document}
    \showhyphens{Bytestrom}
    \end{document}
    

    You can find more details in the documentation of the dehyph-exptl package.

  • The experimental patterns for the pre-1996 rules don't hyphenate »Bytestrom« at all, which is incorrect but better than the original patterns. Reason is that this very word is missing in the word list.

  • The »wortliste« project comes with Makefiles which simplifies the creation of new German hyphenation patterns. I invite everyone to participate and improve them!

share|improve this answer

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.