80

LaTeX tends to break words at the end of the line when that causes better typography. Great. I'd like to have some sort of influence on where the words are broken, though.

For example, LaTeX currently breaks cryptography into cryptog-raphy when it does not fit, while I would much rather break it into crypto-graphy.

I've tried putting an mbox around it (or around both parts of the word) but that just ends up overflowing the hspace.

Is there a way I can put a box around the word but still allow a break at designated points, i.e. after crypto and before graphy? I'm fine with doing this on a per-word basis manually.

Joost
  • 1,285
  • 10
    In the document where you use the word: cryp\-to\-graphy or better as a rule in the preamble \hyphenation{cryp-to-graphy} – cgnieder Jun 30 '13 at 12:53
  • 1
    The Merriam-Webster dictionary says cryp•tog•ra•phy link If you use American spelling, you should follow Webster for hyphenation. – egreg Jun 30 '13 at 12:56
  • 1
    @egreg yep but then there is more than one school when it comes down to hyphens – Frank Mittelbach Jun 30 '13 at 13:01
  • @egreg This was just an example (and I prefer breaking it after to) but I wanted to know the general fix – Joost Jun 30 '13 at 13:02
  • 6
    @Joost Hyphenation is not a "personal choice": it's a convention that should be followed. Americans hyphenate fo•togra•phy, while Britons prefer fo•to•graphy. If you follow British spelling, also do \usepackage[british]{babel} – egreg Jun 30 '13 at 13:04
  • While a convention, it is not as explicitly defined as I would prefer it to be. Thanks, changing to british did fix most cases I was a bit annoyed by. I guess that's the convention I should adhere to for everything. – Joost Jun 30 '13 at 13:11
  • 6
    You've come across a well-known aspect of US-English hyphenation rules: Words that end in "ography" (cryptography, photography, etc) are supposed to be hyphenated between g and r, whereas the associated adjectives (cryptographic, photographic, etc) are supposed to be hyphenated before the gr group. If that's not in conformance with your hyphenation preferences, be sure to load the babel package with the appropriate language option. In your case, the british option may be appropriate. – Mico Jun 30 '13 at 14:46

1 Answers1

115

Various possibilities:

  • use the right kind of hyphenation rules, e.g., in your case it is possibly \usepackage[british]{babel} instead of the default hyphenation patterns
  • use \- inside a word to explicitly denote the allowed places to break, e.g. cryp\-to\-graphy
  • specify hyphen exceptions via \hyphenation{cryp-to-graphy} (normally in the document preamble). If done then the word cryptography used in the document will allow hyphenation at the points indicated by the -. Note that only the exact form of the word is affected, if you use different form, eg plural, you need to specify exceptions for each of them
  • the exceptions need to be specified outside of the document e.g. directly below the package import. If you try to do that with a single word, it will not be showing up in your compiled version any longer. Rookie flies away. – mrk Jul 30 '22 at 14:25
  • @mrk I think you misunderstand what \hyphenation does. It specifies an exception and from that point onwards it is used. This means it can be used anywhere in the document, but of course the best place is in the preamble so that it is always applied. But you can put it into a paragraph around an offending word, because then the word is used as an exception and no longer typeset. But you could say \hyphenation{foo-bar}foobar in the middle of a paragraph and it would work --- not that this is a good idea, exceptions should go best into the preamble. – Frank Mittelbach Jul 30 '22 at 19:26
  • I see, I was not precise enough, my point is only wrapping the word \hyphenation{foo-bar} will not make it show, which happened to me. True that you can specify wherever you want to. I think adding your \hyphenation{foo-bar}foobar example to the answer is a good idea - then all these comments can go for readabilities sake. – mrk Jul 30 '22 at 22:34