抑制空白

抑制空白

為了程式碼可讀,我喜歡使用空白行將文字區塊與某些方程式環境分開。不幸的是,這會在 .pdf 中產生不同的輸出。有沒有辦法抑制這種行為?注意:使用 Overleaf 和 pdfLatex 作為編譯器。謝謝。

\documentclass[tikz]{standalone}

\begin{document}

This is some dummy text \begin{equation}
    1 + 1 = 2
\end{equation}

And supposely this is a bigger gap:

\begin{equation}
    2+2 = 4
\end{equation}

\end{document}

產生這個:

在此輸入影像描述

答案1

第二個方程中有一個新行,但第一個方程式沒有。這會建立一個新段落,因此會新增空白。

\documentclass[tikz]{standalone}

\begin{document}

This is some dummy text 
\begin{equation}
    1 + 1 = 2
\end{equation}

And supposely this is a bigger gap:
\begin{equation}
    2+2 = 4
\end{equation}

\end{document}

相關內容