1

I am trying to place the page number at the right top of the page, and it is working in the chapters, but at the beginning of the document it is not working as I was expecting. This are the lines I am using to set the page numbering:

% Page numbering: top right
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancypagestyle{plain}{
    \fancyhf{} % clear all header and footer fields
    \fancyhead[RO,RE]{\thepage} %RO=right odd, RE=right even
    \renewcommand{\headrulewidth}{0pt}
    \renewcommand{\footrulewidth}{0pt}
}

I am getting this:

enter image description here

First, I am getting that horizontal line at the top in several pages. In addition, this page has a number, and it is not supposed to have it, and other pages too. Finally, the pages that have the contents are numbered too. How can I solve this issue?

P.S.: I need no header neither footer.

  • 2
    Welcome! We need more information. The code you've posted is not the problem. Please post a small, complete document which we can copy-paste-compile to reproduce the problem in order to help you. Right now, all anybody can do is either (1) tell you something elsewhere in your code is responsible or (2) guess wildly. Neither have a good track record of helping. – cfr Jul 30 '15 at 2:51
  • I have these files: main and settings. In settings is where I have the code I have posted previously. – lmiguelvargasf Jul 30 '15 at 2:57
  • 1
    Please create a minimal document and post the code here. I've posted a wild guess. But, as it is wild, it may well be wrong. If so, add the missing information to your question. Otherwise, when those links change, this question will become useless to other users. Questions should, as far as practicable, be self-contained. – cfr Jul 30 '15 at 3:00
  • I know, but I have basic knowledge about LaTeX, and I do not know what part of the settings is relevant to this question. I have omitted all the commands I had defined. Feel free to edit my question if you have enough time. – lmiguelvargasf Jul 30 '15 at 3:02
  • Make a copy. Cut stuff out. Still have the problem? Then that wasn't needed. Problem disappears? Then you needed (some) of it. It is just a mechanical process - you don't need to know anything about LaTeX at all. – cfr Jul 30 '15 at 3:20
1

Assuming you are using a standard class, you should be using either titlepage or \maketitle to create your title. This automatically sets the page style to empty or plain. Presumably, you are not doing that, so you are getting the fancy style which includes headings and a page number in the footer by default.

Probably, you want to set up a suitable style for standard pages.

But, in any case, if you do not use titlepage or \maketitle or equivalent, you should say \thispagestyle{empty} on the first page to avoid both header and footer.

This is, of course, a wild guess (see comment). Hence it could be quite wrong. Without a minimal example, it is impossible to do better.

|improve this answer|||||
  • I am not using titlepage neither \maketitle. You solution works for all pages I am having this issue, but not for the pages that have the contents. I would like these pages not to be numbered. – lmiguelvargasf Jul 30 '15 at 3:10
  • @lmiguelvargasf If you don't want headers/footers at all, even when you have contents, just say \pagestyle{empty} and don't bother with fancyhdr. You only need that if you want stuff like page numbers. – cfr Jul 30 '15 at 3:19
  • Well @cfr, although your answer worked, I have found another one that seems easier. I have added \pagestyle{empty} and \pagenumbering{gobble} to the previous code I have shown, and it worked as I wanted, but I will upvote your answer because I really appreciate your effort. – lmiguelvargasf Jul 30 '15 at 3:23
0

Adding the following lines lines:

\pagestyle{empty}
\pagenumbering{gobble}

to the previous code I published worked properly for me. So the code I have used is this one:

% Page numbering: top right
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancypagestyle{plain}{
    \fancyhf{} % clear all header and footer fields
    \fancyhead[RO,RE]{\thepage} %RO=right odd, RE=right even
    \renewcommand{\headrulewidth}{0pt}
    \renewcommand{\footrulewidth}{0pt}
}
\pagestyle{empty}
\pagenumbering{gobble}
|improve this answer|||||
  • But the use of fancyhdr is pointless. You are setting up a page layout and then overwriting it. Why make page numbers top right and then eliminate all page numbering? Why specify you want fancy page style and then immediately say you want empty? – cfr Jul 30 '15 at 13:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.