0

Below is my document. My problem is, that whenever the \section titles are too long, they overlap with the logo and the TOC looks very strange with indents, where there shouldn't by any. Is there a way to reduce the header font size or make it adjust to the section-title length?

Here's a link to the document, where you can see the overlapping etc.

\documentclass[a4paper,10pt,titlepage,twoside]{article}

\usepackage[ngerman]{babel}

%lots of maths packages
\usepackage{tikz-3dplot,framed,enumitem,bbm}

%break after each section
\usepackage{titlesec}
\newcommand{\sectionbreak}{\vspace{6mm}}

\usepackage[margin=1.5cm, headheight=12.6pt, includeheadfoot, left=2cm, right=2cm]{geometry}%new borders

\usepackage{fancyhdr}%header
\pagestyle{fancy}
\fancyhf{}
\fancyhead[RE,LO]{\scshape\nouppercase{{\rightmark}}}
\fancyhead[LE]{\includegraphics[width=1cm]{tub_logo.png}}
\fancyfoot[C]{\thepage}
\renewcommand{\headrulewidth}{1.2pt}
\setlength\headheight{25pt}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}
\begin{titlepage}
\begin{center}
    {\scshape\Large Technische Universität Berlin \par}
    % title page (omitted text etc. because its not relevant)
\tableofcontents
\end{center}   
\end{titlepage}


\section{Vollständigkeit, Kompaktheit, endliche Durchschnittseigenschaft und der Banachsche Fixpunktsatz}

text
\end{document}  
5
  • Welcome to TeX SX! Did you try to use the titletoc package, since you load titlesec? It defines a rightmargin length for the table of contents.
    – Bernard
    Commented May 13, 2018 at 9:52
  • try to make/define shorter section title for page headers: \section[<short title>]{Vollständigkeit, Kompaktheit, endliche Durchschnittseigenschaft und der Banachsche Fixpunktsatz}, where <short title> can be something like "Eigenschaften der Banachsche Fixpunktsatz"
    – Zarko
    Commented May 13, 2018 at 10:14
  • @Bernard No I didn't. Can you please show me how? Commented May 13, 2018 at 10:21
  • @Zarko Will that affect the header length and/or the TOC ? Commented May 13, 2018 at 10:22
  • @ViktorGlombik, depends on used document class (memoir support separate options for toc and headers: \section[<toc-title>][<head-title>]{<title>}). article, report, book ... long title will be in text, short in toc and headers.
    – Zarko
    Commented May 13, 2018 at 10:31

1 Answer 1

1

Her is a solution for the table of contents, based on titletoc.

Unrelated: since version 3.10, language options of babel should be loaded with the document class, so that all language-dependent packages be aware of the document language. Also you set two values for \headheight.

\documentclass[a4paper, 10pt, titlepage, twoside, ngerman]{article}

\usepackage{babel}

%lots of maths packages
\usepackage{tikz, tikz-3dplot,framed,enumitem,bbm}

%break after each section
\usepackage{titlesec}
\newcommand{\sectionbreak}{\vspace{6mm}}

\usepackage[margin=1.5cm, headheight=12.6pt, includeheadfoot, hmargin=2cm]{geometry}%new borders

\usepackage{fancyhdr}%header
\pagestyle{fancy}
\fancyhf{}
\fancyhead[RE,LO]{\scshape\nouppercase{{\rightmark}}}
\fancyhead[LE]{\includegraphics[width=1cm]{tub_logo.png}}
\fancyfoot[C]{\thepage}
\renewcommand{\headrulewidth}{1.2pt}
\setlength\headheight{25pt}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{titletoc}
\titlecontents{section}[0em]{\medskip\bfseries}% formatting for numbered sections
{\thecontentslabel\quad\parbox[t]{36pc}}
{}% for unnumbered sections
{\hfill\contentspage}%

\usepackage{lipsum}

\begin{document}
\begin{titlepage}
\begin{center}
    {\scshape\Large Technische Universität Berlin \par}
    % title page (omitted text etc. because its not relevant)
\tableofcontents
\end{center}
\end{titlepage}

\section{Vollständigkeit, Kompaktheit, endliche Durchschnittseigenschaft und der Banachsche Fixpunktsatz}

\lipsum

\section{Vollständigkeit, Kompaktheit, endliche Durchschnittseigenschaft und der Banachsche Fixpunktsatz}

\lipsum

\section{Vollständigkeit, Kompaktheit, endliche Durchschnittseigenschaft und der Banachsche Fixpunktsatz}

\lipsum

\section{Vollständigkeit, Kompaktheit, endliche Durchschnittseigenschaft und der Banachsche Fixpunktsatz}

\lipsum

\end{document} 

enter image description here

6
  • Great! What does {\hfill\contentspage} do? And how do I get the TOC on my title page? ( Everything I have on my title page fills approximately the upper half, and since the TOC won't be that long, I would like to have it all on one page). Commented May 13, 2018 at 11:46
  • \hfill\contentspage prints the page number at the right margin, ragged right. As to your second question, as you can see, the title and the table of contents are already on the same page. If you want to be sure they remain on the same page, as this depends on what you put in the title page, you might want to take a look at the titling package, which gives tools to customise the \maketitle command and defines a titlingpage environment.
    – Bernard
    Commented May 13, 2018 at 11:59
  • In my document, the toc is not on the title page. Also, I only see the page number on the bottom center. Am I missing out on something? Commented May 13, 2018 at 12:07
  • Do you use the article class, as in your post? Also what do you mean with ‘only the page number at the bottom center’ – you obtain the plain page style?
    – Bernard
    Commented May 13, 2018 at 12:17
  • Yes I do use article and concerning your second question: you said ''\hfill\contentspage prints the page number at the right margin, ragged right.'', but I don't see the page number at the right margin... Commented May 13, 2018 at 12:33

You must log in to answer this question.

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