如何让这个页眉出现在每一页上?

如何让这个页眉出现在每一页上?

我想要数字 510000000 出现在每一页的右上角,我该使用什么命令?提前谢谢您。

    \documentclass[10pt,a4paper]{report}
\usepackage[utf8]{inputenc}
%% Graphics
\usepackage{graphicx}
\usepackage{everypage}
\usepackage{lipsum}

\usepackage{pdfpages}
\usepackage{eso-pic}
\usepackage{lipsum}

\AddToShipoutPictureBG*{%
  \AddEverypageHook
  \AtPageUpperLeft{%
    \hspace{\paperwidth}%
    \raisebox{-\baselineskip}{%
      \makebox[0pt][r]{510000000}
     }}}%

% THESE ARE LaTeX DEFAULTS; CAN CHANGE IF NEEDED.
\def\PageTopMargin{1in}
\def\PageLeftMargin{1in}
\newcommand\atxy[3]{%
 \AddEverypageHook{\smash{\hspace*{\dimexpr-\PageLeftMargin-\hoffset+#1\relax}%
  \raisebox{\dimexpr\PageTopMargin+\voffset-#2\relax}{#3}}}}
% VERIFIED THAT SETTING \hoffset AND \voffset DO NOT BREAK SOLUTION.
%\hoffset=0.4in
%\voffset=0.2in
\atxy{0.1in}{0.1in}{\raisebox{-\height}{\includegraphics[height=0.53in]{logo.jpg}
}}
\begin{document}
%% Titlepage
\vspace*{.2in}
\lipsum[1]
\includepdf{Plagiarism.pdf}

\title{Lab Report}

\end{document}

答案1

使用fancyhdr

\documentclass{article}
\usepackage{fancyhdr}
\renewcommand\headrulewidth{0pt}
\rhead{510000000}
\pagestyle{fancy}
\begin{document}
foo
\end{document}

在此处输入图片描述

答案2

我以两种方式更改了您的文档。我将参数 #3\includegraphics中的替换\atxy为文本,并将第一个参数的值增加为\atxy(值为\dimexpr\paperwidth-.7in),以将块向右移动。

\documentclass[10pt,a4paper]{report}
\usepackage[utf8]{inputenc}
%% Graphics
\usepackage{graphicx}
\usepackage{everypage}
\usepackage{lipsum}

\usepackage{pdfpages}
\usepackage{eso-pic}
\usepackage{lipsum}

% THESE ARE LaTeX DEFAULTS; CAN CHANGE IF NEEDED.
\def\PageTopMargin{1in}
\def\PageLeftMargin{1in}
\newcommand\atxy[3]{%
 \AddEverypageHook{\smash{\hspace*{\dimexpr-\PageLeftMargin-\hoffset+#1\relax}%
  \raisebox{\dimexpr\PageTopMargin+\voffset-#2\relax}{#3}}}}
% VERIFIED THAT SETTING \hoffset AND \voffset DO NOT BREAK SOLUTION.
%\hoffset=0.4in
%\voffset=0.2in
\atxy{\dimexpr\paperwidth-1.5in}{0.1in}{\raisebox{-\height}{\Huge510000000}}
\begin{document}
\lipsum[1]
\end{document}

在此处输入图片描述

相关内容