我最近开始使用这些koma-script
课程,但我在从 过渡到fancyhdr
时遇到了麻烦scrlayer-scrpage
。我想在右侧放置一个徽标,在左侧放置一个标记。但是,scrlayer-scrpage
垂直对齐并不像预期的那样。这是我迄今为止尝试过的方法
\documentclass[headsepline]{scrreprt}
\usepackage{graphicx}
\usepackage{blindtext}
\usepackage[hmargin=2.5cm, vmargin=2.5cm, headheight=40pt] {geometry}
%----------This does not work as expected------------
\usepackage[automark]{scrlayer-scrpage}
\clearpairofpagestyles
\ihead{\headmark}
\ohead{\includegraphics[height=12mm]{example-image-a}}
\cfoot*{\pagemark}
%---------This is what i want------------------------
%\usepackage{fancyhdr}
%\pagestyle{fancy}
%\lhead{\leftmark}
%\rhead{\includegraphics[height=12mm]{example-image-a}}
%\cfoot{\thepage}
%\renewcommand{\headrulewidth}{1.2pt}
\begin{document}
\blinddocument
\end{document}
的输出scrlayer-scrpage
输出使用fancyhdr
如果不添加图像\ohead
,标记的行为与fancyhdr
解决方案中的行为相同。不知何故,添加图像会改变对齐方式。
我如何更改代码以垂直对齐底部的标记headsepline
?
答案1
您可以隐藏图像的高度:
\ohead{\smash{\includegraphics[height=12mm]{example-image-a}}}
例子:
\documentclass[headsepline]{scrreprt}
\usepackage{graphicx}
\usepackage{blindtext}
\usepackage[hmargin=2.5cm, vmargin=2.5cm, headheight=40pt] {geometry}
\usepackage[automark]{scrlayer-scrpage}
\clearpairofpagestyles
\ihead{\headmark}
\ohead{\smash{\includegraphics[height=12mm]{example-image-a}}}
\cfoot*{\pagemark}
\begin{document}
\blinddocument
\end{document}
或者使用大写的页眉并改变页眉线的宽度:
\documentclass[headsepline]{scrreprt}
\usepackage{graphicx}
\usepackage{blindtext}
\usepackage[hmargin=2.5cm, vmargin=2.5cm, headheight=40pt] {geometry}
\usepackage[
automark,
markcase=upper,
headsepline=1.2pt
]{scrlayer-scrpage}
\addtokomafont{pageheadfoot}{\upshape}
\renewcommand*{\chaptermarkformat}{\chaptername~\thechapter\autodot~~}
\clearpairofpagestyles
\ihead{\headmark}
\ohead{\smash{\includegraphics[height=12mm]{example-image-a}}}
\cfoot*{\pagemark}
\begin{document}
\blinddocument
\end{document}