Page LayoutTOC modification with fancyhdr

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
mrbluesky
Posts: 1
Joined: Tue Jul 08, 2014 12:47 am

TOC modification with fancyhdr

Post by mrbluesky »

Hey guys,
I've got some problems with my document which I created with fancyhdr. It's all fine, everything works, exept for one thing:

In my table of contents I would like to have the sections (in contrast to the subsections) in bold letters. Does anyone know how to do this with fancyhdr?

Thanks :)

Here's an example of my code:

Code: Select all

\documentclass[12pt,a4paper]{article}
\usepackage{fancyhdr}
\usepackage[ngerman]{babel}
\usepackage[top=2.5cm, bottom=2.5cm, left=2.5cm, right=2.5cm]{geometry}
\usepackage{blindtext}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0.5pt}
\rhead{\nouppercase{\rightmark}}\lhead{}
\renewcommand{\sectionmark}[1]{\markright{\ #1}}
\setcounter{secnumdepth}{-2}

\makeatletter
\renewcommand*\l@section{\@dottedtocline{1}{0.5em} {2.3em}}
\renewcommand*\l@subsection{\@dottedtocline{1}{1.5em} {2.3em}}
\makeatother 

\begin{document}
\tableofcontents

\newpage

\section{Section 1 (die soll im TOC fett sein)}
\subsection{Subsection 1}

\blindtext

\newpage
\subsection{Subsection 2} 

\blindtext

\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

TOC modification with fancyhdr

Post by Johannes_B »

Package fancyhdr provides commands to change the header and footer of pages. It doesn't affect the TOC-style.

However package titlesec does, package tocstyle might provide something similar, but i am not sure about this right now.

I think it is fairly easy using the KOMA article class scrartcl. You might want to give that a try.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

TOC modification with fancyhdr

Post by Johannes_B »

The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply