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'm using the LaTeX eco package to default to text figures/\oldstylenums throughout my document. However, for some strange reason it seems to be causing TeX to think it's okay to hyphenate within words that are already hyphenated, including in places where a hyphen wouldn't be legal if that word were on its own, like this:

Code for that example:

\documentclass[twocolumn]{memoir}
\usepackage{eco} % default to text figures, use \newstylenums if you don't want them

\begin{document}
Sometimes one might choose to take the beat-you-over-the-head-with-it approach instead of the delicate method. 
\end{document}

If I comment out \usepackage{eco}, it correctly puts the line break after all of 'you'.

Any ideas on why this is happening, or what I could do to stop it (short of getting rid of the package and manually specifying \oldstylenums everywhere I use a number in the document)? I'd obviously prefer an automatic solution, but even a manual one would be helpful. Using \hyphenation doesn't help because the word contains hyphens, so I can't specify that there are no breaks allowed in it by not putting any hyphens in it.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

For mysterious reasons, eco defines the \hyphenchar to be 127 instead of the usual 45, so a character 45 is not recognized as a hyphen as far as the hyphenation mechanism is concerned.

You can fix it by redefining the relevant macros before accessing fonts.

\documentclass[twocolumn]{memoir}
\usepackage{eco} % default to text figures, use \newstylenums if you don't want them
\makeatletter
\@namedef{T1+cmor}{\hyphenchar\font=45 } 
\@namedef{T1+cmoss}{\hyphenchar\font=45 } 
\makeatother

\begin{document}

Sometimes one might choose to take the beat-you-over-the-head-with-it approach instead of the
delicate method.

\end{document}

enter image description here

You might want to look at the cfr-lm package that offers several options, including old style numerals.

share|improve this answer
    
+1 for mentioning the nifty package cfr-lm. –  Mico Aug 30 at 17:01
    
The redefinition solution didn't work for me -- it caused my header and section title formatting to be lost and just printed in the text font. Using cfr-lm worked great, though; I added the tip at latex-community.org/forum/viewtopic.php?f=44&t=23068 to automatically switch over to lining figures in tables. –  Soren Bjornstad Aug 30 at 17:46
    
@SorenBjornstad It might be a followup question; without a minimal example it's difficult to say. –  egreg Aug 30 at 17:47

Load the eco package in your MWE is equivalent to write in the preamble:

\usepackage[T1]{fontenc}
\renewcommand{\rmdefault}{cmor}

Therefore is evident that the problem is the font cmor, that does not use - as a hard hyphen,

Although this "feature" is fixed perfectly as egreg explained, it is worth noting that another solution for finer control of hyphens, without touching this bug (ehh ... feature) nor the guts of TeX, is to use the predefined shorthands of the package babel for the different types of hyphens of your language, or define your own shorthands, so you can use some like "- for a hard hyphen. It is well explained in the babel documentation. Example:

\documentclass[twocolumn]{memoir}
\usepackage[english]{babel}  
\useshorthands*{"}
\defineshorthand{"-}{\babelhyphen*{hard}\,}

\usepackage{eco}

\begin{document}

Sometimes one  might  to take the 
beat-you-over-the-head-with-it 
approach instead of the delicate method.

Sometimes one  might  to take the 
beat"-you-over-the-head-with-it 
approach instead of the delicate method.

Sometimes one  might  to take the 
beat-you"-over-the-head-with-it 
approach instead of the delicate method.

Sometimes one  might  to take the 
beat-you-over"-the-head-with-it 
approach instead of the delicate method.

Sometimes one  might  to take the 
beat-you-over-the"-head-with-it 
approach instead of the delicate method.

\end{document}

MWE

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.