我想将\baselineskip
尺寸增加到 所使用的尺寸\normalsize
。因此,如果我使用尺寸\tiny
,我希望行距与 中的行距相匹配\normalsize
。我不想绝对调整它,而是根据整个文档使用的字体大小进行调整。
MWE 具有minipage
:
\documentclass{article}
\begin{document}
\begin{minipage}{3cm}
{\tiny this is a tiny text example.
It shouldn't be too short to see the linebreaks.
This is the usual \verb|\baselineskip|.
This is happening without a \verb|\par|.
Anyhow, I want this \verb|\baselineskip| independently of a \verb|\par|\dots.%
}
Just some usual text. %This \baselineskip should be used for the tiny part too
\end{minipage}
\end{document}
答案1
只需保存并恢复baselineskip:
\documentclass{article}
\begin{document}
\begin{minipage}{3cm}
{\skip0=\baselineskip\tiny\baselineskip=\skip0 this is a tiny text example.
It shouldn't be too short to see the linebreaks.
This is the usual \verb|\baselineskip|.
This is happening without a \verb|\par|.
Anyhow, I want this \verb|\baselineskip| independently of a \verb|\par|\dots.%
}
Just some usual text. %This \baselineskip should be used for the tiny part too
\end{minipage}
\end{document}
答案2
尽管在我看来这看起来很糟糕,但这里有一种方法可以做到:
\documentclass{article}
\usepackage{lipsum}
\begin{document}
\lipsum[1]
\fontsize{5}{\the\baselineskip}\selectfont%tiny with normalsizes baselineskip
\lipsum[1]
\normalsize
\lipsum[1]
\end{document}
上述想法具有更多的自动化功能(允许您保持实际文本不受影响,即只需\tiny
在正文中写入等):
\documentclass{article}
\usepackage{lipsum}
\makeatletter
\def\defaultbaselineskip{\ifcase\@ptsize 12\or 13.6\or 14.5\else 12\fi}
\def\@setfontsize#1#2#3{\@nomath#1%
\ifx\protect\@typeset@protect\let\@currsize#1\fi
\fontsize{#2}{\defaultbaselineskip}\selectfont}
\makeatother
\begin{document}
\lipsum[1]
\tiny
\lipsum[1]
\normalsize
\lipsum[1]
\end{document}
甚至更花哨(需要编译两次):
\documentclass{article}
\usepackage{lipsum}
\makeatletter
\AtBeginDocument{%
\if@filesw
\newwrite\defbslfile
\immediate\openout\defbslfile=\jobname.bsl
\immediate\write\defbslfile{\noexpand\def\noexpand\defaultbaselineskip{\the\baselineskip}}
\fi
\immediate\closeout\defbslfile
\InputIfFileExists{\jobname.bsl}{%
\def\@setfontsize##1##2##3{\@nomath##1%
\ifx\protect\@typeset@protect\let\@currsize##1\fi
\fontsize{##2}{\ifdefined\defaultbaselineskip\defaultbaselineskip\else\@xiipt\fi}\selectfont}%
}{}
}
\makeatother
\begin{document}
\lipsum[1]
\tiny
\lipsum[1]
\normalsize
\lipsum[1]
\end{document}