How do I remove hyphenating from all the \part{}
, \chapter{}
, \section{}
, etc., titles of a document?
2 Answers
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}
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}
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.\documentclass[11pt]{book}
.