4

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:

enter image description here

With linebreak:

enter image description here

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[headheight=110pt]{geometry}

\usepackage{titlesec}
    \titleformat{\chapter}{\bfseries\Huge}{\thechapter\quad}{0em}{}
    \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{\chaptermark}[1]{\markboth{\thechapter~#1}{}} %no chapter in header
\renewcommand{\sectionmark}[1]{\markright{\thesection~#1}{}}
     %\MakeUppercase{\thesection\ #1} 
     \fancyfoot{}
\fancyhead{}
\fancyhead[OR]{\rightmark} %die Section-Name
\fancyhead[EL]{\leftmark} % Chapter-Name
\fancyfoot[OR,EL]{\textbf \Large \thepage}
  • 1
    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
4

You can use

 \section[form for header with no break](display form\\ with linebreak} 
| improve this answer | |
2

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}
  {\thechapter\quad}
  {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{\chaptermark}[1]{\markboth{\thechapter~#1}{}} %no chapter in header
\renewcommand{\sectionmark}[1]{\markright{\thesection~#1}{}} %\MakeUppercase{\thesection\ #1} 
\fancyfoot{}
\fancyhead{}
\fancyhead[OR]{\rightmark} %die Section-Name
\fancyhead[EL]{\leftmark} % Chapter-Name
\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}

enter image description here

| improve this answer | |
  • 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

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.