花式页眉或页脚内的行间距(调整字体大小后)

花式页眉或页脚内的行间距(调整字体大小后)

大约 1 个月前,我在这里询问了有关行间空格的问题,并了解到当字体大小发生变化时在段落末尾插入 \par 的重要性。这帮助我理解了几个问题。

今天,我有一个关于花式页脚(或页眉)中相同问题的后续问题。我试图匹配我们用于文具的 MS Word 文档的输出。在该 Word 文档中,页脚中的字体较小,单倍行距很紧。

当我尝试在 LaTeX 中执行相同操作时,我能够将字体变小,但行距仍然很大。我测量过,即使我将字体调小,行距也不会在花哨的页脚内缩小。

如果我在页脚中用 \par 结束一行,则会出现编译器错误,提示有一个空白行,而这个空白行不应该存在。

在下面的代码中,我很确定我明白哪里出了问题。通过在两行中使用 \footnotesize,我没有给 LaTeX 任何关于需要缩小行大小的信息。如何重新设计,使最后两行之间的间距更小

这是 MRE:

\documentclass[english]{article}
\usepackage{lmodern}
\renewcommand{\sfdefault}{lmss}
\renewcommand{\ttdefault}{lmtt}
\renewcommand{\familydefault}{\rmdefault}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[letterpaper]{geometry}
\geometry{verbose,tmargin=1in,bmargin=2in,lmargin=1.5in,rmargin=1in}
\setlength{\parskip}{\smallskipamount}
\setlength{\parindent}{0pt}
\usepackage{setspace}

\makeatletter
\usepackage{fancyhdr}
\usepackage{graphicx}
\headheight=70pt
\marginparwidth=0pt
\footskip=30pt

\usepackage{ifthen}
\usepackage{lastpage}
\usepackage[hidelinks, unicode=true]{hyperref}

\renewcommand{\headrulewidth}{0pt}
\fancyhead{}
\fancyfoot{}

\fancyhead[L]{
\ifthenelse{\value{page}=1}{\hspace*{-1in}IMAGINE A BEAUTIFUL LOGO HERE}
}
\fancyfoot[L]{
\ifthenelse{\value{page}=1}{\textsf{\textbf{The Name of My Center}}\\
\textsf{\footnotesize{}Knowledge Hall Room 1 | 1234 Your Alley | Pretend, ST 66666}\\
\textsf{\footnotesize{}(123)456-1234 | \url{http://google.edu} | email: [email protected]}}
{\centering{Page  \thepage \hspace{1pt} of \pageref{LastPage}}}
}

\makeatother

\usepackage{babel}
\begin{document}
\thispagestyle{fancy}

\begin{singlespace}
Joseph Pretend Name\\
Chair, Geography\\
Unreal Dominion University\\
3423 Space Age Bldg.\\
Canada, UK 22348\smallskip{}

\end{singlespace}

Dear Professor:\smallskip{}

asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf
asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf
asdfasdf asdfadf asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf asdfdf
asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf
asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf
asdfasdf asdfasdf asdfasdf asdfasdf asdfadf asdfasdf asdfasdf asdfasdf
asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf
asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf

asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf
asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf
asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf ~asdfasdf asdfasdf
asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf
asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf
asdfasdf asdfasdf asdfasdf asdfasdf asdfasdf 

\begin{singlespace}
\smallskip{}

\end{singlespace}

Sincerely:
\bigskip{}
\bigskip{}

Armond T. Philpot

\end{document}

答案1

没错。虽然字体切换 (\footnotesize ) 确实改变了字体尺寸和基线跳过,单行用法通常不会发出段落结尾的空白行(或显式\par),因此基线间距不会保留。为了查看字体更改的效果,请将整个页脚放在 内,minipage并使用常规段落(或显式\pars)来设置每行。不过,这里有一种替代方法,使用 手动调整垂直间距tabular

在此处输入图片描述

\fancyfoot[L]{
  \ifnum\value{page}=1
    \sffamily
    \begin{tabular}{ @{} l }
      \bfseries The Name of My Center \\[-.2\normalbaselineskip]
      \footnotesize Knowledge Hall Room 1 | 1234 Your Alley | Pretend, ST 12345 \\[-.2\normalbaselineskip]
      \footnotesize (123) 456-1234 | \url{http://google.edu} | email: [email protected]
    \end{tabular}
  \else
    \makebox[\textwidth]{Page \thepage{} of \pageref{LastPage}}%
  \fi
}

不要使用geometry然后设置如下内容\headheight\footskip和其他人)外部设置\geometry。在同一个地方完成所有操作。

答案2

我测试了各种选项。这是我最终使用的一个。

\fancyfoot[L]{
\ifthenelse{\value{page}=1}{\textsf{\textbf{The Name of My Center}}\footnotesize{}\\
\textsf{Knowledge Hall Room 1 | 1234 Your Alley | Pretend, ST 66666}\\
\textsf{(123)456-1234 | \url{http://google.edu} | email: [email protected]}}
{\centering{Page  \thepage \hspace{1pt} of \pageref{LastPage}}}
}

通过在第一行打开 \footnotesize{} 可以解决问题,并且它一直有效直到组结束。

在此处输入图片描述

在我看来,与手动调整 \normalbaselineskip 相比,这是一个危险性较小的选择,但我同意你的观点,这也能取得良好的结果。

相关内容