在字体行距方面,LaTeX 确实不太以用户为中心。大多数用户会期望行距在调用的地方发生变化。我遇到过很多次这样的问题,通常会找到一些 hack(例如无用地更改字体大小)来实现它想要的效果。但如果能学会如何正确地做到这一点,那就太好了。所以,下面是说明这个问题的例子:
\documentclass[11pt]{article}
\usepackage{color}
\usepackage{setspace}
\setstretch{0.75} %% at 10pt, min seems to be 0.75; 0.7 is more distant, 0.8 is more distant
\newcommand{\notesclass}[2]{{\par{\setstretch{5}\medskip\noindent\tiny\textbf{#1:} #2}}\par}
%% useless overkill: \renewcommand{\notesclass}[2]{\begin{minipage}{\textwidth}{\par{\setstretch{5}\medskip\noindent\tiny\textbf{#1:} #2}}\par\end{minipage}\par}
\providecommand{\source}[1]{\notesclass{Source}{#1}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
I am trying to define a macro that reliably typesets content (that explains my tables) in a
font-size and line-spacing of my preference.
For sake of visual illustration, I have set the main text to ugly 0.75 spacing. (I also do not
understand why 0.75 is the minimum setstretch spacing when 10pt is my article main font; either
0.7 or 0.8 creates linespacing that is larger.)
\begin{table}\color{blue}
--- Table Blue Starts
\source{I would have wanted the 5 spacing here. Why does this still have spacing that seems
to be based on the font-size of the main paragraph (10pt)? LaTeX has recognized that it is in
tiny.}
--- Table Blue Ends
\end{table}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{table}\color{red}
--- Table Red Starts
\source{I understand why this has 5 spacing relative to the actual font size that I used. It
is actually what I wanted.
Alas, despite the par at the end of the notesclass macro, this has the same normalsize-
font-related 0.75 separation that I did not want. I would have wanted the 5 spacing here. Even
stranger, if the documentclass is changed from 11pt to 12pt, table red changes in incongruous fashion.}
--- Table Red Ends
\end{table}
\end{document}
结果是
当然,我的意图不是使用 5.0 行距,而是在脚注字体上使用 0.95 行距,以便紧凑地显示浮点数的源引用。
答案1
您的代码\par
位置错误:它应该位于限制范围的右括号之前\tiny
。
另一方面,三行中 0.7pt 的空间节省似乎不值得,但您是最终的裁判。
您不需要setspace
此应用程序。
\documentclass[11pt]{article}
\usepackage{lipsum}
\newcommand{\notesclass}[2]{%
\par\medskip
{\linespread{0.95}\tiny\noindent\textbf{#1:} #2\par}%
}
\newcommand{\source}[1]{\notesclass{Source}{#1}}
\begin{document}
\source{\lipsum[1][1-4]}
As a comparison, the same with just \verb|\tiny|
\medskip{\tiny\noindent\textbf{Source:} \lipsum[1][1-4]\par}
\sbox0{\parbox[b]{\textwidth}{\source{\lipsum[1][1-4]}}}\the\ht0
\sbox0{\parbox[b]{\textwidth}{\medskip\tiny\noindent\textbf{Source:} \lipsum[1][1-4]}}\the\ht0
\end{document}