在页面顶部设置页码

在页面顶部设置页码

我想将页码设置在页面顶部。我用过,\usepackage{fancyhdr}但出现了两个问题。第一个问题是我的论文第一页(实际上是目录的第一页)仍然有一个页码在底部。第二个问题是新的页码与每页的文本冲突,我希望新的页码放在顶部边距,就像截图中那样 在此处输入图片描述

如果有人了解我的问题,我请他帮助我。我正在使用以下内容:

\documentclass[12pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{geometry}
\usepackage[svgnames]{xcolor}
\geometry{footskip=15pt}
\usepackage{amsmath}
\numberwithin{equation}{subsection}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{graphicx}
\usepackage{fullpage}
\usepackage[utf8]{inputenc}
\renewcommand{\qedsymbol}{\rule{0.5em}{0.5em}}
\usepackage{enumitem}
\interdisplaylinepenalty=100
\usepackage{mathtools}
\DeclareMathOperator{\sgn}{sgn}
\usepackage{pgfplots}
\usepackage{tikz}
\usepackage{hyperref}
   \hypersetup{
    colorlinks=true,
    linkcolor=blue,
    filecolor=magenta,      
    urlcolor=red,
      }
   \newcommand*{\at}{@}
\usepackage[nottoc]{tocbibind}
   \newlength{\bibitemsep}\setlength{\bibitemsep}{.05\baselineskip plus  .05\baselineskip minus .05\baselineskip}
   \newlength{\bibparskip}\setlength{\bibparskip}{0pt}
   \let\oldthebibliography\thebibliography
   \renewcommand\thebibliography[1]{%
    \oldthebibliography{#1}%
     \setlength{\parskip}{\bibitemsep}%
     \setlength{\itemsep}{\bibparskip}%
      }
   \newcommand{\comment}[1]{%
    \text{\phantom{(#1)}} \tag{#1} 
    } % to tag equations

\usepackage{tocloft}
   \setlength{\cftsecnumwidth}{2em}
   \setlength{\cftsubsecnumwidth}{3em}
   \setlength{\cftsubsubsecnumwidth}{4em}


   % to center the part name 
   \renewcommand\cftpartpresnum{\hfill}
   \renewcommand\cftpartleader{\hfill}
\usepackage{capt-of}

   % to appear the word "part"

\usepackage{booktabs}

   \newcommand{\overbar}[1]{\mkern 1.5mu\overline{\mkern-1.5mu#1\mkern-1.5mu}\mkern 1.5mu}

\usepackage{verbatim}

\usepackage{mathrsfs}

\usepackage{fancyhdr}
    \pagestyle{fancy}
    \fancyhf{}
    \fancyhead[R]{\thepage}  

\begin{document}
 \tableofcontents
 My Text  
\end{document}

答案1

就是这个。我稍微重新组织了一下你的序言,删除了fullpage,用合适的参数替换了geometry。目录页底部的页码的原因是,对于此页面,plain应用了页面样式,所以我重新定义了它。

\documentclass[12pt, a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[margin=1in]{geometry}
\geometry{footskip=15pt, headheight=15pt}
\usepackage[svgnames]{xcolor}
\usepackage{mathtools}
\numberwithin{equation}{subsection}
\usepackage{amsfonts, amssymb, mathrsfs}
\usepackage{amsthm}
\renewcommand{\qedsymbol}{\rule{0.5em}{0.5em}}
\usepackage{graphicx}
\usepackage{enumitem}
\interdisplaylinepenalty=100
\DeclareMathOperator{\sgn}{sgn}
\usepackage{pgfplots}
   \newcommand*{\at}{@}

\usepackage[nottoc]{tocbibind}
   \newlength{\bibitemsep}\setlength{\bibitemsep}{.05\baselineskip plus .05\baselineskip minus .05\baselineskip}
   \newlength{\bibparskip}\setlength{\bibparskip}{0pt}
   \let\oldthebibliography\thebibliography
   \renewcommand\thebibliography[1]{%
    \oldthebibliography{#1}%
     \setlength{\parskip}{\bibitemsep}%
     \setlength{\itemsep}{\bibparskip}%
      }
   \newcommand{\comment}[1]{%
    \text{\phantom{(#1)}} \tag{#1}
    } % to tag equations

\usepackage{tocloft}
   \setlength{\cftsecnumwidth}{2em}
   \setlength{\cftsubsecnumwidth}{3em}
   \setlength{\cftsubsubsecnumwidth}{4em}

   % to center the part name
   \renewcommand\cftpartpresnum{\hfill}
   \renewcommand\cftpartleader{\hfill}

   \usepackage{caption}

   % to appear the word "part"

\usepackage{booktabs}

   \newcommand{\overbar}[1]{\mkern 1.5mu\overline{\mkern-1.5mu#1\mkern-1.5mu}\mkern 1.5mu}

\usepackage{verbatim}

\usepackage{fancyhdr}
    \pagestyle{fancy}
    \fancyhf{}
    \fancyhead[R]{\thepage}
\fancypagestyle{plain}{%
\fancyhf{} % clear all header and footer fields
\fancyhead[R]{\thepage} % except the center
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}}

\usepackage{hyperref}
   \hypersetup{
    colorlinks=true,
    linkcolor=blue,
    filecolor=magenta,
    urlcolor=red,
      }
\usepackage{lipsum}

\begin{document}
 \tableofcontents
% \thispagestyle{fancy}
\section{First section}
 \lipsum
 \section{A second section}
 \lipsum

\end{document} 

在此处输入图片描述

相关内容