0

I want to be able to have line breaks in my .TeX file without producing extra white space in my final document. For example, from something I'm currently writing, I have

\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}

This is quite dense however, and for me difficult to read, and I would prefer if I could put white spaces in, e.g.

\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}

However, such extra line breaks create extra white space between lines in my compiled document (I am using the parskip package so there's no issue with indentation), about a half of a blank line each, I assume that this is because this is creating a new paragraph. Is there a way to require a double new line to create a new paragraph, so that a single blank line won't affect the output? Or is there a better way to do this for readability purposes?

This is the same as this question which did not have a solution other than putting a % on each blank line to space things out.

  • 1
    Welcome to TeX.SE! Could you explain a bit further why putting % on a blank line is not a good solution for you? – Marijn Mar 13 '18 at 19:50
  • anything is possible but a blank line is reported to TeX as \par and changing that is bound to break lots of things. Note you should not use $$ in latex documents – David Carlisle Mar 13 '18 at 20:00
  • 2
    As you say, this is really a duplicate question, asking it again doesn't really change the fact that using % commented lines is almost certainly the best answer. – David Carlisle Mar 13 '18 at 20:01
  • Also, if you disable blank lines creating new paragraphs (somehow: simplest would be to process your .tex file to strip the blank lines before TeX sees them), how do you plan to indicate new paragraphs? By typing \par? – ShreevatsaR Mar 14 '18 at 0:01
3

Using double blank lines, apart from being technically fragile and likely to break a lot of existing code would make it quite hard to see paragraph breaks in the source.

The main difficulty in reading the source as posted are the long lines and lack of indentation. On site here the long lines require horizontal scrolling to read and even if your editor soft wraps the lines so they are all visible, the linebreaks will occur at semantically meaningless places and so disturb the reading.

I would set it out more like the following, note unrelated changes of using \[ not $$ and using \Bigl and \Bigr not \Big to get proper mathopen and mathclose spacing.

\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}
| improve this answer | |
  • You could also indent the displayed equations by two or more spaces in your source code (if you have the patience to do so); that may make even more readable slightly. – ShreevatsaR Mar 14 '18 at 22:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.