1

I would like to adjust the page number position in my TEX file: I tried this post, but it does not work for me. In fact, I would like to set the position in the upper right corner of the page (2cm vertically and 2.5cm horizontally). Here is my code:


\documentclass[12pt]{report}
\usepackage[total={8.5in,11in}, left = 1.5in, right = 0.75in, top = 1.5in, bottom = 0.75in]{geometry}
% \usepackage[total={8.5in,11in},centering,margin=1in]{geometry}

% Packages Section
%=================
\usepackage[title]{appendix}
\usepackage{amssymb}            % Complex numbers
\usepackage{bbding}             % Symbols
\usepackage{bm}                 % Bold Math
\usepackage{enumitem}
\usepackage{gensymb}
\usepackage{fancyhdr}
\usepackage[T1]{fontenc}
\usepackage[french]{babel}
\usepackage{float}
\usepackage[justification=centering]{caption}
\usepackage[hyphens]{url}
\usepackage[colorlinks,
            urlcolor=blue,
            ]{hyperref}
\usepackage{listings}
\usepackage{mathtools}
\usepackage{graphicx}
\usepackage{parskip}
\usepackage{ragged2e}
\usepackage{setspace}
\usepackage{subcaption}
\usepackage[usenames, dvipsnames]{xcolor}
\usepackage[utf8]{inputenc}     % Support for french language
\usepackage{newtxtext,newtxmath}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}     % Support for french language
\usepackage{tikz}
\usetikzlibrary{arrows.meta,
                babel,
                calc,
                decorations.markings,
                positioning, 
                shapes}

\usepackage{standalone}


% Set up Section
%===============

% Page configuration
\pagestyle{fancyplain}
\fancyhf{}
\fancyhead[R]{\thepage}
% \rfoot{\thepage}

% Remove the header line
\renewcommand{\headrulewidth}{0pt}

% Setup subsection format
\renewcommand\thesubsubsection{\arabic{section}.\arabic{subsection}}

% Setup enumeration
\renewcommand{\labelenumi}{\alph{enumi})}

% Listing configuration
\definecolor{light-gray}{gray}{0.75}

\newcommand{\me}[1]{\mathrm{\emph{e}}^{#1}}
\newcommand{\jcplx}[0]{\mathrm{\emph{j}}}

% Setup listings
\lstset {
    language=Python,
    frame=single,
    backgroundcolor=\color{light-gray},
    breaklines=true,
    basicstyle=\tiny\ttfamily,
    keywordstyle=\bfseries\color{blue!40!black},
    commentstyle=\itshape\color{green!40!black},
    identifierstyle=\color{blue},
    stringstyle=\color{red},
    showstringspaces=false,
    captionpos=t
}

% Text Section
%=============

\DeclareMathOperator{\sign}{sgn}
\begin{document}


    \tableofcontents
    \thispagestyle{empty}
    \listoffigures
    \thispagestyle{empty}

    \newpage
    \onehalfspacing

    \begin{thebibliography}{9}
        \bibitem{svm}
        Prediction Stock Price Direction using Support Vector Machines
        \\\url{https://www.cs.princeton.edu/sites/default/files/uploads/saahil_madge.pdf}

    \end{thebibliography}
\end{document}

Any comment or suggestion is welcome. Thank you in advance.

1

1 Answer 1

2

The top of the text area is given by 1in+\topmargin+\headheight+\headsep and is set by geometry to 1.5in. This solution retains the default \headheight and puts a 2cm gap above the header. The showframe option is for demonstration purposes only.

I threw out all the irrelevant stuff.

\documentclass[12pt]{report}
\usepackage[total={8.5in,11in}, headsep={\dimexpr 1.5in-2cm-\headheight}, 
  left = 1.5in, right = 0.75in, top=1.5in, bottom = 0.75in,
  showframe]{geometry}
\usepackage{fancyhdr}
% Page configuration
\fancypagestyle{plain}{%
  \fancyhf{}%
  \rhead{\thepage\hspace{\dimexpr 2.5cm-0.75in}}%
}
% Remove the header line
\renewcommand{\headrulewidth}{0pt}
\pagestyle{plain}

\usepackage{lipsum}%MWE only

\begin{document}
\lipsum[1-8]
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .