2

How do I remove hyphenating from all the \part{}, \chapter{}, \section{}, etc., titles of a document?

  • 1
    It will depend on the specifics of your document, a sample MWE for which you have not posted. Going ragged right will prevent hyphenation and is often done with large point-size title lines. – Steven B. Segletes Apr 15 at 18:00
  • 2
    For example, in article class, there is a definition \newcommand\section{\@startsection {section}{1}{\z@}% {-3.5ex \@plus -1ex \@minus -.2ex}% {2.3ex \@plus.2ex}% {\normalfont\Large\bfseries}}. The term \raggedright can be added after \bfseries to remove full justification and thus hyphenation. But don't go editing your class files directly. Tell us more about your document class and preamble. – Steven B. Segletes Apr 15 at 18:05
  • 1
    @StevenB.Segletes I'm using \documentclass[11pt]{book}. – Geremia Apr 15 at 18:06
1

When disabling hyphenation, be sure to switch from full justification to \raggedright, or \centering in the case of part-level headers

Since you're using the book document class, I suggest you employ the facilities of the sectsty package:

\usepackage{sectsty}
\partfont{\centering}
\chapterfont{\raggedright}
\allsectionsfont{\raggedright}
2

Hyphenation only occurs with full justification (unless the ragged2e package is employed, hat tip Mico). For large point-size titles, it is frequently disabled by invoking \raggedright. That can be made standard for your document by redefining that particular sectioning command.

For example, you can go to the book documentclass, copy the definitions of the sectioning that requires modification, and use \makeatletter...\makeatother redefinitions to add \raggedright.

I demonstrate it here, mid-document, but you should do it in the preamble.

These sort of changes can also be done with the titlesec package, but I will let someone else post that.

\documentclass{book}
\begin{document}
\section{This is a long title that requires extraordinary hyphenation}

\makeatletter
\renewcommand\section{\@startsection {section}{1}{\z@}%
                                   {-3.5ex \@plus -1ex \@minus -.2ex}%
                                   {2.3ex \@plus.2ex}%
                                   {\normalfont\Large\bfseries\raggedright}}
\makeatother
\section{This is a long title that requires extraordinary hyphenation}

\end{document}

enter image description here

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.