48

I have a custom block of text on my title page which can be longer than a single line. By default LaTeX is hyphenating a word at the end of a line, but I want it to break on to the next line.

How do I force this to happen?

I know I can use \\ in the text, but I'm creating a standard template for a documents and I would prefer it to handle this edge case automatically instead of having to remember to break the text manually.

E.g.

This is my title longpiece-
oftext

should be

This is my title
longpieceoftext

6 Answers 6

45

See this answer in the TeX FAQ.

Three "easy" ways to prevent hyphenation for a text block (as opposed to the whole document) are:

  • Enclose the text block in a raggedright environment (this typesets the block raggedright and makes hyphenation very unlikely);

  • Enclose the text block in a group and set \hyphenpenalty and \exhyphenpenalty to 10000;

  • EDIT: Load the hyphenat package and write \nohyphens{(text block)}.

Minimal example:

\documentclass{article}

\usepackage[english]{babel}

\usepackage{hyphenat}

\usepackage{blindtext}

\textwidth 300pt

\begin{document}

\blindtext

\begin{raggedright}

\blindtext

\end{raggedright}

\begingroup
\hyphenpenalty 10000
\exhyphenpenalty 10000

\blindtext

\endgroup

\nohyphens{\blindtext}

\end{document}

EDIT 2: The biblatex package provides the additional commands \nohyphenation (which normally should be used inside a group) and \textnohyphenation{(text)}.

2
  • 1
    biblatex's \[text]nohyphenation only work on complete paragraphs; they rely on \lefthyphenmin, and the value of that at the end of the paragraph is used when breaking a paragraph into lines. Apr 15, 2011 at 16:09
  • I would like to point out that none of these solutions work if the wrapfigure is used. The text simply ignores the figure and writes on it.
    – Peaceful
    Oct 13, 2021 at 6:59
19

If the longpieceoftext s are few and easily identified, then

This is my title \mbox{longpieceoftext} with 
some other \mbox{ridiculouslylongtextaddition}

should do what you want. You will, of course, "get what you wish for, so beware": over/underfull boxes...

2
  • 3
    This may cause the text block to stick into the margin.
    – lockstep
    Nov 6, 2010 at 14:01
  • @lockstep: Yes, true. I think OP needs to clarify a bit exactly what he's trying to do. For example, this answer plus \raggedright might fill the bill... Nov 6, 2010 at 17:07
8

You must use:

\usepackage[none]{hyphenat}

Read this link

1
  • This would prevent more than only one text block, wouldn't it?
    – cabohah
    Jan 31 at 12:52
2

You can use the command:

\raggedright

or the environment:

\begin{flushleft}
\end{flushleft}

§ Paragraph alignment

2

Easiest solution:

\usepackage{hyphenat}
\DeclareCaptionTextFormat{new}{\nohyphens{#1}}      
1
  • You can highlight code in your post using back-ticks. For code-blocks indent them by four spaces or use the {} on the gui.
    – user30471
    Apr 12, 2016 at 10:08
0

If you want to prevent names from being hyhenated then in the preamble write \hyphenation{Verylongname anothername namex namey etcetera}.

I think you need the babel package for this.

1
  • But note, this would prevent the given words from being hyphenated everywhere in the document not only in one special text block.
    – cabohah
    Jan 31 at 12:53

You must log in to answer this question.

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