精美頁首或頁尾內的行間距(調整字體大小後)

精美頁首或頁尾內的行間距(調整字體大小後)

大約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),因此不會保留基線間距。為了查看更改字體的效果,請將整個頁腳放在 a 內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 更危險的選擇,但我同意你的觀點,這也取得了很好的結果。

相關內容