7

I want to have section name + number on the left side in the header, and a predefined text on the right side. Also want to have subsection / subsubsection name + number, if the subsection is long enough. This is what I have.

\documentclass[11pt,norsk,a4paper]{article}
\usepackage{ucs,babel}
\usepackage[utf8x]{inputenc}
\usepackage{fancyhdr}

% title and so on

\begin{document}

\pagestyle{fancy}
\renewcommand{\sectionmark}[1]{\markright{#1}{}}

\fancyhf{}

\rhead{\fancyplain{}{Prosessrapport}} % predefined ()
\lhead{\fancyplain{}{\rightmark }} % 1. sectionname, 1.1 subsection name etc
\cfoot{\fancyplain{}{\thepage}}

What I get from this, is the subsection name without number. And the subsection name + number.

UPDATE:

\documentclass[11pt,norsk,a4paper]{article}
\usepackage{ucs,babel}
\usepackage[utf8x]{inputenc}
\usepackage{fancyhdr}

\title{sd}
\date{}

\begin{document}
\maketitle

\pagestyle{fancy}
\renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}

\fancyhf{}

\rhead{\fancyplain{}{$<$Name of the report$>$}} % predefined ()
\lhead{\fancyplain{}{\rightmark }} % 1. sectionname, 1.1 subsection name etc
\cfoot{\fancyplain{}{\thepage}}
\newpage
\section{section}
\newpage
\subsection{subsection}
\newpage
\subsubsection{subsubsection}

\end{document}

On the last page (4), I have a subsubsection, but the header says subsection. Is there any way to make it say subsubsection?

6
  • The argument of \sectionmark is only the title of the section. So if you want \markright to store also the number you must add it yourself: \renewcommand{\sectionmark}[1]{\markright{\thesection\ #1}}. For the rest of your questions: Sort out your problem description first. Commented Apr 16, 2012 at 9:35
  • Thanks for the reply! This worked great for the section and subsection. But the subsubsection does not show up in the header. Any idea? :)
    – raze
    Commented Apr 16, 2012 at 11:50
  • Make a complete example that demonstrates your problem. Also start comments with @Ulrike so that I get notified. Commented Apr 16, 2012 at 13:55
  • @UlrikeFischer Thanks for your help! I have updated the post.
    – raze
    Commented Apr 17, 2012 at 10:25
  • 1
    You can use \renewcommand{\subsubsectionmark}[1]{\markright{\thesubsubsection\ #1}} so that also the \subsubsection fills \rightmark. \rightmark will always show the first title of the page. Commented Apr 17, 2012 at 10:51

1 Answer 1

4

You can use \renewcommand{\subsubsectionmark}[1]{\markright{\thesubsubsection\ #1}} so that also the \subsubsection fills \rightmark. \rightmark will always show the first title of the page.

You must log in to answer this question.

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