如何将图像放置在每个页面的顶部/底部边框?

如何将图像放置在每个页面的顶部/底部边框?

这个问题与答案相关https://tex.stackexchange.com/a/235607/。解决方案是,将给定的图像放在第一页的顶部边框。

如何将该图像放在每一个页?

\documentclass[10pt,a4paper]{report}
\usepackage[utf8]{inputenc}
%% Graphics
\usepackage{graphicx}
\usepackage{everypage}
\usepackage{lipsum}
% THESE ARE LaTeX DEFAULTS; CAN CHANGE IF NEEDED.
\def\PageTopMargin{1in}
\def\PageLeftMargin{1in}
\newcommand\atxy[3]{%
 \AddThispageHook{\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{0in}{0in}{\raisebox{-\height}{\includegraphics[width=\paperwidth]{someimage.jpg}}}
\begin{document}
%% Titlepage
\vspace*{.2in}
\lipsum[1]
\newpage
\lipsum[1]
\end{document}

答案1

正如我在评论中所说,将定义中的\AddThispageHook改为。此外,我删除了第 1 页上的 ,而是将其添加到序言中。\AddEverypageHook\atxy\vspace\usepackage[top=160pt]{geometry}

\documentclass[10pt,a4paper]{report}
\usepackage[utf8]{inputenc}
%% Graphics
\usepackage[top=160pt]{geometry}
\usepackage{graphicx}
\usepackage{everypage}
\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{0in}{0in}{\raisebox{-\height}{\includegraphics[width=\paperwidth,
  height=140pt]{example-image}}}
\begin{document}
%% Titlepage
\lipsum[1]
\newpage
\lipsum[2]
\end{document}

在此处输入图片描述

相关内容