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.

How do I flush page numbers to the right in the footer of an article class?

\documentclass{article}
\usepackage[english]{babel}
\usepackage{fancyhdr}
\pagestyle{fancy}
\headheight=14pt
\renewcommand\headrule{}
\fancyhf{}
\rhead{\textit{header}}
\thispagestyle{fancy}


\begin{document}

\section{Lorem Ipsum}

Tart jelly-o oat cake gingerbread cupcake cake icing croissant. Bear claw cake halvah oat cake pie carrot cake bonbon. Tiramisu applicake bonbon oat cake toffee cheesecake candy croissant. Topping candy canes cotton candy apple pie tart croissant caramels. Cupcake toffee sweet roll sesame snaps dessert biscuit oat cake. Sweet roll powder applicake chocolate bar icing chocolate cake dessert. Lollipop bear claw sugar plum gummi bears caramels sugar plum wafer jelly beans. Drage gummi bears wafer. Pie wypas chocolate bar lemon drops tiramisu. Topping wafer biscuit cake liquorice. Jujubes marshmallow tart liquorice marzipan applicake applicake. Dragee sweet roll jelly macaroon sesame snaps. Donut applicake macaroon dessert.


\subsection{Cupcake Ipsum}
Cake sesame snaps jelly sugar plum. Cotton candy cheesecake chocolate cake bonbon sweet. Liquorice pastry drage muffin oat cake sugar plum lollipop topping. Lemon drops chocolate bonbon. Topping jujubes topping. Lollipop bear claw biscuit chupa chups. Ice cream oat cake sesame snaps oat cake jelly beans jelly sweet roll apple pie. Chocolate cake jelly beans jelly beans applicake chupa chups cupcake powder. Applicake sweet roll danish cheesecake jujubes sweet cotton candy pie. Caramels bear claw halvah. Toffee cupcake sweet roll topping cheesecake. Jelly-o danish croissant jelly brownie wypas sweet chocolate. 

Topping powder candy canes. Jelly-o jelly topping macaroon bear claw.
Sweet roll danish souffle jujubes powder biscuit. Sesame snaps apple pie pie pie brownie jujubes. Gummi bears jujubes lemon drops tart fruitcake tart applicake tart macaroon. Muffin tart danish. Candy canes lemon drops liquorice marzipan gummies icing tootsie roll cupcake. Gummi bears chocolate tart fruitcake liquorice wafer applicake. Macaroon danish faworki jelly beans lollipop. Cupcake chupa chups dessert cake gummies halvah. Fruitcake cake brownie gummies sweet. Chocolate bar cotton candy applicake cotton candy biscuit toffee chocolate bar brownie souffle. Souffle lemon drops dragee bear claw oat cake bonbon chocolate cake tootsie roll. Candy topping marzipan gingerbread sweet roll pie. Carrot cake bear claw candy canes cake liquorice.
Chupa chups chupa chups gummi bears chocolate cake carrot cake gingerbread icing. Gummi bears sugar plum candy canes cookie sweet brownie cotton candy.

\section{Cupcake Ipsum}

Fruitcake gummi bears candy canes candy canes cheesecake sweet. Marzipan danish chocolate bar croissant applicake. Oat cake biscuit chocolate cake jujubes ice cream pudding. Dessert marzipan jujubes wafer jelly-o. Jelly jelly faworki bonbon cupcake wypas candy canes gummies jelly-o. Liquorice donut wafer sweet roll croissant. Sweet roll fruitcake lollipop jelly beans. Tart cotton candy marshmallow donut croissant souffle. Dragee chupa chups cookie dragee caramels. Cheesecake caramels sweet roll muffin wafer.
Sweet roll danish souffle jujubes powder biscuit. Sesame snaps apple pie pie pie brownie jujubes. Gummi bears jujubes lemon drops tart fruitcake tart applicake tart macaroon. Muffin tart danish. Candy canes lemon drops liquorice marzipan gummies icing tootsie roll cupcake. 

Gummi bears chocolate tart fruitcake liquorice wafer applicake. Macaroon danish faworki jelly beans lollipop. Cupcake chupa chups dessert cake gummies halvah. Fruitcake cake brownie gummies sweet. Chocolate bar cotton candy applicake cotton candy biscuit toffee chocolate bar brownie souffle. Souffle lemon drops dragee bear claw oat cake bonbon chocolate cake tootsie roll. Candy topping marzipan gingerbread sweet roll pie. Carrot cake bear claw candy canes cake liquorice.
Chupa chups chupa chups gummi bears chocolate cake carrot cake gingerbread icing. Gummi bears sugar plum candy canes cookie sweet brownie cotton candy.

\end{document}
share|improve this question
2  
Use package fancyhdr for class article or scrpage2 for scrartcl (KOMA-Script). –  Kurt Feb 7 '13 at 10:20
    
I did use fancyhdr for my header, but as a consequence my page numbers disappeared. –  Costanza Feb 7 '13 at 11:33
3  
Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. –  Kurt Feb 7 '13 at 12:38
4  
\fancyfoot[R]{\thepage}; use \fancyhead[R]{...} instead of \rhead: the "new" syntax is more powerful. –  egreg Feb 7 '13 at 13:31
    
Thank you @egreg: now it works perfectly. –  Costanza Feb 7 '13 at 14:03

1 Answer 1

up vote 4 down vote accepted

This is clearly explained in the manual of fancyhdr. After

\pagestyle{fancy}

you should define the appearance of your header and footer. The command

\fancyhf{}

clears all six fields (three for the header and three for the footer, left, center and right).

Now you can fill them:

\fancyheader[R]{\textit{header}}

will set "header" in italics in the right field of the header. To get the page number to the right of the footer, act similarly:

\fancyfoot[R]{\thepage}

The other fields are accessible with \fancyheader[L]{...} , \fancyheader[C]{...}, \fancyfoot[L]{...} and \fancyfoot[C]{...}.

If you choose the twoside option, the fields can be set differently on odd (right) pages and even (left) pages; for instance,

\fancyhead[LE,RO]{\textit{header}}

will set "header" in the left field on even pages and in the right field on odd pages.

share|improve this answer

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.