4

Possible Duplicate:
How to disable hyphenation in all section and subsection titles?
No hyphen for a word

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!

3
  • 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
    Commented Aug 21, 2012 at 23:42
  • See the solutions provided in No hyphen for a word. As a quick-fix, I would use \mbox{model}.
    – Werner
    Commented Aug 21, 2012 at 23:52
  • What document class are you using? Commented Aug 21, 2012 at 23:57

1 Answer 1

5

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

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