Problems with Latex and fancyhdr

10,352

Your \documentclass[a4paper,12pt,T2A,oneside]{article} specifies oneside - that is one sided article - so all headers would get printed on all pages by fancyhdr. Change that to twoside:

\documentclass[a4paper,12pt,T2A,twoside]{article}

See this article for information on how you might have to change page borders when using this option.

Share:
10,352
abhijeet nigoskar
Author by

abhijeet nigoskar

Architect 👨‍💻 @nrwl_io 🐳🦄 • Google Dev Expert #GDE •🎓 @eggheadio • ❤ JS, Angular • 📝 blogger • 🗣️ speaker • @cypress_io Ambassador • nx.app • nx.dev You can find me on juri.dev or @juristr

Updated on November 19, 2022

Comments

  • abhijeet nigoskar
    abhijeet nigoskar over 1 year

    I hope also Latex questions are welcome here on Stackoverflow since it's not really programming related.

    I have a problem in defining the correct style for the header using the fancyhdr package. What I'd like to achieve is to have

    • On odd pages on the left side the following text "My paper title"
    • On even pages on the right side the text "Firstname Surname"

    (Replaced with the correct text of course).

    At the moment I have the following "test" Latex document:

    \documentclass[a4paper,12pt,T2A,oneside]{article}
    \usepackage[english]{babel}
    \usepackage{indentfirst}
    \usepackage{amsmath}
    \usepackage{amsxtra}
    \usepackage{amssymb}
    \usepackage{amsfonts}
    \usepackage{graphicx}
    \usepackage{subfigure}
    \usepackage{float}
    \usepackage{fancyhdr}
    \usepackage[pdfborder=0 0 0]{hyperref}
    
    
    
    %define the header
    \pagestyle{fancy}
    
    \fancyhf{}
    \fancyhf[ROH,LEH]{Firstname Surname}
    \fancyhf[REH,LOH]{\bfseries My paper title}
    
    \begin{document}
    
    \title{My title \\}
    \author{\small{Firstname Surname}}
    \date{June 9, 2009}
    
    \maketitle
    
    
    \section{Introduction}
    blablabla asdfasdf asdf ads fad sf
    
    adsfadsf a fdasfd asfd 
    
    \subsection{This is a subsection}
    Some text\ldots
    
    \pagebreak
    
    some further text
    
    \pagebreak
    
    some additional text
    
    % Stop your text
    \end{document}
    

    I tried different variations of this part

    \fancyhf{}
    \fancyhf[ROH,LEH]{Firstname Surname}
    \fancyhf[REH,LOH]{\bfseries My paper title}
    

    but I can't make it work. At the moment the text is printed on each page, odd and even. I also found this wiki article which describes the different meanings of "ROH" etc... and it's also clear, but for some reason it doesn't work for me. I must make some silly mistake which I can't get right now...

    Thx for any help!

    //Edit:
    Tex distribution: gwTeX
    OS: Mac OS X 10.5.8

    • mcandre
      mcandre over 14 years
      The various TeX distributions have discrepancies (much like browsers and CSS). Which TeX system and OS are you using?
    • abhijeet nigoskar
      abhijeet nigoskar over 14 years
      I updated the details on my post. Thx for the info
  • abhijeet nigoskar
    abhijeet nigoskar over 14 years
    That was it exactly. Thanks a lot.
  • abhijeet nigoskar
    abhijeet nigoskar over 14 years
    Just another question. Do you maybe have some links or know how to change the default formatting/alignment of section titles defined with \section{some section title}? That would be great.
  • abhijeet nigoskar
    abhijeet nigoskar over 14 years
    Found something that seems to work: tex.ac.uk/cgi-bin/texfaq2html?label=secthead