Page Layout"\markboth" not working

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
lnsam22
Posts: 28
Joined: Thu Jan 13, 2011 6:47 pm

"\markboth" not working

Post by lnsam22 »

Hi All.

I'm attempting to make my own headers for a paper I'm writing. I want to alternate between two headings: "Left" and "Right"; i.e. Page 1 has 'Left' written in the left corner (along with the page number), page 2 has 'Right' written in the right corner. Page 3 again has 'Left' written in the left corner, page 4 Right in right corner... and so forth.

My problem is: I'm not getting the Left and Right printing out when I use "\markboth". Only Left. Can you help me figure out why? And when you do, get them to alternate pages?

Code: Select all

\documentclass{article}
%
\usepackage{amsmath}%
\usepackage{amsfonts}%
\usepackage{amssymb}%
\usepackage{graphicx}
\usepackage{graphics,color}
\usepackage[superscript]{cite}

\begin{document}
\pagestyle{myheadings}
\markboth{Right}{Left}

First page
\newpage
Second page
\newpage
Third page
\newpage
Fourth page

 \end{document}
Thanks much!
lnsam
Last edited by lnsam22 on Thu Feb 10, 2011 2:17 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

"\markboth" not working

Post by frabjous »

The article class is one-sided by default, so it doesn't treat odd and even page numbers differently, and \rightmark is never used.

Change

Code: Select all

\documentclass{article}
to

Code: Select all

\documentclass[twoside]{article}
This, however, will have other effects you may or may not want.

Or better yet, use the fancyhdr package for more customizability.
lnsam22
Posts: 28
Joined: Thu Jan 13, 2011 6:47 pm

Re: "\markboth" not working

Post by lnsam22 »

I'm using fancyhdr. You guys on this forum are really helpful. Thanks!
Post Reply