Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

migrated from stackoverflow.com Apr 15 '12 at 15:28

This question came from our site for professional and enthusiast programmers.

    
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. –  Ulrike Fischer Apr 16 '12 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 Apr 16 '12 at 11:50
    
Make a complete example that demonstrates your problem. Also start comments with @Ulrike so that I get notified. –  Ulrike Fischer Apr 16 '12 at 13:55
    
@UlrikeFischer Thanks for your help! I have updated the post. –  raze Apr 17 '12 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. –  Ulrike Fischer Apr 17 '12 at 10:51
show 2 more comments

1 Answer

up vote 3 down vote accepted

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.