如何将同一张图片放在某一部分的每一页的最顶部

如何将同一张图片放在某一部分的每一页的最顶部

我想在属于相同的文档的部分。这可能吗?

参见下面的示例,其中图形是 PNG 图形:

\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{graphicx}
\usepackage{babel}
\begin{document}

\section*{Section A}

\includegraphics{fig1}

A lot of contents spanning several pages. 

I would like to have the figure above repeated at the top of each page 
of Section A.

\section*{Section B}

\includegraphics{fig2}

A lot of contents spanning several pages. 

I would like to have the figure above repeated at the top of each page 
of Section B.

\end{document}

补充

我尝试了一种不同的方法,即使用fancyhdr包。(请参见下面的代码。)但是,我遇到了下面显示的问题。有什么想法吗?

问题 1

在文件的第一页上。

问题 2

当返回到普通样式时:

在此处输入图片描述

使用过的图片

在此处输入图片描述

我正在使用的代码

\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{graphicx}

\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\usepackage{lipsum}

\fancypagestyle{logo}{
\fancyhf{}
\fancyhead[H]{\includegraphics[scale=0.5]{/tmp/x}}
\renewcommand{\headrulewidth}{0pt}
}

\makeatother

\usepackage{babel}
\begin{document}
\pagestyle{logo}

\lipsum[1-8]

\includegraphics[scale=0.5]{/tmp/x}

\pagestyle{plain}

\lipsum[1-7]
\end{document}

答案1

好的,我一直在尝试这个,它只是一个非常最小/基本的解决方案。版本 1(请参阅 V2 和 V3 的后续编辑 :-)

我不得不从几个答案中借用一些片段来获得足够稳定的结果,但是在版本 1(基于章节编号)中,我打破了您提供的一个要求(章节/章节定义中没有数字星号)

我正在处理的每个部分都有一个数字(可能并非总是如此),这与您的将其抑制为零相反。

我不允许这样使用右侧或左侧(我假设只有右上角),如果您希望某个部分为空白,则需要该部分的清晰/空白图像。(但是这些问题在版本 2 中会得到解决)

在此处输入图片描述

\documentclass[english,draft]{article}% use draft to observe numbering then remove for print run
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{graphicx}
\usepackage{babel}

\usepackage{calc}
\usepackage{everypage}
\renewcommand{\thesection}{\number\value{section}}%
\newlength\Hoffset \Hoffset 0.0cm
\newlength\Voffset \Voffset 0.5cm
\AddEverypageHook{%
    \smash{\hspace{\oddsidemargin}\hspace{\textwidth}\hspace{\Hoffset}%
    \raisebox{\Voffset-\headsep-\headheight-\topmargin}%
    {%
    \includegraphics[height=3cm,width=4cm]{example\thesection}
    }         }             }

\usepackage{lipsum} %remove after demo

\begin{document}

\section{Section A}% NOTe the star version will zero chapter counter thus blocking an image number

\includegraphics[width=12cm,height=9cm]{example\thesection}

A lot of contents spanning several pages. 
\newline
I would like to have the figure above repeated at the top of each page 
of Section A.
\lipsum[1-7]

\newpage % newpage is needed to split count from old section to new section
\section{Section B}
\includegraphics[width=12cm,height=9cm]{example\thesection}

A lot of contents spanning several pages. 

I would like to have the figure above repeated at the top of each page 
of Section B.
\lipsum[1-6]
\end{document}

版本 2

问题已扩展,包括一些标题的开/关控制,我对最初与部分编号的绑定(可能会被隐藏)并不满意。对于版本 2,我根据修改后的问题使用了花哨的标题。但请注意,这种方法仍然存在一些弱点。

我已强制将正常的花式和普通页眉设置为相同,但系统仍会将章节页面(和一些其他页面)视为不同,因此通过这种方法,我无法将徽标分配给章节的第一页(如果它具有完整的图像并且后面的页面只是回显它,则不是问题。)我们可以通过更多的方式扩展我们的使用,fancyhdr但是由于我们正在扭曲正常用法,因此下一个级别的定制最好是通过使用专用的开关标记切换到每页更专用的覆盖来实现。

在此处输入图片描述

\documentclass[english]{book} % I suspect LyX may be adding to and shuffling this preamble I set to book to show dual sided  abilities
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{graphicx}

%--- just for the examples
\usepackage{mwe}
\usepackage{lipsum}
%---

\usepackage{fancyhdr,floatpag}
% globally remove fancy style rules since \pagestyle{plain} for chapters etc. = no header, and footer only contains page number centered
% set fancy to be similar default just have the page number
\fancyhf{}
\fancyfoot[C]{\textbf{\thepage}} % common method to use simple Bottom centre page numbers
\renewcommand{\headrulewidth}{0pt}% common method to blank (zero) the top header rule
\renewcommand{\footrulewidth}{0pt}

\fancypagestyle{plain}{%
\fancyhf{} % clear all header and footer fields
\fancyfoot[C]{\textbf{\thepage}} % except the center
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}}

\floatpagestyle{plain}% Page style for float-pages
%\usepackage[style=plain]{clrdblpg} this option will ensure verso pages are also plain

\fancypagestyle{logo}{%change LO,RE v RO,LE for opposite side or just C for centre
\fancyhf{}
\fancyhead[RO,LE]{\smash{\raisebox{0cm}{\includegraphics[scale=0.2]{x}}}}
\fancyfoot[C]{\textbf{\thepage}} % except the center
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}}

%the following is a lyx construct so although not used I am leaving in place
\makeatletter 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\makeatother

\begin{document}
\pagenumbering{arabic} % reset page number counter
\thispagestyle{logo}
\chapter{One}
\pagestyle{logo} %  If you want a fancy layout on a page containing \maketitle you must issue a \thispagestyle{fancy} after the \maketitle.
%\pagestyle{plain} % uncoment to reset
%
\lipsum[1-9]
\section{first still with logo}
\noindent\includegraphics[width=1.0\textwidth]{x.jpg}\newline\par\lipsum[10-12]
%
\newpage \pagestyle {plain} % if header style change is required it can usually be combined with \newpage at the same time
%\pagestyle{plain}
\section {without header image}
\noindent\begin{figure}[t]
  \centering
  \includegraphics[width=1.0\textwidth]{x.jpg}%
  \caption{Caption}
\end{figure}
Page style ``Plain'' default usually has only page number at bottom centre but no header.\newline\par
\lipsum[1-7]

\end{document}  

版本 3 - 与章节无关(使用当前页面作为开始停止)

这是基于非常基本的 Bg NoBg 应用水印的众多方法之一(可以使用更复杂的方法来选择页面),因此对于更具体的控制选择,请阅读background
在此示例中,我排除了第一页和最后一页上的“徽标”,并在所有其他页面上使用 50% 的不透明度。

在此处输入图片描述

\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{fancyhdr}
\usepackage{graphicx}

\usepackage[ %<===== Add to preamble
placement=top,
opacity=0.5]{background}
\backgroundsetup{contents={\includegraphics[scale=0.04]{./tmp/x}}}

\makeatletter %<=====  Not needed here by TeX but as a LyX construct I am retaining for LyX users
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\makeatother %<=====  Not needed here by TeX but as a LyX construct I am retaining for LyX users

\usepackage{babel}

\pagestyle{fancy}% Change as you wish
\renewcommand{\headrulewidth}{0pt}
\fancypagestyle{plain}{ % Change as you wish
\fancyhf{}
\fancyfoot[C]{\thepage}
\renewcommand{\headrulewidth}{0pt}
}

% for example use only
\usepackage{lipsum}

\begin{document}
\pagestyle{plain}
\NoBgThispage
Hello World my name is X

\noindent\includegraphics[scale=0.7]{./tmp/x}
\lipsum[1-8]
\BgThispage % we start logo on this page
\lipsum[1-7]
\NoBgThispage % we end logo this page
\end{document}

相关内容