LATEX tables and equations

LATEX tables and equations

W. Ethan Duckworth, Loyola University Maryland, 2014

? tabular makes something with rows and columns.

Example 1. Input:

\begin{tabular}{rcll}

xxx & yyyy & zzzz & wwww \\

t &u

&v

&s

\end{tabular}

Output:

xxx yyyy zzzz wwww tuv s

(1) The letters {rcll} specify how many columns there are (four, one for each letter) and how each is justified (r = right, c = center, l = left). (2) Separate each column with & and each row with \\.

? array is just like tabular, but it's used in math mode.

Example 2. Input:

$$

\begin{array}{rcll}

xxx & yyyy & zzzz & wwww \\

t &u

&v

&s

\end{array}

$$

Output:

xxx yyyy zzzz wwww tuv s

? Equations using array

Example 3. Input: $$ \begin{array}{rcl}

x & = & \frac{ -2\pm \sqrt{4+4}}{2}\\ & = & \frac{ -2\pm 2\sqrt{2}}{2}\\ & = & -1\pm \sqrt{2}

\end{array} $$

Output:

x

=

-2? 4+4 2

=

-2?2 2

2

= -1 ? 2

? Equations using align* (and \usepackage{amsmath})

Example 4. Input: \documentclass{article} \usepackage{amsmath} \begin{document} \begin{align*}

x & = \frac{ -2\pm \sqrt{4+4}}{2}\\ & = \frac{ -2\pm 2\sqrt{2}}{2}\\ & = -1\pm \sqrt{2}

\end{align*} \end{document}

Output:

-2 ? 4 + 4 x=

2 -2 ? 2 2 =

2 = -1 ? 2

? Differences between array and align*. (1) align* needs about half as many &'s: you only put them between the left hand side and the = (or + or > etc.). (2) The spacing is somewhat better in align. (3) If you use align instead of align* you get equation numbering. (4) By entering \allowdisplaybreaks in the preamble, you can let LATEX break the page in the middle of the equations. (5) array gives you more control over each column (but requires that you describe each column).

? Matrices using array with \left[ and \right].

Example 5. Input: $$ \left[ \begin{array}{ccc}

a & b & c \\ d & e & f \\ g&h&i \end{array} $$

\right]

Output:

a b c d e f

gh i

? Matrices using bmatrix (and \usepackage{amsmath})

Example 6. Input: \documentclass{article} \usepackage{amsmath} \begin{document} $$ \begin{bmatrix}

a & b & c \\ d & e & f \\ g&h&i \end{bmatrix} $$

Output:

a b c d e f

gh i

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download