Skip to main content
edited body
Source Link
Ulrik
  • 31
  • 5

I work in a field of mathematics where long, multi-line computations are bread and butter, and I mostly use align* (and its siblings) from the amsmath package to display them. However, I have not found a simple, foolproof way of typesetting such expressions. What is the easiest way of correctly aligning lines horizontally in multi-line expressions?

Ideally, the solution should not be overly technical, lest my coauthors resort to easier, but incorrect, solutions.

Take the following caricature of a multi-line computation: x = -y [newline] -y. If I have understood Knuth and Swanson1 correctly, then the above should be typeset as

Correctly aligned multi-line expression

that is, something like

x [thickspace] = [thickspace] - [no space] y - [medium space] y 

(where the minuses are horizontally aligned). (There should be no space after the first minus, since it's a unary operator, and a medium space after the second, since it's a binary operator.)

I have searched StackExchange for solutions, but in vain. Below are the solutions I have found so far, with MWEs at the bottom.

Some incorrect solutionsSome incorrect solutions

  1. The correct, but overly complicated way:

    \documentclass{article} \usepackage{amsmath} \begin{document} \begin{align*} x &= -y \\ &\mathrel{\phantom{=}} -\:y \end{align*} \end{document} 
  2. Do nothing. The minuses are incorrectly aligned.

    x &= -y \\ &-y 

    (I'm only changing the contents of align* here.)

  3. Indent arbitrarily using e.g. \quad or \qquad. The minuses are incorrectly aligned.

    x &= -y \\ &\quad -y 
  4. Use \phantom. The minuses are incorrectly aligned.

    x &= -y \\ &\phantom{=} -y 
  5. Use \mathrel{\phantom}. The minuses are incorrectly aligned, and there is no medium space after the second minus.

    x &= -y \\ &\mathrel{\phantom{=}} -y 
  6. Use {}&. There seems to be a thin and a thick space after the equals sign, and a thin space after the first minus.

    x ={}& -y \\ & -y 
  7. Use aligned. Produces the same as in (6).

    x &= \begin{aligned}[t] &-y \\ &-y \end{aligned} 

1: Donald Knuth: The TeXbook, page 170 and Ellen Swanson: Mathematics into Type, Section 3.3.5.

Edit 29 January: I misread Knuth's table; there should be a medspace after the second minus. Also, turned the fragments into a full document.

I work in a field of mathematics where long, multi-line computations are bread and butter, and I mostly use align* (and its siblings) from the amsmath package to display them. However, I have not found a simple, foolproof way of typesetting such expressions. What is the easiest way of correctly aligning lines horizontally in multi-line expressions?

Ideally, the solution should not be overly technical, lest my coauthors resort to easier, but incorrect, solutions.

Take the following caricature of a multi-line computation: x = -y [newline] -y. If I have understood Knuth and Swanson1 correctly, then the above should be typeset as

Correctly aligned multi-line expression

that is, something like

x [thickspace] = [thickspace] - [no space] y - [medium space] y 

(where the minuses are horizontally aligned). (There should be no space after the first minus, since it's a unary operator, and a medium space after the second, since it's a binary operator.)

I have searched StackExchange for solutions, but in vain. Below are the solutions I have found so far, with MWEs at the bottom.

Some incorrect solutions

  1. The correct, but overly complicated way:

    \documentclass{article} \usepackage{amsmath} \begin{document} \begin{align*} x &= -y \\ &\mathrel{\phantom{=}} -\:y \end{align*} \end{document} 
  2. Do nothing. The minuses are incorrectly aligned.

    x &= -y \\ &-y 

    (I'm only changing the contents of align* here.)

  3. Indent arbitrarily using e.g. \quad or \qquad. The minuses are incorrectly aligned.

    x &= -y \\ &\quad -y 
  4. Use \phantom. The minuses are incorrectly aligned.

    x &= -y \\ &\phantom{=} -y 
  5. Use \mathrel{\phantom}. The minuses are incorrectly aligned, and there is no medium space after the second minus.

    x &= -y \\ &\mathrel{\phantom{=}} -y 
  6. Use {}&. There seems to be a thin and a thick space after the equals sign, and a thin space after the first minus.

    x ={}& -y \\ & -y 
  7. Use aligned. Produces the same as in (6).

    x &= \begin{aligned}[t] &-y \\ &-y \end{aligned} 

1: Donald Knuth: The TeXbook, page 170 and Ellen Swanson: Mathematics into Type, Section 3.3.5.

Edit 29 January: I misread Knuth's table; there should be a medspace after the second minus. Also, turned the fragments into a full document.

I work in a field of mathematics where long, multi-line computations are bread and butter, and I mostly use align* (and its siblings) from the amsmath package to display them. However, I have not found a simple, foolproof way of typesetting such expressions. What is the easiest way of correctly aligning lines horizontally in multi-line expressions?

Ideally, the solution should not be overly technical, lest my coauthors resort to easier, but incorrect, solutions.

Take the following caricature of a multi-line computation: x = -y [newline] -y. If I have understood Knuth and Swanson1 correctly, then the above should be typeset as

Correctly aligned multi-line expression

that is, something like

x [thickspace] = [thickspace] - [no space] y - [medium space] y 

(where the minuses are horizontally aligned). (There should be no space after the first minus, since it's a unary operator, and a medium space after the second, since it's a binary operator.)

I have searched StackExchange for solutions, but in vain. Below are the solutions I have found so far, with MWEs at the bottom.

Some incorrect solutions

  1. The correct, but overly complicated way:

    \documentclass{article} \usepackage{amsmath} \begin{document} \begin{align*} x &= -y \\ &\mathrel{\phantom{=}} -\:y \end{align*} \end{document} 
  2. Do nothing. The minuses are incorrectly aligned.

    x &= -y \\ &-y 

    (I'm only changing the contents of align* here.)

  3. Indent arbitrarily using e.g. \quad or \qquad. The minuses are incorrectly aligned.

    x &= -y \\ &\quad -y 
  4. Use \phantom. The minuses are incorrectly aligned.

    x &= -y \\ &\phantom{=} -y 
  5. Use \mathrel{\phantom}. The minuses are incorrectly aligned, and there is no medium space after the second minus.

    x &= -y \\ &\mathrel{\phantom{=}} -y 
  6. Use {}&. There seems to be a thin and a thick space after the equals sign, and a thin space after the first minus.

    x ={}& -y \\ & -y 
  7. Use aligned. Produces the same as in (6).

    x &= \begin{aligned}[t] &-y \\ &-y \end{aligned} 

1: Donald Knuth: The TeXbook, page 170 and Ellen Swanson: Mathematics into Type, Section 3.3.5.

Edit 29 January: I misread Knuth's table; there should be a medspace after the second minus. Also, turned the fragments into a full document.

added 23 characters in body
Source Link
Ulrik
  • 31
  • 5

I work in a field of mathematics where long, multi-line computations are bread and butter, and I mostly use align* (and its siblings) from the amsmath package to display them. However, I have not found a simple, foolproof way of typesetting such expressions. What is the easiest way of correctly aligning lines horizontally in multi-line expressions?

Ideally, the solution should not be overly technical, lest my coauthors resort to easier, but incorrect, solutions.

Take the following caricature of a multi-line computation: x = -y [newline] -y. If I have understood Knuth and Swanson1 correctly, then the above should be typeset as

Correctly aligned multi-line expression

that is, something like

x [thickspace] = [thickspace] - [no space] y - [medium space] y 

(where the minuses are horizontally aligned). (There should be no space after the first minus, since it's a unary operator, and a medium space after the second, since it's a binary operator.)

I have searched StackExchange for solutions, but in vain. Below are the solutions I have found so far, with MWEs at the bottom.

Some incorrect solutions

  1. The correct, but overly complicated way:

    \documentclass{article} \usepackage{amsmath} \begin{document} \begin{align*} x &= -y \\ &\mathrel{\phantom{=}} -\:y \end{align*} \end{document} 
  2. Do nothing. The minuses are incorrectly aligned.

    x &= -y \\ &-y 

    (I'm only changing the contents of align* here.)

  3. Indent arbitrarily using e.g. \quad or \qquad. The minuses are incorrectly aligned.

    x &= -y \\ &\quad -y 
  4. Use \phantom. The minuses are incorrectly aligned.

    x &= -y \\ &\phantom{=} -y 
  5. Use \mathrel{\phantom}. The minuses are incorrectly aligned, and there is no medium space after the second minus.

    x &= -y \\ &\mathrel{\phantom{=}} -y 
  6. Use {}&. There seems to be a thin and a thick space after the equals sign, and a thin space after the first minus.

    x ={}& -y \\ & -y 
  7. Use aligned. Produces the same as in (6).

    x &= \begin{aligned}[t] &-y \\ &-y \end{aligned} 

1: Donald Knuth: The TeXbook, page 170 and Ellen Swanson: Mathematics into Type, Section 3.3.5.

Edit 29 January: I misread Knuth's table; there should be a medspace after the second minus. Also, turned the fragments into a full document.

I work in a field of mathematics where long, multi-line computations are bread and butter, and I mostly use align* (and its siblings) from the amsmath package to display them. However, I have not found a simple, foolproof way of typesetting such expressions. What is the easiest way of correctly aligning lines horizontally in multi-line expressions?

Ideally, the solution should not be overly technical, lest my coauthors resort to easier, but incorrect, solutions.

Take the following caricature of a multi-line computation: x = -y [newline] -y. If I have understood Knuth and Swanson1 correctly, then the above should be typeset as

Correctly aligned multi-line expression

that is, something like

x [thickspace] = [thickspace] - [no space] y - [medium space] y 

(where the minuses are horizontally aligned). (There should be no space after the first minus, since it's a unary operator, and a medium space after the second, since it's a binary operator.)

I have searched StackExchange for solutions, but in vain. Below are the solutions I have found so far, with MWEs at the bottom.

Some incorrect solutions

  1. The correct, but overly complicated way:

    \documentclass{article} \usepackage{amsmath} \begin{document} \begin{align*} x &= -y \\ &\mathrel{\phantom{=}} -\:y \end{align*} \end{document} 
  2. Do nothing. The minuses are incorrectly aligned.

    x &= -y \\ &-y 

    (I'm only changing the contents of align* here.)

  3. Indent arbitrarily using e.g. \quad or \qquad. The minuses are incorrectly aligned.

    x &= -y \\ &\quad -y 
  4. Use \phantom. The minuses are incorrectly aligned.

    x &= -y \\ &\phantom{=} -y 
  5. Use \mathrel{\phantom}. The minuses are incorrectly aligned, and there is no medium space after the second minus.

    x &= -y \\ &\mathrel{\phantom{=}} -y 
  6. Use {}&. There seems to be a thin and a thick space after the equals sign, and a thin space after the first minus.

    x ={}& -y \\ & -y 
  7. Use aligned. Produces the same as in (6).

    x &= \begin{aligned}[t] &-y \\ &-y 

1: Donald Knuth: The TeXbook, page 170 and Ellen Swanson: Mathematics into Type, Section 3.3.5.

Edit 29 January: I misread Knuth's table; there should be a medspace after the second minus. Also, turned the fragments into a full document.

I work in a field of mathematics where long, multi-line computations are bread and butter, and I mostly use align* (and its siblings) from the amsmath package to display them. However, I have not found a simple, foolproof way of typesetting such expressions. What is the easiest way of correctly aligning lines horizontally in multi-line expressions?

Ideally, the solution should not be overly technical, lest my coauthors resort to easier, but incorrect, solutions.

Take the following caricature of a multi-line computation: x = -y [newline] -y. If I have understood Knuth and Swanson1 correctly, then the above should be typeset as

Correctly aligned multi-line expression

that is, something like

x [thickspace] = [thickspace] - [no space] y - [medium space] y 

(where the minuses are horizontally aligned). (There should be no space after the first minus, since it's a unary operator, and a medium space after the second, since it's a binary operator.)

I have searched StackExchange for solutions, but in vain. Below are the solutions I have found so far, with MWEs at the bottom.

Some incorrect solutions

  1. The correct, but overly complicated way:

    \documentclass{article} \usepackage{amsmath} \begin{document} \begin{align*} x &= -y \\ &\mathrel{\phantom{=}} -\:y \end{align*} \end{document} 
  2. Do nothing. The minuses are incorrectly aligned.

    x &= -y \\ &-y 

    (I'm only changing the contents of align* here.)

  3. Indent arbitrarily using e.g. \quad or \qquad. The minuses are incorrectly aligned.

    x &= -y \\ &\quad -y 
  4. Use \phantom. The minuses are incorrectly aligned.

    x &= -y \\ &\phantom{=} -y 
  5. Use \mathrel{\phantom}. The minuses are incorrectly aligned, and there is no medium space after the second minus.

    x &= -y \\ &\mathrel{\phantom{=}} -y 
  6. Use {}&. There seems to be a thin and a thick space after the equals sign, and a thin space after the first minus.

    x ={}& -y \\ & -y 
  7. Use aligned. Produces the same as in (6).

    x &= \begin{aligned}[t] &-y \\ &-y \end{aligned} 

1: Donald Knuth: The TeXbook, page 170 and Ellen Swanson: Mathematics into Type, Section 3.3.5.

Edit 29 January: I misread Knuth's table; there should be a medspace after the second minus. Also, turned the fragments into a full document.

added 54 characters in body
Source Link
Ulrik
  • 31
  • 5

I work in a field of mathematics where long, multi-line computations are bread and butter, and I mostly use align* (and its siblings) from the amsmath package to display them. However, I have not found a simple, foolproof way of typesetting such expressions. What is the easiest way of correctly aligning lines horizontally in multi-line expressions?

Ideally, the solution should not be overly technical, lest my coauthors resort to easier, but incorrect, solutions.

Take the following caricature of a multi-line computation: x = -y [newline] -y. If I have understood Knuth and Swanson1 correctly, then the above should be typeset as

Correctly aligned multi-line expression

that is, something like

x [thickspace] = [thickspace] - [no space] y - [medium space] y 

(where the minuses are horizontally aligned). (There should be no space after the first minus, since it's a unary operator, and a medium space after the second, since it's a binary operator.)

I have searched StackExchange for solutions, but in vain. Below are the solutions I have found so far, with MWEs at the bottom.

Some incorrect solutions

  1. The correct, but overly complicated way:

    \documentclass{article} \usepackage{amsmath} \begin{document} \begin{align*} x &= -y \\ &\mathrel{\phantom{=}} -\:y \end{align*} \end{document} 
  2. Do nothing. The minuses are incorrectly aligned.

    x &= -y \\ &-y 

    (I'm only changing the contents of align* here.)

  3. Indent arbitrarily using e.g. \quad or \qquad. The minuses are incorrectly aligned.

    x &= -y \\ &\quad -y 
  4. Use \phantom. The minuses are incorrectly aligned.

    x &= -y \\ &\phantom{=} -y 
  5. Use \mathrel{\phantom}. The minuses are incorrectly aligned, and there is no medium space after the second minus.

    x &= -y \\ &\mathrel{\phantom{=}} -y 
  6. Use {}&. There seems to be a thin and a thick space after the equals sign, and a thin space after the first minus.

    x ={}& -y \\ & -y 
  7. Use aligned. Produces the same as in (6).

    x &= \begin{aligned}[t] &-y \\ &-y 

1: Donald Knuth: The TeXbook, page 170 and Ellen Swanson: Mathematics into TypeEllen Swanson: Mathematics into Type, Section 3.3.5.

Edit 29 January: I misread Knuth's table; there should be a medspace after the second minus. Also, turned the fragments into a full document.

I work in a field of mathematics where long, multi-line computations are bread and butter, and I mostly use align* (and its siblings) from the amsmath package to display them. However, I have not found a simple, foolproof way of typesetting such expressions. What is the easiest way of correctly aligning lines horizontally in multi-line expressions?

Ideally, the solution should not be overly technical, lest my coauthors resort to easier, but incorrect, solutions.

Take the following caricature of a multi-line computation: x = -y [newline] -y. If I have understood Knuth and Swanson1 correctly, then the above should be typeset as

Correctly aligned multi-line expression

that is, something like

x [thickspace] = [thickspace] - [no space] y - [medium space] y 

(where the minuses are horizontally aligned). (There should be no space after the first minus, since it's a unary operator, and a medium space after the second, since it's a binary operator.)

I have searched StackExchange for solutions, but in vain. Below are the solutions I have found so far, with MWEs at the bottom.

Some incorrect solutions

  1. The correct, but overly complicated way:

    \documentclass{article} \usepackage{amsmath} \begin{document} \begin{align*} x &= -y \\ &\mathrel{\phantom{=}} -\:y \end{align*} \end{document} 
  2. Do nothing. The minuses are incorrectly aligned.

    x &= -y \\ &-y 

    (I'm only changing the contents of align* here.)

  3. Indent arbitrarily using e.g. \quad or \qquad. The minuses are incorrectly aligned.

    x &= -y \\ &\quad -y 
  4. Use \phantom. The minuses are incorrectly aligned.

    x &= -y \\ &\phantom{=} -y 
  5. Use \mathrel{\phantom}. The minuses are incorrectly aligned, and there is no medium space after the second minus.

    x &= -y \\ &\mathrel{\phantom{=}} -y 
  6. Use {}&. There seems to be a thin and a thick space after the equals sign, and a thin space after the first minus.

    x ={}& -y \\ & -y 
  7. Use aligned. Produces the same as in (6).

    x &= \begin{aligned}[t] &-y \\ &-y 

1: Donald Knuth: The TeXbook, page 170 and Ellen Swanson: Mathematics into Type, Section 3.3.5.

Edit 29 January: I misread Knuth's table; there should be a medspace after the second minus. Also, turned the fragments into a full document.

I work in a field of mathematics where long, multi-line computations are bread and butter, and I mostly use align* (and its siblings) from the amsmath package to display them. However, I have not found a simple, foolproof way of typesetting such expressions. What is the easiest way of correctly aligning lines horizontally in multi-line expressions?

Ideally, the solution should not be overly technical, lest my coauthors resort to easier, but incorrect, solutions.

Take the following caricature of a multi-line computation: x = -y [newline] -y. If I have understood Knuth and Swanson1 correctly, then the above should be typeset as

Correctly aligned multi-line expression

that is, something like

x [thickspace] = [thickspace] - [no space] y - [medium space] y 

(where the minuses are horizontally aligned). (There should be no space after the first minus, since it's a unary operator, and a medium space after the second, since it's a binary operator.)

I have searched StackExchange for solutions, but in vain. Below are the solutions I have found so far, with MWEs at the bottom.

Some incorrect solutions

  1. The correct, but overly complicated way:

    \documentclass{article} \usepackage{amsmath} \begin{document} \begin{align*} x &= -y \\ &\mathrel{\phantom{=}} -\:y \end{align*} \end{document} 
  2. Do nothing. The minuses are incorrectly aligned.

    x &= -y \\ &-y 

    (I'm only changing the contents of align* here.)

  3. Indent arbitrarily using e.g. \quad or \qquad. The minuses are incorrectly aligned.

    x &= -y \\ &\quad -y 
  4. Use \phantom. The minuses are incorrectly aligned.

    x &= -y \\ &\phantom{=} -y 
  5. Use \mathrel{\phantom}. The minuses are incorrectly aligned, and there is no medium space after the second minus.

    x &= -y \\ &\mathrel{\phantom{=}} -y 
  6. Use {}&. There seems to be a thin and a thick space after the equals sign, and a thin space after the first minus.

    x ={}& -y \\ & -y 
  7. Use aligned. Produces the same as in (6).

    x &= \begin{aligned}[t] &-y \\ &-y 

1: Donald Knuth: The TeXbook, page 170 and Ellen Swanson: Mathematics into Type, Section 3.3.5.

Edit 29 January: I misread Knuth's table; there should be a medspace after the second minus. Also, turned the fragments into a full document.

added 104 characters in body
Source Link
Ulrik
  • 31
  • 5
Loading
added 104 characters in body
Source Link
Ulrik
  • 31
  • 5
Loading
Source Link
Ulrik
  • 31
  • 5
Loading