![虛假空白換行在 \small 中顯示數學](https://rvso.com/image/328820/%E8%99%9B%E5%81%87%E7%A9%BA%E7%99%BD%E6%8F%9B%E8%A1%8C%E5%9C%A8%20%5Csmall%20%E4%B8%AD%E9%A1%AF%E7%A4%BA%E6%95%B8%E5%AD%B8.png)
我可以使用將顯示數學放在文字段落的中間\[...\]
,但我希望數學使用字體大小small
。如果我將顯示塊包裝在{\small...}
段落的後半部分,以“世紀”一詞開頭,則以少量不需要的空白開始。如果我刪除{\small...}
.
\documentclass{article}
\begin{document}
Lorem Ipsum is simply dummy text of the printing and typesetting
industry. Lorem Ipsum has been the industry's standard dummy text ever
since the 1500s, when an unknown printer took a galley of type and
scrambled it to make a type specimen book. It has survived not only five
{\small\[
A / B + C = D
\]}
centuries, but also the leap into electronic typesetting, remaining
essentially unchanged. It was popularised in the 1960s with the release
of Letraset sheets containing Lorem Ipsum passages, and more recently
with desktop publishing software like Aldus PageMaker including versions
of Lorem Ipsum.
\end{document}
我想我正在以錯誤的方式處理這件事。幫助?
答案1
你得到二虛假空格:位於行開頭的一個,這更明顯,但顯示器上方的垂直空間比下方更緊密,因為您使用的是與 相關的上面的跳過\small
,但與 相關的下面的跳過\normalsize
。
您可以模擬標準行為:
\documentclass{article}
\begin{document}
Lorem Ipsum is simply dummy text of the printing and typesetting
industry. Lorem Ipsum has been the industry's standard dummy text ever
since the 1500s, when an unknown printer took a galley of type and
scrambled it to make a type specimen book. It has survived not only five
{\par\penalty\predisplaypenalty\small\[
A / B + C = D
\]\par}\penalty\postdisplaypenalty\noindent
centuries, but also the leap into electronic typesetting, remaining
essentially unchanged. It was popularised in the 1960s with the release
of Letraset sheets containing Lorem Ipsum passages, and more recently
with desktop publishing software like Aldus PageMaker including versions
of Lorem Ipsum.
\end{document}
您可以定義一個vardisplaymath
環境:
\makeatletter
\newenvironment{vardisplaymath}[1][\small]
{\par\penalty\predisplaypenalty\begingroup#1\begin{displaymath}}
{\end{displaymath}\par\endgroup\penalty\postdisplaypenalty
\@endparenv}
\makeatletter
完整範例:
\documentclass{article}
\makeatletter
\newenvironment{vardisplaymath}[1][\small]
{\par\penalty\predisplaypenalty\begingroup#1\begin{displaymath}}
{\end{displaymath}\par\endgroup\penalty\postdisplaypenalty
\@endparenv}
\makeatletter
\begin{document}
Lorem Ipsum is simply dummy text of the printing and typesetting
industry. Lorem Ipsum has been the industry's standard dummy text ever
since the 1500s, when an unknown printer took a galley of type and
scrambled it to make a type specimen book. It has survived not only five
\begin{vardisplaymath}
A / B + C = D
\end{vardisplaymath}
centuries, but also the leap into electronic typesetting, remaining
essentially unchanged. It was popularised in the 1960s with the release
of Letraset sheets containing Lorem Ipsum passages, and more recently
with desktop publishing software like Aldus PageMaker including versions
of Lorem Ipsum.
\begin{vardisplaymath}[\footnotesize]
A / B + C = D
\end{vardisplaymath}
centuries, but also the leap into electronic typesetting, remaining
essentially unchanged. It was popularised in the 1960s with the release
of Letraset sheets containing Lorem Ipsum passages, and more recently
with desktop publishing software like Aldus PageMaker including versions
of Lorem Ipsum.
\end{document}
可以調整它以始終從 獲取參數\normalsize
。
感謝 Tobi 提出改進建議。
一種更簡單的方法,不需要深入了解細節,例如\penalty\postdisplaypenalty
(需要避免顯示後分頁)並保持上面和下面的跳過\normalsize
是
\newsavebox{\vardisplaymathbox}
\newenvironment{vardisplaymath}[1][\small]
{\begin{displaymath}\begin{lrbox}{\vardisplaymathbox}
#1$\displaystyle}
{$\end{lrbox}\usebox{\vardisplaymathbox}\end{displaymath}%
\ignorespacesafterend}
這個定義的結果是