How to Solve Equations and Improve Alignment in Latex Math?

Click For Summary

Discussion Overview

The discussion revolves around the use of LaTeX for formatting mathematical equations, focusing on alignment and presentation issues. Participants share their experiences and suggestions for improving the clarity and organization of equations in LaTeX.

Discussion Character

  • Technical explanation
  • Conceptual clarification
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant expresses difficulty in keeping equations aligned in LaTeX and seeks advice on improving formatting.
  • Another participant suggests including complete formulas between dollar signs and proposes using slashes for fractions in inline formulas instead of the \frac command.
  • A later reply introduces the align environment as a method to align equations by the equals sign, providing an example of its use.
  • Further suggestions include using a single align environment, utilizing ampersands for alignment control, and omitting dollar signs since the align environment is already in math mode.
  • One participant emphasizes the importance of using curly braces around exponents and subscripts to avoid formatting issues in the future.

Areas of Agreement / Disagreement

Participants present multiple views on how to effectively format equations in LaTeX, with no consensus on a single best approach. Suggestions vary, indicating differing preferences and practices.

Contextual Notes

Some suggestions depend on personal preferences for typesetting and may not be universally applicable. The discussion highlights various methods without resolving which is superior.

Casio1
Messages
86
Reaction score
0
$y=2x+1$

$y=2x^2+3x+5$

$ a+3b=1$
$2a - b=1$

Multiply through by 3

$6a - 3b = 3$

Subtract equation (3) from (1)

$6a - 3b = 3$
$ a + 3b = 1$
$7a - 0b = 4$

a =$\frac{4}{7}$

Just learning latex on here and trying to understand how I can keep everything in line, which seems difficult with some parts above, is there something I am missing out?

Please advise

Kind regards

Casio
 
Physics news on Phys.org
Casio said:
Just learning latex on here and trying to understand how I can keep everything in line, which seems difficult with some parts above, is there something I am missing out?
What do you mean by difficulties of keeping everything in line? You should include the complete formula between the dollar signs, i.e., write $a=\frac{4}{7}$ instead of a =$\frac{4}{7}$. Also, from the typography viewpoint, it is arguably better to write fractions in inline formulas and in sub- and superscripts using a slash instead of \frac: \(4/7\) instead of \(\frac{4}{7}\). The command \frac is convenient for large display formulas (i.e., formulas that take their own line). However, this remark is probably more appropriate for fine book typesetting rather than online forums.
 
Casio said:
$y=2x+1$

$y=2x^2+3x+5$

$ a+3b=1$
$2a - b=1$

Multiply through by 3

$6a - 3b = 3$

Subtract equation (3) from (1)

$6a - 3b = 3$
$ a + 3b = 1$
$7a - 0b = 4$

a =$\frac{4}{7}$

Just learning latex on here and trying to understand how I can keep everything in line, which seems difficult with some parts above, is there something I am missing out?

Please advise

Kind regards

Casio

To add to Evgeny.Makarov's comments, you can use the align environment (among many, many possibilities in $\LaTeX$) to align equations by the equals sign. For example, the code

Code:
\begin{align*}
a&=x+y\\
b&=x-y
\end{align*}

produces

\begin{align*}
a&=x+y\\
b&=x-y
\end{align*}
 
$\begin{align}r^2=(x + 5)^2 + (y - 3)^2\end{align}$
$\begin{align}r^2=(x - 1)^2 + (y + 1)^2\end{align}$
$\begin{align}r^2=(x - 0)^2 + (y + 2)^2\end{align}$

${2}/{3} + {4}/{6}=$

How is this?

Better
 
Casio said:
$\begin{align}r^2=(x + 5)^2 + (y - 3)^2\end{align}$
$\begin{align}r^2=(x - 1)^2 + (y + 1)^2\end{align}$
$\begin{align}r^2=(x - 0)^2 + (y + 2)^2\end{align}$

${2}/{3} + {4}/{6}=$

How is this?

Better

It is better, but only by accident. There are three things you could do to improve this code.

1. Use only one align environment.
2. Use ampersands to control how things are aligned.
3. Leave off the dollar signs. The align environment is automatically math mode.

For example, suppose you wanted to type these:

Code:
$\begin{align}r^2+x^{2}=(x + 5)^2 + (y - 3)^2\end{align}$
$\begin{align}r^2=(x - 1)^2 + (y + 1)^2\end{align}$
$\begin{align}r^2=(x - 0)^2 + (y + 2)^2\end{align}$

produces

$\begin{align}r^2+x^{2}=(x + 5)^2 + (y - 3)^2\end{align}$
$\begin{align}r^2=(x - 1)^2 + (y + 1)^2\end{align}$
$\begin{align}r^2=(x - 0)^2 + (y + 2)^2\end{align}$

Not aligned the way we want!

Try this code:

Code:
\begin{align}r^2+x^{2}&=(x + 5)^2 + (y - 3)^2\\
r^2&=(x - 1)^2 + (y + 1)^2\\
r^2&=(x - 0)^2 + (y + 2)^2\end{align}

producing

\begin{align}r^2+x^{2}&=(x + 5)^2 + (y - 3)^2\\
r^2&=(x - 1)^2 + (y + 1)^2\\
r^2&=(x - 0)^2 + (y + 2)^2.\end{align}

Much better. Notice the double backslashes at the end of each line marking where the code should begin the next line.

Incidentally: as a defensive $\LaTeX$ programming habit, I always put curly braces around exponents and subscripts, even if it's only one character. That way, if I want to insert another character in the exponent or subscript later, I won't wonder why I get this sort of thing: $x^45$ instead of $x^{45}$.
 

Similar threads

  • · Replies 11 ·
Replies
11
Views
8K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 6 ·
Replies
6
Views
6K
  • · Replies 9 ·
Replies
9
Views
6K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
Replies
10
Views
3K