1

How can I set the vertical spacing for all equations at once? And how can I align them to the left without use \usepackage[fleqn]{amsmath} in preambule?

\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{standalone}
\usepackage{txfonts}
\usepackage{wallpaper}

\usepackage{indentfirst}
\setlength\parindent{1.25cm}

\usepackage{graphicx}

\usepackage{titletoc}

\usepackage{setspace}
\singlespacing

\usepackage[fleqn]{amsmath}
\makeatletter
\g@addto@macro\normalsize{%
    \setlength\abovedisplayskip{0mm}
    \setlength\belowdisplayskip{5mm}
    \setlength\abovedisplayshortskip{0mm}
    \setlength\belowdisplayshortskip{0mm}
}
\makeatother

\pagestyle{myheadings}

\usepackage[bottom=2cm,top=3cm,left=3cm,right=2cm]{geometry}
\usepackage{titling}
\usepackage{titlesec}

\begin{document}
    \begin{equation}
      y(t) = \sqrt{y_{0}^{2} + \bigg(\frac{v_{0}}{\omega} \bigg)^{2}} \ sin(\omega t + \alpha) \ = \ \sqrt{y_{0}^{2} + \bigg(\frac{v_{0}}{\omega} \bigg)^{2}} \ cos(\omega t - \beta)
    \end{equation}
\end{document}  

closed as off-topic by Mico, lockstep, Mensch, yo', moewe Oct 4 '15 at 17:26

  • This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    fleqn option is the way to align all equations to the left (there is essentially no other way, although you could look at the code that runs and run it "by hand" why? and the settings that you show for \abovedisplay skip are the settings to set, but also \abovedisplayshortskip and \belowdisplayshortskip – David Carlisle Oct 4 '15 at 10:01
  • 3
    your comment to the answer, citing error messages from amsmath shows that you haven't given all the relevant information in your sample. please provide a compilable example that prospective testers can experiment with. then you are more likely to get a fully working answer. – barbara beeton Oct 4 '15 at 13:49
  • I'm asking what's the purpose of removing vertical space above displays, but leaving huge space below. – egreg Oct 4 '15 at 15:34
  • 5
    I'm voting to close this question as off-topic because the one of the two questions posed by the OP is based on a mis-understanding, viz., that the txfonts package doesn't load macros that conflict with those in the amsmath package. – Mico Oct 4 '15 at 15:45
3

Your posting contains two separate queries.

How can I set the vertical spacing for all equations at once?

The four relevant length parameters are \abovedisplayskip, \abovedisplayshortskip, \belowdisplayskip, and \belowdisplayshortskip. Set them to whatever values you like.

And, how can I align them to the left without [writing] \usepackage[fleqn]{amsmath} in [the preamble]?

To answer a question with a question: Why would you not want to use this approach? As David Carlisle has already pointed in a comment, this approach is the preferred method for having left-aligned (as opposed to centered) displayed equations. Please state what's wrong -- in your view -- with this method.

  • The vertical spacing problem was solved. But, amsmath give me a lot of "errors", as seen on this image: [link] (pt-br.tinypic.com/r/k0r05s/8). There's another package that works in the same way? – Pedro Felipe Oliveira Oct 4 '15 at 11:59
  • 1
    @PedroFelipeOliveira - Which other math-related packages do you load? And, have you tried changing the order in which amsmath and any other math-related packages are loaded in the preamble? – Mico Oct 4 '15 at 12:04
  • amsmath is the only math-related package that I'm using. – Pedro Felipe Oliveira Oct 4 '15 at 14:33
  • 1
    @PedroFelipeOliveira - Actually, the txfonts package loads lots of math-related macros! The simple solution is to load amsmath before txfonts. – Mico Oct 4 '15 at 15:20
2

The \usepackage{txfonts} should be loaded after \usepackage[fleqn]{amsmath}. The example based on reduced your code:

\documentclass[a4paper,12pt]{article}
    \usepackage[bottom=2cm,top=3cm,left=3cm,right=2cm]{geometry}
    \usepackage[utf8]{inputenc}

    \usepackage{standalone}
    \usepackage[fleqn]{amsmath}% should be before txfonts
\makeatletter
\g@addto@macro\normalsize{%
    \setlength\abovedisplayskip{0mm}
    \setlength\belowdisplayskip{5mm}
    \setlength\abovedisplayshortskip{0mm}
    \setlength\belowdisplayshortskip{0mm}
}
\makeatother
    \usepackage{txfonts}% should be after amsmath

\begin{document}
    \begin{equation}
      y(t) = \sqrt{y_{0}^{2} + \bigg(\frac{v_{0}}{\omega} \bigg)^{2}} \ sin(\omega t + \alpha) \ = \ \sqrt{y_{0}^{2} + \bigg(\frac{v_{0}}{\omega} \bigg)^{2}} \ cos(\omega t - \beta)
    \end{equation}
\end{document} 

gives:

enter image description here

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