3

I have a document containing my course notes, and am attempting to alter the fancyhdr header as in the images below:

Current

current

Wanted

wanted

Here is my current header code, with irrelevant parts omitted.

\documentclass[english, 11pt]{article}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usetikzlibrary{decorations.pathmorphing}

\chead{\coursename}
\lhead{\semester}

\begin{document}

\section{Lecture 1}
.
.
.
\end{document}

What I would like is for the right header to contain the section name (and only the section name) of the current page, the actual section titles in the document to contain only the section name, but the table of contents to retain the section number. Please note I have only limited TeX experience (self-taught), so this is a fairly steep learning curve for me. Thank you in advance.

1
  • 1
    I guess you omit \usepackage{fancyhdr} in your MWE. Please edit your question so that it corresponds to Minimal Working Example.
    – chejnik
    Mar 17, 2015 at 13:18

1 Answer 1

1

Here is a slightly alternative suggestion based on the fact that you're probably going to enumerate all lectures one after the other, and not really "name" them. Therefore, instead of using

\section{Lecture 1}

use some automated

\newlecture

which will print the heading, do some formatting, and adjust the header/footer accordingly.

enter image description here

\documentclass{article}
\usepackage{fancyhdr,lipsum}
\pagestyle{fancy}

\chead{\coursename}
\lhead{\semester}
\rhead{\lecturename{} \thelecture}

\newcommand{\coursename}{Engineering Numerical Methods}
\newcommand{\semester}{Semester 1 2015}
\newcommand{\lecturename}{Lecture}

\newcounter{lecture}
\newcommand{\newlecture}{%
  \clearpage
  \refstepcounter{lecture}%
  \noindent{\large\bfseries \lecturename{} \thelecture}%
  \par\bigskip\noindent\ignorespaces%
}

\begin{document}

\newlecture\label{lec:first}%
\lipsum[1-3]

\newlecture
In Lecture~\ref{lec:first}, we examined \ldots
\lipsum[1-3]

\end{document}

You must log in to answer this question.

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