我想调整 TEX 文件中的页码位置:我尝试过这个 邮政,但这对我来说不起作用。事实上,我想将位置设置在页面的右上角(垂直 2 厘米,水平 2.5 厘米)。这是我的代码:
\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}
欢迎提出任何意见或建议。提前谢谢您。
答案1
文本区域的顶部由 geometry 给出1in+\topmargin+\headheight+\headsep
并设置为 1.5 英寸。此解决方案保留默认值\headheight
,并在标题上方留出 2 厘米的间隙。showframe 选项仅用于演示目的。
我把所有不相关的东西都扔掉了。
\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}