我想在双面文档(左侧和右侧)的所有页面的页眉中包含一个带有徽标的图形文件。徽标应在左侧左对齐,在右侧右对齐。页眉行和文档标题应从徽标旁边开始。有两个问题:
- 将标题行和文档标题的开头稍微向右(左侧)和向左(右侧)移动,为徽标留出空间
- 包括徽标
你有什么建议吗?这是我的代码:
\documentclass[
12pt,
a4paper,
twoside,
headinclude,
headsepline,
BCOR12mm,
DIV12,
openright,
bibliography=totoc,
listof=totoc,
numbers=noenddot,
fleqn,
]{scrbook}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman, english]{babel}
\usepackage{lipsum}
\usepackage{xcolor}
\definecolor{grey} {RGB} {132,130,132}
\usepackage{scrpage2}
\setkomafont{pageheadfoot}{\color{grey}{\normalfont\sffamily}}
\setkomafont{pagenumber}{\color{grey}{\normalfont\sffamily}}
\setheadsepline{1pt}[\color{grey}]
\clearscrheadfoot
\pagestyle{scrheadings}
\rehead[ ]{Document title}
\lohead[ ]{Document title}
\lehead[ ]{\headmark}
\rohead[ ]{\headmark}
\refoot[\pagemark]{\pagemark}
\lofoot[\pagemark]{\pagemark}
\begin{document}
\section{section title}
\lipsum[1-9]
\end{document}
感谢您的评论和回答。我已经尝试了上述解决方案(仅包括图形),但对结果不满意,因为:
- 该线路也位于徽标下方
- 文档标题和章节标题的高度不同
这次我附上了一份布局草稿(布局中的图片是徽标的替代品)。最终徽标的尺寸为:高度=15 毫米,宽度=20 毫米(或 79x61 像素)。
文档标题为“Yaacomo”。页眉中不应有文本,徽标下也不应有线条。
答案1
第一次尝试可以包含graphicx
宏包\includegraphics
并将标题的配置更改为:
\usepackage{graphicx} % for macro \includegraphics
\rehead[ ]{Document title \includegraphics[height=8mm]{example-image-A.jpg}}
\lohead[ ]{\includegraphics[height=8mm]{example-image-A.jpg} Document title}
顺便说一句:example-image-A.jpg
是包裹的一部分MWE
,对于构建 MWE 非常有用......
答案2
我的解决方案:
graphicx
我添加了用于包含图像的包,calc
以便能够进行一些计算,并adjustbox
添加一些必要的边距,因为否则头线会接触到徽标。
我定义了一些长度;请参见下文%Logo
,也许您想更改它们。这也是您实际徽标的位置。
头部本身现在只在\cehead
resp. \cohead
。因此可以确保一切都在同一条线上。
总而言之,该软件包blindtext
仅适用于盲文(\Blinddocument
此处):
\documentclass[
paper=a4, % it's the default anyway
fontsize=12pt,
twoside,
headinclude,
headsepline,
BCOR=12mm,
DIV=12,
openright,
bibliography=totoc,
listof=totoc,
numbers=noenddot,
fleqn,
]{scrbook}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman, english]{babel}
\usepackage{blindtext} % provides blindtext with sectioning
\usepackage{calc} % for some calculation
\usepackage{xcolor}
\definecolor{grey} {RGB} {132,130,132}
\usepackage{graphicx}% for loading images
\usepackage[calc]{adjustbox} % we need some margin around the logo, for option see manual
% Logo
\newlength{\logoheight}\setlength{\logoheight}{15mm} % Adjust height of logo here
\newlength{\logowidth}\setlength{\logowidth}{20mm} % Adjust width of logo here
\newcommand*{\logo}{\raisebox{-5pt}% The bigger the amount of the negative number the more the header is raised!
{\includegraphics[height=\logoheight,width=\logowidth]{example-image-4x3.png}}}
\newlength{\extramargin}\setlength{\extramargin}{5pt} % Change to your needs
\setlength{\headheight}{\logoheight}
% This won't work (!!!):
%%% \KOMAoptions{headheight=\logoheight}
\usepackage{scrpage2}
\setkomafont{pageheadfoot}{\color{grey}{\normalfont\sffamily}}
\setkomafont{pagenumber}{\color{grey}{\normalfont\sffamily}}
\setheadsepline{1pt}[\color{grey}]
\setheadwidth[\logowidth+\extramargin]{\textwidth-\logowidth-\extramargin} % for calculation "calc" is needed
\clearscrheadfoot
\pagestyle{scrheadings}
%\rehead[]{Yaacomo}
\cehead[]{\headmark\hfill Yaacomo \rlap{\adjustbox{margin={\extramargin} 0pt 0pt 0pt}{\logo}}}
%\lohead[]{Yaacomo}
\cohead[]{\llap{\adjustbox{margin=0pt 0pt {\extramargin} 0pt}{\logo}}\ Yaacomo\hfill\headmark}
%\lehead[]{\headmark}
%\rohead[]{\headmark}
\refoot[\pagemark]{\pagemark}
\lofoot[\pagemark]{\pagemark}
\begin{document}
\Blinddocument
\end{document}