我想知道是否有办法让页眉中的图像与页眉底部的水平线重叠?我在页眉中放了我公司的徽标,在页眉中放了一些文字。
我本质上是想增加徽标的尺寸,使其与水平线重叠,但不会移动水平线。
感谢任何反馈/评论/答案!
这就是我想要的,红色框是徽标:
另外,这里是 fancyhdr 的序言部分:
\pagestyle{fancy}
\fancyhf{}
\setlength\headheight{52.6363pt}
\lhead{\textcolor{blue}{Company \\ Product}}
\rhead{\includegraphics[width=2cm]{img-src/logo}}
\lfoot{\textcolor{blue}{Company}}
\rfoot{\textcolor{blue}{\thepage}}
\renewcommand{\footrulewidth}{0.4pt}
答案1
不幸的是,这条线划在了标题上:
\documentclass{article}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\setlength\headheight{52.6363pt}
\lhead{\textcolor{blue}{Company \\ Product}}
\rhead{\raisebox{\dimexpr \baselineskip-\headsep}[0pt][0pt]{\includegraphics[width=2cm]{example-image}}}
\lfoot{\textcolor{blue}{Company}}
\rfoot{\textcolor{blue}{\thepage}}
\renewcommand{\footrulewidth}{0.4pt}
\usepackage{lipsum}% random text
\begin{document}
\lipsum[1-4]
\end{document}
此版本用于\AddToHook
单独绘制图像。
\documentclass{article}
\usepackage{xcolor}
\usepackage{graphicx}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\setlength\headheight{52.6363pt}
\lhead{\textcolor{blue}{Company \\ Product}}
\lfoot{\textcolor{blue}{Company}}
\rfoot{\textcolor{blue}{\thepage}}
\renewcommand{\footrulewidth}{0.4pt}
\AddToHook{shipout/foreground}{\ifodd\value{page}\relax
\put({\dimexpr 1in+\oddsidemargin+\textwidth},{\dimexpr -1in-\topmargin-\headheight+\baselineskip-\headsep})
{\llap{\includegraphics[width=2cm]{example-image}}}
\else
\put({\dimexpr 1in+\evensidemargin+\textwidth},{\dimexpr -1in-\topmargin-\headheight+\baselineskip-\headsep})
{\llap{\includegraphics[width=2cm]{example-image}}}
\fi}
\usepackage{lipsum}% random text
\begin{document}
\lipsum[1-4]
\end{document}