# Don't split words in section title [duplicate]

How to I tell LaTeX not to split words in section title? For example:

\section{Protokol CAN in ISO/OSI referenčni model}


... gets printed as "Protokol CAN in ISO/OSI referenčni mo-del". How do I tell him to put last word in new line? Thanks!

-

## migrated from stackoverflow.comAug 21 '12 at 23:36

This question came from our site for professional and enthusiast programmers.

## marked as duplicate by Werner, percusse, yo', lockstep, ThorstenAug 22 '12 at 6:40

Welcome to TeX.sx! Your question was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question. – Werner Aug 21 '12 at 23:42
See the solutions provided in No hyphen for a word. As a quick-fix, I would use \mbox{model}. – Werner Aug 21 '12 at 23:52
What document class are you using? – Gonzalo Medina Aug 21 '12 at 23:57

Making the words un-breakable may lead to underfull or overfull boxes. I would say that the best solution is to make the section headers \raggedright, which ensures that they break only at spaces and no bad boxes are introduced. As well, it looks better than the hyphenates section titles IMO.

Recommanded solution with titlesec package. Put this code into your preamble:

\usepackage[raggedright]{titlesec}


Solution with no package. This redefines the inner section commands to use \raggedright. Put this code into your preamble:

\makeatletter
\def\section{\@startsection{section}{1}{\z@}{-3.5ex \@plus -1ex \@minus -.2ex}{2.3ex \@plus .2ex}
{\normalfont\raggedright\Large\bfseries}}
\def\subseciton{\@startsection{subsection}{2}{\z@}{-3.25ex\@plus -1ex \@minus -.2ex}{1.5ex \@plus .2ex}
{\normalfont\raggedright\large\bfseries}}
\def\subsubsection{\@startsection{subsubsection}{3}{\z@}{-3.25ex\@plus -1ex \@minus -.2ex}{1.5ex \@plus .2ex}
{\normalfont\raggedright\normalsize\bfseries}}
\makeatother

-