3

I'm trying to modify the page layout of my thesis. I'd like to have at the top-right corner the section number and section title and at the top left corner the page number.

Using the following:

\usepackage{fancyhdr}

\begin{document}

\pagestyle{fancy}
\lhead{\thesection}
\chead{}
\rhead{\thepage}
\lfoot{}
\cfoot{}
\rfoot{}

I get what expected. However I'd like to add the section name. I've tried:

\pagestyle{fancy}
\lhead{\thesection}{thesectiontitle}
\chead{}
\rhead{\thepage}
\lfoot{}
\cfoot{}
\rfoot{}

but of course it didn't work. I think it requires a bit more of programming but I only have a basic Latex tutorial so far where I can't find useful information. Thank you in advance for any advice

3
  • Maybe what you want, roughly, is: \renewcommand{\sectionmark}[1]{\markright{\thesection.\ #1}} and then in \lhead{\rightmark}. But I think you have your description and code reversed. And is your thesis going to be 'one-sided'?
    – jon
    Nov 7, 2013 at 16:24
  • @jon Wanna write up an answer and get this off the list of unanswered questions? Thanks.
    – Johannes_B
    Jan 25, 2015 at 17:00
  • @Johannes_B -- No problem.
    – jon
    Jan 25, 2015 at 17:35

1 Answer 1

3

(Based on an earlier comment.)

Adding this to the preamble

\renewcommand{\sectionmark}[1]{\markright{\thesection.\ #1}} 

and then changing \lhead in the following way

\lhead{\rightmark}

seems to have solved this problem.

You must log in to answer this question.

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