问题
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
回答1:
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.
回答2:
Another problem I encountered, which isn't directly related to fancyhdr, but may still be of interest is how to modify the formatting of section headers.
These two links helped me a lot:
- TeX FAQ entry: The style of section headings
- http://zoonek.free.fr/LaTeX/LaTeX_samples_section/0.html
来源:https://stackoverflow.com/questions/1288084/problems-with-latex-and-fancyhdr