Math & ScienceVertical spacing in equation

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
Post Reply
Singularity
Posts: 156
Joined: Sat Jan 22, 2011 9:55 pm

Vertical spacing in equation

Post by Singularity »

Hi. I'm pretty new to Latex. I have some math equations which are vertically crammed (for lack of a better description) together and very difficult to read. Everything I read says not to worry about Latex spacing, that it does a good job by default. I'm not sure I agree and I cannot find how to change the vertical spacing in math mode (I could add a blank line, but that was too much space).

Following is my code. I also uploaded a few small attachments to show what I mean by 'crammed' together (note that they look even worse on my PC than the attached versions).

How can I get some white space between lines of the equation?
Thanks.

Code: Select all

Adding the two equations gives:
\begin{equation*}
	\begin{array}{l}
		c_1 = \frac{y_1 - 2y_2 + y_3}{2 \Delta t^2} \\
		c_2 = \frac{y_3-y_1}{2 \Delta t} \\
		c_3 = y_2
	\end{array}
\label{eq:}
\end{equation*}
add.PNG
add.PNG (10.85 KiB) Viewed 17866 times

Code: Select all

\begin{equation*}
	\begin{array}{l}
		c_1=\frac{\left| V_1 \right|}{\left| V \right|}=\frac{-\Delta t (y_1-2y_2+y_3)}{-2 \Delta t^3} =
				\frac{(y_1-2y_2+y_3)}{2 \Delta t^2} \\
		c_2=\frac{\left| V_2 \right|}{\left| V \right|}=\frac{\Delta t^2(y_1-y_3)}{-2 \Delta t^3} = \frac{y_3-y_1}{2 \Delta t} \\
		c_3=\frac{\left| V_3 \right|}{\left| V \right|}=\frac{-2\Delta t^3y_2}{-2 \Delta t^3} = y_2
	\end{array}
\label{eq:}
\end{equation*}

The vertex occurs at $t=-b/2a$:
\begin{equation*}
	\begin{array}{rl}
		t &=\; \frac{-c_2}{2c_1}\; =\; \frac{-\frac{y_3-y_1}{2 \Delta t}}{2\frac{(y_1-2y_2+y_3)}{2 \Delta t^2}}+t_2 \\
			&=\; \frac{y_1-y_3}{2 \Delta t} \cdot	\frac{\Delta t^2}{y_1-2y_2+y_3}+t_2 \\
			&=\; \frac{\Delta t(y_1-y_3)}{2(y_1-2y_2+y_3)}+t_2
	\end{array}
\label{eq:}
\end{equation*}
C.PNG
C.PNG (13.81 KiB) Viewed 17866 times
t.PNG
t.PNG (17.26 KiB) Viewed 17866 times
Last edited by Singularity on Thu Mar 10, 2011 7:08 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

shadgrind
Posts: 140
Joined: Thu Jul 16, 2009 12:39 am

Vertical spacing in equation

Post by shadgrind »

You can add vertical spacing after the \\, like this:

Code: Select all

\begin{equation*}
   \begin{array}{l}
      c_1 = \frac{y_1 - 2y_2 + y_3}{2 \Delta t^2} \\[6pt]
      c_2 = \frac{y_3-y_1}{2 \Delta t} \\[6pt]
      c_3 = y_2
   \end{array}
\label{eq:}
\end{equation*}
System: TeX Live 2012, Fedora 18 x86_64, GNU Emacs 24.2
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Vertical spacing in equation

Post by localghost »

StupidUser wrote:[…] How can I get some white space between lines of the equation? […]
I wonder why you use the array environment at all. The amsmath package offers much smarter solutions.

Code: Select all

\documentclass[11pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{mathtools}       % loads »amsmath«

\begin{document}
  Adding the two equations gives:
  \begin{equation*}
    \begin{aligned}
      c_1 &= \frac{y_1 - 2y_2 + y_3}{2 \Delta t^2} \\
      c_2 &= \frac{y_3-y_1}{2 \Delta t} \\
      c_3 &= y_2
    \end{aligned}
  \end{equation*}
  \begin{equation*}
    \begin{alignedat}{3}
      c_1 &= \frac{\left| V_1 \right|}{\left| V \right|} &&= \frac{-\Delta t (y_1-2y_2+y_3)}{-2 \Delta t^3} &&= \frac{(y_1-2y_2+y_3)}{2 \Delta t^2} \\
      c_2 &= \frac{\left| V_2 \right|}{\left| V \right|} &&= \frac{\Delta t^2(y_1-y_3)}{-2 \Delta t^3} &&= \frac{y_3-y_1}{2 \Delta t} \\
      c_3 &= \frac{\left| V_3 \right|}{\left| V \right|} &&= \frac{-2\Delta t^3y_2}{-2 \Delta t^3} &&= y_2
    \end{alignedat}
  \end{equation*}

  The vertex occurs at $t=-\frac{b}{2a}$:
  \begin{equation*}
    \begin{alignedat}{2}
      t &= -\frac{c_2}{2c_1} &&= \frac{-\frac{y_3-y_1}{2 \Delta t}}{2\frac{(y_1-2y_2+y_3)}{2 \Delta t^2}}+t_2 \\
      &&&= \frac{y_1-y_3}{2 \Delta t} \cdot \frac{\Delta t^2}{y_1-2y_2+y_3}+t_2 \\
      &&&= \frac{\Delta t(y_1-y_3)}{2(y_1-2y_2+y_3)}+t_2
    \end{alignedat}
  \end{equation*}
\end{document}
For advanced math typesetting refer to the excellent »Math mode« document.


Best regards and welcome to the board
Thorsten
Singularity
Posts: 156
Joined: Sat Jan 22, 2011 9:55 pm

Vertical spacing in equation

Post by Singularity »

shadgrind wrote:You can add vertical spacing after the \\, like this:...
Thanks shad. I hadn't seen that option.
localghost wrote:I wonder why you use the array environment at all.
I was using the environments that were shown in the tutorials I was reading. Each of them could do some of what I wanted, but I wasn't particularly happy with any of them. Maybe I need better tutorials.
localghost wrote:The amsmath package offers much smarter solutions.
...

For advanced math typesetting refer to the excellent »Math mode« document.
aligned and alignedat look much better.

Thanks for the reference to the Math mode doc. I already see lots of good info in there.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Vertical spacing in equation

Post by localghost »

If the problem is solved, then please mark the topic (not the last post) accordingly as written in Section 3 of the Board Rules (to be read before posting). Otherwise tell us what is missing.


Best regards and welcome to the board
Thorsten
Singularity
Posts: 156
Joined: Sat Jan 22, 2011 9:55 pm

Vertical spacing in equation

Post by Singularity »

localghost wrote:If the problem is solved, then please mark the topic (not the last post) accordingly as written in Section 3 of the Board Rules (to be read before posting). Otherwise tell us what is missing.

Best regards and welcome to the board
Thorsten
OK, here, finally, is my the code I ended up with. Since I handed in the assignment, it's not going to improve anymore:

Code: Select all

Adding the two equations gives:
\begin{equation*}\label{eq:add}
  \begin{aligned}
    c_1 &= \frac{y_1 - 2y_2 + y_3}{2 \Delta t^2} \\
    c_2 &= \frac{y_3-y_1}{2 \Delta t} \\
    c_3 &= y_2
  \end{aligned}
\end{equation*}

Code: Select all

\begin{equation*}\label{eq:vecC}
  \begin{alignedat}{3}
    c_1 &= \frac{\left| V_1 \right|}{\left| V \right|} &&= \frac{-\Delta t (y_1-2y_2+y_3)}{-2 \Delta t^3} &&= \frac{(y_1-2y_2+y_3)}{2 \Delta t^2} \\
    c_2 &= \frac{\left| V_2 \right|}{\left| V \right|} &&= \frac{\Delta t^2(y_1-y_3)}{-2 \Delta t^3} &&= \frac{y_3-y_1}{2 \Delta t} \\
    c_3 &= \frac{\left| V_3 \right|}{\left| V \right|} &&= \frac{-2\Delta t^3y_2}{-2 \Delta t^3} &&= y_2
  \end{alignedat}
\end{equation*}

Code: Select all

The vertex occurs at $t=-b/2a$:
\begin{equation*}\label{eq:third}
  \begin{alignedat}{2}
    t &= -\frac{c_2}{2c_1} &&= \frac{-\frac{y_3-y_1}{2 \Delta t}}{2\frac{(y_1-2y_2+y_3)}{2 \Delta t^2}}+t_2 \\
    &&&= \frac{y_1-y_3}{2 \Delta t} \cdot \frac{\Delta t^2}{y_1-2y_2+y_3}+t_2 \\
    &&&= \frac{\Delta t(y_1-y_3)}{2(y_1-2y_2+y_3)}+t_2
  \end{alignedat}
\end{equation*}
But I still have general spacing issues with Latex. For example, I have to manually add spacing to the following nested enumerated lists, and I can't find any way to tighten up white space where I don't want it (e.g. before the first list starts). I need to get the spacing right without jumping through all kinds of hoops. Can I?

Code: Select all

    \subsection*{23.1:} For each of the following relations, please answer these questions:
    \begin{enumerate}
       \item Is it a function? If not, explain why.
       \item If yes, what are it's domain and range?
       \item Is the function one-to-one? If not, explain why.
       \item If yes, what is the inverse function? \\[\baselineskip]
       \begin{enumerate}

          \item $f=\set{(1,2),(3,4)}$ \\
              \A   \begin{enumerate}
                      \item Yes
                      \item dom $f=\set{1,3}$, im $f=\set{2,4}$
                      \item Yes
                      \item $f^{-1}=\set{(2,1),(4,3)}$ \\[\baselineskip]
                   \end{enumerate}
             
          \item $f=\setof{(x,y)}{x,y \in \mathbb{Z}, y=2x}$ \\
             \A   \begin{enumerate}
                      \item Yes
                      \item dom $f=\mathbb{Z}$, im $f=\mathbb{E}=\set{\text{even integers}}$
                      \item Yes
                      \item $f^{-1}=\setof{(2x,x)}{x \in \mathbb{E}}$ \\[\baselineskip]
                   \end{enumerate}
          
          \item $f=\setof{(x,y)}{x,y \in \mathbb{Z}, x+y=0}$ \\
             \A   \begin{enumerate}
                      \item Yes
                      \item dom $f=\mathbb{Z}$, im $f=\mathbb{Z}$
                      \item Yes
                      \item $f^{-1} \colon x=-y$ (basically, the same as $f$). \\[\baselineskip]
                   \end{enumerate}
          
          \item $f=\setof{(x,y)}{x,y \in \mathbb{Z}, xy=0}$ \\
             \A   \begin{enumerate}
                      \item No. $(0,1) \in f$ and $(0,2) \in f$. \\[\baselineskip]
                   \end{enumerate}
          
          \item $f=\setof{(x,y)}{x,y \in \mathbb{Z}, y=x^2}$ \\
             \A   \begin{enumerate}
                      \item Yes
                      \item dom $f=\mathbb{Z}$, im $f=\mathbb{Z^+}=\set{\text{non-negative integers}}$
                      \item No. $(1,1) \in f$ and $(-1,1) \in f$. \\[\baselineskip]
                   \end{enumerate}

          \item $f=\emptyset$ \\
             \A   \begin{enumerate}
                      \item Frankly, this doesn't look like a relation (a set of ordered pairs), so I doubt it's a function. \\[\baselineskip]
                   \end{enumerate}

          \item $f=\setof{(x,y)}{x,y \in \mathbb{Q}, x^2+y^2=1}$ \\
             \A   \begin{enumerate}
                      \item No. $(0,1) \in f$ and $(0,-1) \in f$. \\[\baselineskip]
                   \end{enumerate}

          \item $f=\setof{(x,y)}{x,y \in \mathbb{Z}, x|y}$ \\
             \A   \begin{enumerate}
                      \item No. $(2,2) \in f$ and $(2,4) \in f$. \\[\baselineskip]
                   \end{enumerate}

          \item $f=\setof{(x,y)}{x,y \in \mathbb{N}, x|y \text{ and }y|x}$ \\
             \A   \begin{enumerate}
                      \item Yes. $f=\setof{(x,x)}{x \in \mathbb{Z^+}}$
                      \item dom $f=\mathbb{Z^+}$, im $f=\mathbb{Z^+}$
                      \item Yes
                      \item $f^{-1}=f$. \\[\baselineskip]
                   \end{enumerate}

          \item $f=\setof{(x,y)}{x,y \in \mathbb{N}, \dbinom xy=1}$ \\
             \A   \begin{enumerate}
                      \item No. $\dbinom 20 = \dbinom 22 = 1$.
                   \end{enumerate}
       \end{enumerate}
    \end{enumerate}
Post Reply