Page LayoutPage Number in top right Corner

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
fabioled
Posts: 14
Joined: Sat Sep 15, 2012 2:51 am

Page Number in top right Corner

Post by fabioled »

Hi everyone,

I have a problem with the page in my document. How do I put the page number in top right corner of the page in case I need to use the option twoside in the docment class report?

Here is my minimal example (my apologies for that because until now I can't do a good example, but hope that you understand).

Code: Select all

\documentclass[
  12pt,
  a4paper,
%  twoside
]{report}

%%%%%Preambule
\usepackage[T1]{fontenc}  %encoding
\usepackage{times}        %font
\usepackage{setspace}
\usepackage[utf8]{inputenc}   %encoding
\usepackage{graphicx}

\usepackage{fancyhdr} % draw header and foot
 
% Pacote para divisão silábica do portugues
\usepackage[english, brazilian]{babel}
\usepackage[titles]{tocloft} %% formatar a lista de figuras e tabelas.

\usepackage{geometry}
\geometry{tmargin=20mm,bmargin=20mm,lmargin=30mm,rmargin=20mm}

% change indent of table of content
\usepackage[titles]{tocloft}
\cftsetindents{chapter}{0cm}{.3cm}
\cftsetindents{section}{0cm}{.6cm}
\cftsetindents{subsection}{0cm}{.9cm}
\cftsetindents{subsubsection}{0cm}{1.2cm}
\cftsetindents{paragraph}{0cm}{1.5cm}

%%%%%%%%%%%  CONFIG ABOUT HEADER E AND FOOT %%%%%%%%%%%%%%%%%%
\pagestyle{fancy}
\fancyhf{}
%para margem do cabeçalho ficar do tamanho da margem do texto
\fancyheadoffset{0cm}

\rhead{\thepage}  %% PUT THE PAGE ON TOP RIGHT BUT NOT WORK

\setlength\parindent{0pt}
\renewcommand{\headrulewidth}{0pt} % remove lines as well
\renewcommand{\footrulewidth}{0pt}
% \fancyhead[R]{\thepage}
\lfoot{}

%%%%%%%%%%%% Begin Docment %%%%%%%%%%%%%%%%%%

\begin{document}

% \listafiguras   % list of figures
% \listatabelas   % list of tables
% \listadesiglas  % list abrevy
   \tableofcontents
%  \sumario  %My custon tableofcontents 


%%%%%%%%%%%%%%% Textos %%%%%%%%%%%%%%%%%%
\chapter{\uppercase{Introdução}}

A introdução deverá conter a natureza do trabalho, justificativa.

\section{Problema}

a lek lek lek lelek lekyyyy girando girando girando prum lado
girando girando pro outro kkk.
 
\section{Justificativa}

Esta seção foi inserida para ilustrar uma seção 

\chapter{\uppercase{Desenvolvimento}}

Eu não sei falar ingles, ela não entende uma palavra em portugues.

I saw you saying that you say that you saw I saw you saying that you say that you

\chapter{\uppercase{Conclusão}}

I feel good because you put your butt on me
I feel good because you put your butt on...

\bibliography{bibliografia}   %my bib file
\end{document}
Last edited by localghost on Mon Sep 23, 2013 6:58 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

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Page Number in top right Corner

Post by Johannes_B »

Hi,

the pages where a chapter begins are typeset differently. Please have a look at section 7 of the fancyhdr manual to learn how to change the plain style.

By the way, getting rid of the \parindent isn't a good idea. You should use the parskip package instead.

Code: Select all

\documentclass[12pt,a4paper,twoside]{report}
\usepackage{fancyhdr} 

\pagestyle{fancy}
\fancyhf{}
\fancyheadoffset{0cm}
\renewcommand{\headrulewidth}{0pt} 
\renewcommand{\footrulewidth}{0pt}
\fancyhead[R]{\thepage}
\fancypagestyle{plain}{%
  \fancyhf{}%
  \fancyhead[R]{\thepage}%
}

\usepackage{blindtext}
\usepackage{parskip}

\begin{document}
  \Blinddocument
\end{document}

Best regards
Johannes
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
fabioled
Posts: 14
Joined: Sat Sep 15, 2012 2:51 am

Re: Page Number in top right Corner

Post by fabioled »

Hi,

Work perfectly, very thanks for you help.
Is the persons how you that make the diference.
Post Reply