79

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.

7
  • 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, 2013 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, 2013 at 12:56
  • 1
    @egreg yep but then there is more than one school when it comes down to hyphens Jun 30, 2013 at 13:01
  • 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, 2013 at 13:04
  • 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, 2013 at 14:46

1 Answer 1

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
3
  • 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, 2022 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. Jul 30, 2022 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, 2022 at 22:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .