3

I'm revising one of the final drafts of my thesis and on several pages there are words running into the right margin.

My question is whether rewording the paragraph is the only way to get rid of this problem? (I'd like to avoid using the command \sloppy because it screws up spacing between words.)

The related question How can I make my text never go over the right margin by always hyphenating or breaking on word-boundaries? offers using \sloppy or rewording the paragraph as solutions. I'd like to know whether there are alternative solutions.

Update (January 31st 2016). Using the microtype package did the job. Thanks to Henri Menke for suggesting this.

  • 3
    You might want to have a look at the microtype package, which enables margin kerning and Hermann Zapf typography for enhanced line breaking. Using this package the right way considerably lowers the number of hyphenations. – Henri Menke Jan 30 '16 at 14:30
  • 2
    Using longer paragraphs may also help - it gives the line breaking algorithm more chances to find a good set of breaks. – Thruston Jan 30 '16 at 14:37
  • 1
    you can hyphenate the long word by adding \- you don't have to reword the paragraph or you can set \emergencystretch which does not change the spacing in good paragraphs or use microtype – David Carlisle Jan 30 '16 at 14:40
  • 2
    Which language is your document in? Have you loaded babel with the appropriate language option(s) to help LaTeX find additional permissible hyphenation points? Are the words that are running into the right-hand margin not very common and hence maybe not known to TeX's hyphenation algorithm? – Mico Jan 30 '16 at 14:41
  • 3
    it would be easier to gave a specific answer if you showed an example document with (just) a paragraph of text showing the bad linebreaks – David Carlisle Jan 30 '16 at 15:12
4

The German LaTeX Wikibook contains a chapter about hyphenation -- here's the link.

babel Package

First of all make sure that you use the babel package. It loads hyphenation rules for the language you use.

hyphsubst Package

If you write in German maybe the hyphsubst package is a good option.

Manually Help LaTeX with the Hyphenation (Globally)

As stated here or here or here for example you can add specific hyphenation rules in the preamble of your document:

% needs babel package
\hyphenation{cryp-to-graphy lalala-la lolo-lolo-lulu}

Manually Help LaTeX with the Hyphenation (Locally)

I would recommend this as the last step when you finished your document. Then you can manually help LaTeX.

The command \overfullrule=2pt in the preamble will show you where LaTeX has a problem with hyphenation:

\documentclass{article}

\usepackage[ngerman]{babel}

% showframe to show the layout frames... :)
\usepackage[textwidth=50mm,showframe]{geometry}

% Show overfull boxes and lines (TeX primitive)
\overfullrule=2pt

\begin{document}

Lalalalalalala lalalalala lalalalala lalalalala

\end{document}

enter image description here

Here's a list of manual options:

  • \- Hyphenation a word only here and nowhere else (all other hyphenation rules are not valid anymore).
  • "- Hyphenation a word also here (the other hyphenation rules are still valid).
  • "= This produces a dash. Hyphenation is allowed here and the other hyphenation rules are still valid. Normally if a word contains a dash the dash is the only place where a hyphenation can occur.
  • "~ This produces a dash where no hyphenation is allowed.
  • "" Here a hyphenation can occur but no automatic hyphenation dash will be produced by LaTeX.

These commands work if you use ngerman option for babel. I do not know how to make them work if you use other languages. Can somebody help me on this?

\documentclass{article}

\usepackage[ngerman]{babel}

% showframe to show the layout frames... :)
\usepackage[textwidth=50mm,showframe]{geometry}

% Show overfull boxes and lines (TeX primitive)
\overfullrule=2pt

\begin{document}

Lalalalalalala lalalalala lal"-lalala lalalalala

\end{document}

enter image description here

microtype Package

Stolen from the comments (@Henri Menke)!

The microtype package also improves hyphenation. The following cite is taken from the package manual:

Micro-typography is the art of enhancing the appearance and readability of a document while exhibiting a minimum degree of visual obtrusion. It is concerned with what happens between or at the margins of characters, words or lines. Whereas the macro-typographical aspects of a document (i.e., its layout) are clearly visible even to the untrained eye, micro-typographical refinements should ideally not even be recognisable. That is, you may think that a document looks beautiful, but you might not be able to tell exactly why: good micro-typographic practice tries to reduce all potential irritations that might disturb a reader.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.