Page LayoutHeader in every page with elsarticle

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
amiruw1
Posts: 3
Joined: Tue Feb 15, 2011 3:47 pm

Header in every page with elsarticle

Post by amiruw1 »

Dear All,

I want to have a fixed header (TEXT) in every page including the first one (with elsarticle). With the following I can't get this header in the first page; how can I fix this problem? Your comment is greatly appreciated.

\documentclass{elsarticle}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{}
\fancyhead[LE,LO]{TEXT}

amiruw
Last edited by amiruw1 on Wed Feb 16, 2011 3:35 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.

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

Header in every page with elsarticle

Post by frabjous »

You should always provide a complete minimal working example -- as is, we are simply left to guess why the first page is different from the rest, though in this case, it is not too hard to make an educated guess.

Most likely, the plain page style is being applied to the first page, rather than the fancy page style. So you either need to use \thispagestyle{fancy} for the first page, after whatever command is making it plain style (probably \maketitle), or else you need to redefine plain style so it works just like fancy. So after all of the above, do:

Code: Select all

Code, edit and compile here:
\fancypagestyle{plain}{%
\fancyhead{}
\fancyhead[LE,LO]{TEXT}
\renewcommand{\headrulewidth}{0.4pt}% or whatever
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
See sec. 7 of the fancyhdr documentation.
amiruw1
Posts: 3
Joined: Tue Feb 15, 2011 3:47 pm

Header in every page with elsarticle

Post by amiruw1 »

Thanks for your reply. Unfortunately it didn't work out. I also used the following alternative approach but the problem is still the same; that is, the header is missed in the first page:

Code: Select all

Code, edit and compile here:
\usepackage{fancyhdr}
\fancyhead{TEXT}
\usepackage{lastpage}
\pagestyle{fancy}
\lhead{TEXT} \chead{}\rhead{\scriptsize \thepage}
\lfoot{}\cfoot{}\rfoot{}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
My first page is as follows:

Code: Select all

Code, edit and compile here:
\documentclass{elsarticle}
%
\usepackage{natbib}
%
\usepackage {graphicx}
\usepackage{threeparttable}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage[nodots]{numcompress}
\usepackage{lineno}
%
\usepackage{fancyhdr}
\fancyhead{TEXT}
\usepackage{lastpage}
\pagestyle{fancy}
\lhead{TEXT} \chead{}\rhead{\scriptsize \thepage}
\lfoot{}\cfoot{}\rfoot{}
%
\renewcommand{\headrulewidth}{0.0pt}
%
\usepackage{colortbl}
\usepackage{float}
\usepackage{subfigure}
\usepackage{longtable}
%
\usepackage{url}
\usepackage[hyphens]{url}
\usepackage[dvips=true,bookmarks=true,breaklinks=true]{hyperref}
\usepackage{breakurl}
%
\newcommand{\eg}{\text{e.g.,}~}
\newcommand{\ie}{\text{i.e.,}~}
\newcommand{\etc}{\text{etc.}~}
%
\renewcommand\floatpagefraction{.9}
\renewcommand\topfraction{.9}
\renewcommand\bottomfraction{.9}
\renewcommand\textfraction{.1}
\renewcommand{\dbltopfraction}{0.9}
\setcounter{totalnumber}{4}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

Header in every page with elsarticle

Post by frabjous »

An excellent example of why minimal working example is so important. (Unfortunately, you still didn't provide one, since you didn't post a complete document, since yours cuts of before \end{document}, and you also use two packages that are not available as part of standard LaTeX installation -- numcompress and lineo. I had to comment these out to test your code. See the Post on Avoidable Mistakes.) But they don't have anything to do with your problem (or so I'd guess), so they shouldn't have been in your sample anyway.

However, both of my suggestions work perfectly. One is to put \thispagestyle{fancy} right after whatever command is changing the pagestyle for the first page. In this case, that is the frontmatter environment. So if you put \thispagestyle{fancy} right after \end{frontmatter}, it works just fine. (Or does in my test.)

The other option is to change the pagestyle used on that page. I assumed it was plain, since that is what it would be for a normal document class. However, for the elsarticle document class, the pagestyle there is called "pprintTitle"; this is specific to that documentclass, and hence, without a full document of your code, it was impossible to get it right. However, it seems to work fine if you put:

Code: Select all

Code, edit and compile here:
\fancypagestyle{pprintTitle}{%
\lhead{TEXT} \chead{}\rhead{\scriptsize \thepage}
\lfoot{}\cfoot{}\rfoot{}
\renewcommand{\headrulewidth}{0.0pt}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
in the preamble.

In the future, please keep in mind how important minimal examples are, and read the page linked above about how to create one. It really helps make it easier for people to provide help!
amiruw1
Posts: 3
Joined: Tue Feb 15, 2011 3:47 pm

Re: Header in every page with elsarticle

Post by amiruw1 »

Thanks very much; I appreciate your time and help.
As you suggested, putting \thispagestyle{fancy} right after \end{frontmatter} solved the problem.

amiruw1
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Header in every page with elsarticle

Post by localghost »

amiruw1 wrote:[…] As you suggested, putting \thispagestyle{fancy} right after \end{frontmatter} solved the problem. […]
Then please mark the topic (not the last post) accordingly.


Best regards and welcome to the board
Thorsten
Post Reply