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'm trying to figure out how to get the odd and pages to display the current section name and the odd pages to display the title of the paper.

How do I accomplish this?

I'm using article and I have fancyhdr loaded.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

Here's one possibility:

\documentclass[twoside]{article}
\usepackage{fancyhdr}
\usepackage{lipsum}% just to generate text for the example

\fancyhf{}
\renewcommand\headrulewidth{0pt}
\fancyhead[LO]{\nouppercase\leftmark}
\fancyhead[RE]{\hdrtitle}
\fancyhead[LE,RO]{\thepage}
\pagestyle{fancy}

\title{Some Title}
\author{Some Author}

\makeatletter
\let\hdrtitle\@title
\makeatother

\begin{document}
\section{Test Section One}
\lipsum[1-10]
\section{Test Section Two}
\lipsum[1-10]
\end{document}
share|improve this answer
    
I noticed that the pages shift left and right (as if written for a book). How do I remove that feature? –  AlanH Mar 31 '13 at 3:15
1  
@AlanH I am not sure what do you mean with "pages shift left and right". Perhaps that inner/outer margins are different for even and odd pages? If this is so, then you could load the geometry package with the centering option: \usepackage[centering]{geometry}. If you meant other thing, please explain in a little more detail. –  Gonzalo Medina Mar 31 '13 at 4:17
    
When I use your code, the section number will display. It's quite confusing because the section number and the page number are both in the header. How do I just display the section title without the numbering? –  AlanH Mar 31 '13 at 8:12
    
@AlanH just now I saw your comment; I see you opened a new question, with this issue. I've provided an answer to this new question. –  Gonzalo Medina Mar 31 '13 at 13:57

titleps is an intuitive alternative to fancyhdr which provides \*title macros the contain the sectional unit titles (in contrast to using article's \leftmark, that has no immediate context).

Pilfering an example structure from Gonzalo:

\documentclass[twoside]{article}
\usepackage{titleps,lipsum}% http://ctan.org/pkg/{titleps,lipsum}

\title{Some Title}
\author{Some Author}

\makeatletter
\let\hdrtitle\@title% To store the title after using \maketitle
\newpagestyle{main}{%
  \sethead[\thepage][][\thesection \quad \sectiontitle] % even
  {\hdrtitle}{}{\thepage}} % odd
\makeatother
\pagestyle{main}

\begin{document}
\maketitle
\section{A section}
\lipsum[1-10]
\section{Another section}
\lipsum[1-10]
\end{document}

The main driver for setting headers/footers is given by

\sethead[<left>][<centre>][<right>] % even header
  {<left>}{<centre>}{<right>}} % odd header
\setfoot[<left>][<centre>][<right>] % even footer
  {<left>}{<centre>}{<right>}} % odd footer

which are self-explanatory.

share|improve this answer
    
what would be the advantage of this over Gonzalo's? –  AlanH Mar 31 '13 at 3:05
1  
@AlanH: Extracting other sectional unit titles where needed (\subsectiontitle, ...), and perhaps extracting so-called top/bottom title marks (typically associated with dictionary-style headings). You'd have to see the full titleps documentation for more on this. There's also a short section on titleps for fan­cy­hdr users, if you're interested. –  Werner Mar 31 '13 at 3:13

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.