为了在页眉中添加图像,我编写了代码,基本上是页面样式修改。现在,只是为了试验,我首先只修改了我的plain
页面样式。将图像插入页眉后,我得到了一条水平线,我该如何删除它?
以下是 MWE:
\documentclass[12pt]{book}
\usepackage{lipsum}
\usepackage{wallpaper}
\usepackage{fancyhdr}
\fancypagestyle{plain}{
\fancyhf{}
\fancyhead[C]{\includegraphics[scale=.25]{example-image-a}}
}
\begin{document}
\chapter{A Chapter}
\lipsum[4]
\section{blah blah blah}
\end{document}
答案1
您必须声明您想要一个没有宽度的标题行:
\renewcommand{\headrulewidth}{0pt}
梅威瑟:
\documentclass[12pt]{book}
\usepackage{lipsum}
\usepackage{wallpaper}
\usepackage{fancyhdr}
\fancypagestyle{plain}{
\fancyhf{}
\fancyhead[C]{\includegraphics[scale=.25]{example-image-a}}
\renewcommand{\headrulewidth}{0pt}
}
\begin{document}
\chapter{A Chapter}
\lipsum[4]
\section{blah blah blah}
\end{document}
输出:
答案2
虽然 Karl 直截了当地回答了你的问题,但这只是tikz
在短短几页内放一些背景材料的另一个疯狂选择:
\documentclass[12pt]{book}
\usepackage{lipsum}
\usepackage{background}
\usetikzlibrary{calc}
\usepackage{tikzpagenodes}
\backgroundsetup{
pages=some,
scale=1,
opacity=1,
angle=0,
color=black,
contents={%
\begin{tikzpicture}[remember picture,overlay]
\node[draw=green!50!blue,thick,fill=orange!30,rounded corners=1ex] at ($(current page text area.north) + (0,0in)$) {\includegraphics[scale=.25]{example-image-a}};
\end{tikzpicture}%
}
}
\begin{document}
\chapter{A Chapter}
\BgThispage
\lipsum[4]
\section{blah blah blah}
\end{document}
上述代码片段的另一种变体是
\backgroundsetup{
pages=some,
scale=1,
opacity=1,
angle=0,
color=black,
position={0.55\textwidth,-0.1\textheight}, %%% this and
contents={%
\includegraphics[scale=.25]{example-image-a} %%% this also would work
}
}
在这种情况下,你不需要
\usetikzlibrary{calc}
\usepackage{tikzpagenodes}