Page Layoutfancyhdr | Section Names are ignored

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
p90
Posts: 1
Joined: Wed Jan 18, 2012 3:06 pm

fancyhdr | Section Names are ignored

Post by p90 »

Hi,

first, Hello ^^
second, I try to get a header into my document which contains the last section/subsection name on the left side and the page number on the right side. Problem is that section names are not shown, only if I already created a subsection the subsection will be shown.
Here a little example:

Code: Select all

\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr} % get some nice header and fotter options
\fancyhf{} % clear all header and footers
\lhead{\rightmark} %section name left side of header
\rhead{\thepage} %current page on right side of header
\pagestyle{fancy}
\begin{document}
\section{Not shown in header}
\newpage
\subsection{Shown in header}
\end{document}
I am not sure what causes this problem (or if this is by design) and so I ask you guys as a last resort.
With best regards


p90

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

Stefan Kottwitz
Site Admin
Posts: 10335
Joined: Mon Mar 10, 2008 9:44 pm

Re: fancyhdr | Section Names are ignored

Post by Stefan Kottwitz »

Hi,

welcome to the board!

You used \rightmark, which prints the subsection title. \leftmark contains the section title, you did not use that macro.

Stefan
LaTeX.org admin
Post Reply