我希望能够在 .TeX 文件中设置换行符,而不会在最终文档中产生多余的空白。例如,从我目前正在写的东西来看,我有
\documentclass[12pt]{report}
\usepackage{amsmath}
\usepackage{physics}
\usepackage{parskip}
\newcommand{\set}[1]{\left\{#1\right\}}
\begin{document}
We wish to rewrite this using
\begin{align*}
\int d^N \psi \exp[-\frac{1}{2}\psi_i A_{ij} \psi_j + J_i \psi_i] &= (2\pi)^{N/2} (\det A)^{-1/2} \exp[\frac{1}{2} J_i A^{-1}_{ij} J_j]\\
&= (2\pi)^{N/2}\exp[-\frac{1}{2}\Tr(\ln A)] \exp[\frac{1}{2} J_i A^{-1}_{ij} J_j]
\end{align*}
or alternatively
$$\int d^N \psi \exp[-\frac{1}{2}\psi_i A_{ij} \psi_j + J_i \psi_i] = (2\pi)^{N/2}\exp[-\frac{1}{2}\Tr(\ln A)] \exp[\frac{1}{2} J_i A^{-1}_{ij} J_j]$$
where we identify $J_i \equiv \sigma_i$ and $A_{ij}^{-1}/2 \equiv K_{ij}^{-1}$ or $A_{ij} = K_{ij}/2$. This gives us
$$Z = (2\pi)^{-N/2} \exp[\frac{1}{2}\Tr(\ln(K/2))] \sum_{\set{\sigma_i=\pm 1}}\int d^N\psi \exp[-\frac{1}{4}\psi_i K_{ij} \psi_j + \sigma_i \psi_i] \exp\Big[h_i \sigma_i\Big]$$
or
$$Z = (2\pi)^{-N/2} \exp[\frac{1}{2}\Tr(\ln(K/2))] \int d^N\psi \exp[-\frac{1}{4}\sum_{ij} \psi_i K_{ij} \psi_j] \sum_{\set{\sigma_i=\pm 1}} \prod_{i} \exp\Big[(h_i +\psi_i)\sigma_i\Big]$$
performing the summation, we have
$$Z = (2\pi)^{-N/2} \exp[\frac{1}{2}\Tr(\ln(K/2))] \int d^N\psi \exp[-\frac{1}{4}\sum_{ij} \psi_i K_{ij} \psi_j] \prod_{i}2\, \cosh\Big[(h_i +\psi_i)\sigma_i\Big]$$
After factoring out $N$ factors of $2$ from the product, the leading factor is simply an overall normalization which doesn't affect the physics, call it $\mathcal{N}$, so we finally have the desired result
$$Z = \mathcal{N} \int d^N\psi \,\exp\left\{-\left[\frac{1}{4}\sum_{ij} \psi_i K_{ij} \psi_j - \sum_{i} \ln[\cosh(h_i +\psi_i)]\right]\right\}$$
where
$$\mathcal{N} = \left(\frac{2}{\pi}\right)^{N/2} \exp[\frac{1}{2}\Tr(\ln(K/2))]$$
\end{document}
然而,这非常密集,对我来说很难阅读,我更希望可以添加空格,例如
\documentclass[12pt]{report}
\usepackage{amsmath}
\usepackage{physics}
\usepackage{parskip}
\newcommand{\set}[1]{\left\{#1\right\}}
\begin{document}
We wish to rewrite this using
\begin{align*}
\int d^N \psi \exp[-\frac{1}{2}\psi_i A_{ij} \psi_j + J_i \psi_i] &= (2\pi)^{N/2} (\det A)^{-1/2} \exp[\frac{1}{2} J_i A^{-1}_{ij} J_j]\\
&= (2\pi)^{N/2}\exp[-\frac{1}{2}\Tr(\ln A)] \exp[\frac{1}{2} J_i A^{-1}_{ij} J_j]
\end{align*}
or alternatively
$$\int d^N \psi \exp[-\frac{1}{2}\psi_i A_{ij} \psi_j + J_i \psi_i] = (2\pi)^{N/2}\exp[-\frac{1}{2}\Tr(\ln A)] \exp[\frac{1}{2} J_i A^{-1}_{ij} J_j]$$
where we identify $J_i \equiv \sigma_i$ and $A_{ij}^{-1}/2 \equiv K_{ij}^{-1}$ or $A_{ij} = K_{ij}/2$. This gives us
$$Z = (2\pi)^{-N/2} \exp[\frac{1}{2}\Tr(\ln(K/2))] \sum_{\set{\sigma_i=\pm 1}}\int d^N\psi \exp[-\frac{1}{4}\psi_i K_{ij} \psi_j + \sigma_i \psi_i] \exp\Big[h_i \sigma_i\Big]$$
or
$$Z = (2\pi)^{-N/2} \exp[\frac{1}{2}\Tr(\ln(K/2))] \int d^N\psi \exp[-\frac{1}{4}\sum_{ij} \psi_i K_{ij} \psi_j] \sum_{\set{\sigma_i=\pm 1}} \prod_{i} \exp\Big[(h_i +\psi_i)\sigma_i\Big]$$
performing the summation, we have
$$Z = (2\pi)^{-N/2} \exp[\frac{1}{2}\Tr(\ln(K/2))] \int d^N\psi \exp[-\frac{1}{4}\sum_{ij} \psi_i K_{ij} \psi_j] \prod_{i}2\, \cosh\Big[(h_i +\psi_i)\sigma_i\Big]$$
After factoring out $N$ factors of $2$ from the product, the leading factor is simply an overall normalization which doesn't affect the physics, call it $\mathcal{N}$, so we finally have the desired result
$$Z = \mathcal{N} \int d^N\psi \,\exp\left\{-\left[\frac{1}{4}\sum_{ij} \psi_i K_{ij} \psi_j - \sum_{i} \ln[\cosh(h_i +\psi_i)]\right]\right\}$$
where
$$\mathcal{N} = \left(\frac{2}{\pi}\right)^{N/2} \exp[\frac{1}{2}\Tr(\ln(K/2))]$$
\end{document}
但是,这些额外的换行符会在我编译的文档的行间产生额外的空白(我使用的是软件包parskip
,因此缩进没有问题),大约每行半个空白行,我认为这是因为这会创建一个新段落。有没有办法要求双新行来创建新段落,这样单个空白行就不会影响输出?或者有没有更好的方法来提高可读性?
这与这个问题%
除了在每个空白行上放置一个来分隔开之外,没有其他解决方案。
答案1
使用双空行,除了技术上脆弱且可能破坏许多现有代码外,还会使得在源代码中很难看到段落中断。
阅读发布的源代码的主要困难在于行数过长且缺乏缩进。在网站上,长行需要水平滚动才能阅读,即使您的编辑器软换行以使所有行都可见,换行也会发生在语义上无意义的地方,从而干扰阅读。
我会将它设置得更像下面这样,注意使用\[
not$$
和使用\Bigl
and \Bigr
not\Big
以获得适当的 mathopen 和 mathclose 间距的不相关变化。
\documentclass[12pt]{report}
\usepackage{amsmath}
\usepackage{physics}
\usepackage{parskip}
\newcommand{\set}[1]{\left\{#1\right\}}
\begin{document}
We wish to rewrite this using
\begin{align*}
\int d^N \psi \exp[-\frac{1}{2}\psi_i A_{ij} \psi_j + J_i \psi_i]
&= (2\pi)^{N/2} (\det A)^{-1/2} \exp[\frac{1}{2} J_i A^{-1}_{ij} J_j]\\
&= (2\pi)^{N/2}\exp[-\frac{1}{2}\Tr(\ln A)] \exp[\frac{1}{2} J_i A^{-1}_{ij} J_j]
\end{align*}
or alternatively
\[
\int d^N \psi \exp[-\frac{1}{2}\psi_i A_{ij} \psi_j + J_i \psi_i] =
(2\pi)^{N/2}\exp[-\frac{1}{2}\Tr(\ln A)] \exp[\frac{1}{2} J_i A^{-1}_{ij} J_j]
\]
where we identify
$J_i \equiv \sigma_i$ and $A_{ij}^{-1}/2 \equiv K_{ij}^{-1}$
or $A_{ij} = K_{ij}/2$.
This gives us
\[
Z = (2\pi)^{-N/2} \exp[\frac{1}{2}\Tr(\ln(K/2))]
\sum_{\set{\sigma_i=\pm 1}}\int d^N
\psi
\exp[-\frac{1}{4}\psi_i K_{ij} \psi_j +\sigma_i \psi_i]
\exp\Bigl[h_i \sigma_i\Bigr]
\]
or
\[
Z = (2\pi)^{-N/2} \exp[\frac{1}{2}\Tr(\ln(K/2))] \int d^N\psi
\exp[-\frac{1}{4}\sum_{ij} \psi_i K_{ij} \psi_j]
\sum_{\set{\sigma_i=\pm 1}} \prod_{i} \exp\Big[(h_i +\psi_i)\sigma_i\Big]\]
Performing the summation, we have
\[
Z = (2\pi)^{-N/2} \exp[\frac{1}{2}\Tr(\ln(K/2))]
\int d^N
\psi \exp[-\frac{1}{4}\sum_{ij} \psi_i K_{ij} \psi_j]
\prod_{i}2\, \cosh\Bigl[(h_i +\psi_i)\sigma_i\Bigr]
\]
After factoring out $N$ factors of $2$ from the product,
the leading factor is simply an overall normalization which doesn't affect the physics,
call it $\mathcal{N}$, so we finally have the desired result
\[
Z = \mathcal{N} \int d^N\psi \,\exp
\left\{-\left[
\frac{1}{4}\sum_{ij} \psi_i K_{ij} \psi_j - \sum_{i} \ln[\cosh(h_i +\psi_i)]
\right]\right\}
\]
where
\[
\mathcal{N} = \left(\frac{2}{\pi}\right)^{N/2} \exp[\frac{1}{2}\Tr(\ln(K/2))]
\]
\end{document}