# Bad hyphenation in Section Title

Okay, so my issue is that my Section title is wider than my Text due to a wrong hyphenation/linebreak, which does not look good. When I just add a linebreak it will show in my fancyheader with a linebreak as well. Which I Don't want. I would like the Section Title to be just as wide as the text and if that's not possible to do a linebreak at the appropriate position. Here's what it looks like now:

With linebreak:

This is a part of my settings for the document. I deleted everything where I was sure it had nothing to do with it. Any help to fix it is highly appreciated. I am quite new to LaTeX so I apologize in case it is very obvious on how to solve my issue.

\documentclass[12pt,a4paper,square]{report}
\usepackage[section]{placeins} %picture alsways in one section

\usepackage{titlesec}
\titleformat{\section}
{\normalfont\fontfamily{phv}\fontsize{16}{19}\bfseries}{\thesection}{1em}{}
\titleformat{\subsection}
{\normalfont\fontfamily{phv}\fontsize{14}{17}\selectfont}{\thesubsection}{1em}{}
\titleformat{\subsubsection}
{\normalfont\fontfamily{phv}\fontsize{14}{17}\selectfont}{\thesubsubsection}{1em}{}

\usepackage{caption}

\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\sectionmark}[1]{\markright{\thesection~#1}{}}
%\MakeUppercase{\thesection\ #1}
\fancyfoot{}
\fancyfoot[OR,EL]{\textbf \Large \thepage}

• you can use \section[form for header with no break](display form\\ with linebreak} – David Carlisle Apr 23 at 15:38
• Yes, that worked. Thanks so much for your help :) – Nils Apr 24 at 8:01
• This doesn't make sense. The amount of the word "Switching" that fits within the text width is so small that the previous portion of the heading should have been able to stretch. So \section has been redefined somewhere to have unstretchable spaces. That is a bad redefinition and should be fixed. Of course an explicit break works, but it shouldn't be necessary. – barbara beeton Apr 25 at 16:47

You can use

 \section[form for header with no break](display form\\ with linebreak}


I cannot reproduce the behavior.

However, with those long titles, it makes sense to enable ragged right in them.

\documentclass[12pt,a4paper,twoside]{report}

%%% packages
\usepackage[
headheight=110pt, % 110pt? Are you sure?
]{geometry}

\usepackage{titlesec}
\usepackage{caption}
\usepackage{fancyhdr}
\usepackage[section]{placeins} %picture alsways in one section

%%% settings
% 1. titlesec
\titleformat{\chapter}
{\bfseries\Huge}
{0em}
{}
\titleformat{\section}
{\normalfont\fontfamily{phv}\fontsize{16}{19}\bfseries\filright}
{\thesection}
{1em}
{}
\titleformat{\subsection}
{\normalfont\fontfamily{phv}\fontsize{14}{17}\selectfont\filright}
{\thesubsection}
{1em}
{}
\titleformat{\subsubsection}
{\normalfont\fontfamily{phv}\fontsize{14}{17}\selectfont\filright}
{\thesubsubsection}
{1em}
{}

%2. fancyhdr
\pagestyle{fancy}
\renewcommand{\sectionmark}[1]{\markright{\thesection~#1}{}} %\MakeUppercase{\thesection\ #1}
\fancyfoot{}
\fancyfoot[OR,EL]{\bfseries \Large \thepage} %<----- NOT \textbf

\begin{document}

\section{Physical Compact Model of a VCM-type Resistive Switching Cell}

Some text

\end{document}


• But is \section so badly defined in report that the text on the first line won't stretch? It wouldn't be that much of a stretch. – barbara beeton Apr 25 at 16:18
• @barbarabeeton Actually, now that you make me notice, I cannot reproduce the OP's behavior. – egreg Apr 25 at 16:28
• Hmm, interesting that you cannot reproduce my behavior. If you want I can post the entire settings, in case something does influence it anyways. Also, what do you mean by enabling ragged right? I can't seem to see the difference between your settings and mine. – Nils Apr 27 at 9:10
• Ah and why did you comment the headheight of 110pt? Most of the settings I copied from my supervisor, as I am working on my master thesis. So it might be a guideline of my Institute. However, if typically a different headheight is used I will ask my supervisor about this. Thanks for the heads up :) – Nils Apr 27 at 9:12
• @Nils Try removing the setting and see: there is no change at all. – egreg Apr 27 at 9:58