我制作了一个讲座摘要模板,但它表现得有点奇怪。这是平均能量损失
\documentclass[12pt]{extarticle}
\newcommand{\theme}{Theme}
\usepackage[utf8]{inputenc}
\usepackage[T2A]{fontenc}
\usepackage[english]{babel} % main language is the last one
\usepackage[a4paper]{geometry}
\geometry{top=25mm}
\geometry{bottom=25mm}
\geometry{left=20mm}
\geometry{right=20mm}
\usepackage{setspace}
\linespread{1,2}
\usepackage{fancyhdr}
\usepackage{hyperref}
\pagestyle{fancy}
\fancyhead[L,C]{}
\fancyhead[L]{\textbf{\theme}}
\fancyhead[R]{\includegraphics[scale=0.1]{example-image}}
\fancyfoot[C]{\thepage}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0pt}
\usepackage{lipsum}
\usepackage{background}
\definecolor{shkolkovoBlue}{RGB}{2,140, 214}
\hypersetup{
pdftitle = {\theme},
pdfauthor = me,
urlbordercolor = 1 1 1
}
\newcommand{\makeCustomHeader}{
\thispagestyle{plain}
\begin{flushleft}
Some text \\
Some text as well
\end{flushleft}
\begin{flushright}\vspace{-22mm}
\includegraphics[height=2cm]{example-image}
\end{flushright}
\begin{center}\vspace{-0.2cm}
\textbf{ \large \theme}
\end{center}
\begin{center}\vspace{-5mm}
\rule{\linewidth}{0.1mm}
\end{center}
\begin{flushright}
\color{shkolkovoBlue}{\underbar{Found a mistake?}}
\end{flushright}
}
\backgroundsetup{
scale=1.5,
angle=0,
opacity=0.2,
contents={
\begin{tikzpicture}
\node at ([xshift=0pt, yshift=0pt] current page.center){\includegraphics{example-image}};
\end{tikzpicture}
}}
\begin{document}
\makeCustomHeader
\lipsum[1-200]
\end{document}
但是当我删除文本时\lipsum[1-200]
,我的页眉会稍微变宽(如果你在第一页的末尾放置图像,则会更加明显)
所以我的问题是 - 发生这种情况的原因可能是什么?乳胶文档中元素之间的间距不是严格确定的吗?
答案1
如果您添加了lipsum
文本(或任何其他文本),LaTeX 会尝试在页面上容纳整数行文本。为了适应这一点,它会稍微挤压或拉伸页眉。这是因为页眉前后的垂直空间flushright
具有flushleft
一定center
的灵活性。
您可以将标题放入 内来防止这种挤压\parbox
。
\newcommand{\makeCustomHeader}{%
\thispagestyle{plain}%
\noindent\parbox{\textwidth}{\begin{flushleft}
Some text \\
Some text as well
\end{flushleft}
\begin{flushright}\vspace{-22mm}
\includegraphics[height=2cm]{example-image}
\end{flushright}
\begin{center}\vspace{-0.2cm}
\textbf{ \large \theme}
\end{center}
\begin{center}\vspace{-5mm}
\rule{\linewidth}{0.1mm}
\end{center}
\begin{flushright}
\color{shkolkovoBlue}{\underbar{Found a mistake?}}
\end{flushright}}
}