1

For the sake of readable code, I like to separate e.g. a textblock from some equation environment, using blank lines. Unfortunately, this produces different output in the .pdf. Is there a way to suppress this behaviour? Note: Using Overleaf with pdfLatex as a compiler. Thanks.

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

Produces this:

enter image description here

  • 1
    First of standalone is probably not the right tool for an example like this as it make several special choices. As Niklas mentions you have no blank like (= new paragraph) in the first example, and a blank like in the other. Simple solution: remove the unnecessary blank lines (or start them with % so they are ignored). A blank like indicate a new paragraph and 99% of the time one never starts a new paragraph with a displayed formula. – daleif Aug 15 at 13:30
  • @daleif This is exactly the point. Is there a way to supress the behavior to interpret a blank line as a new paragraph? What kind of donkey language has blank lines with a syntax (looking angrily at python)? – Hiwi Makro Aug 15 at 13:33
  • You should not remove the paragraph indentation. It is there for a reason. Say your document is printed. Without paragraph indentation how does the reader know when a new paragraph starts? It is easy to come up with many examples where the user has to try to interpret the text in order to figure out if there is a newparagraph or not. With the paragraph indentation, the is no ambiguity. – daleif Aug 15 at 13:36
  • I don't mind the indentation. I mind loss of control of wether I want the indentation or not. Assigning blank line syntax ruins the readability of the .tex. – Hiwi Makro Aug 15 at 13:40
  • 1
    you ask what languages use blank lines as syntax: lots of document oriented languages do that, including the markdown used on this site which similarly interprets a blank line as code to end a paragarph. TeX syntax is optimised for writing the document which makes coding seem odd at times, just the way it is. – David Carlisle Aug 15 at 15:07
2

You have a new line in the second equation but not the first one. This makes a new paragraph, therefore adding white space.

\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
    No, never suggest users to use \\ in the text, it is always wrong. The user should not be inserting blank lines in the first place. – daleif Aug 15 at 13:27
  • @daleif Never heard about that, why is it bad to use? \break I assume is okey to use? – Niklas Aug 15 at 13:28
  • 2
    Users should never insert manual line breaks in the text. They should write paragraphs separated by blank lines. \\ is fine when appropriate (tables, matrices, align etc), but has no place used in the text. In my LaTeX book I make an effurt to never mention that \\ can be used in the text as users (at the time) has a tendency to use it everywhere. Use paragraphs, and embrace the fact that paragraphs are indented (they are for a reason). – daleif Aug 15 at 13:33
  • +1 for the edit – daleif Aug 15 at 13:33
  • note that the extra visible space is not vertical space to tex (and for example not dropped at a page break) it is a spurious 1-line paragraph with no visible text. – David Carlisle Aug 15 at 15:08

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.