# Tables in LaTeX

#### latentcorpse

hi i made the following table

$\begin{center} \begin{tabular}{l|l|l} \hline & \multicolumn{2}{c}{TYPE OF MATTER} \\ \cline{2-3} & Dust'' & Radiation'' \\ SPATIAL GEOMETRY & P=0 & P=\frac{1}{3} \rho \\ \hline \\ \multirow{2}{*}{3-sphere, K=1} & a=\frac{1}{2}C \left( 1 - \cos{\eta} \right)  & a=\sqrt{C'} \left( 1- \left( 1 - \frac{\tau}{\sqrt{C'}} \right)^2 \right)^{\frac{1}{2}} \\ & \tau=\frac{1}{2}C \left( \eta - \sin{\eta} \right) & \\ \hline Flat, k=0 & a= \left( \frac{9C}{4} \right)^{\frac{1}{3}} \tau^{\frac{2}{3}} & a=\left( 4C' \right)^{\frac{1}{4}} \tau^{\frac{1}{2}} \\ \hline \multirow{2}{*}{3-hyperboloid, k=-1} & a=\frac{1}{2} C \left( \cosh{\eta} - 1 \right) & a=\sqrt{C'} \left( \left( 1 + \frac{\tau}{\sqrt{C'}} \right)^2 -1 \right)^{\frac{1}{2}} \\ & \tau=\frac{1}{2}C \left( \sinh{\eta} - \eta \right) & \\ \hline \end{tabular} \end{center}$

with teh following code:

\begin{center}
\begin{tabular}{l|l|l}
\hline
& \multicolumn{2}{c}{TYPE OF MATTER} \\
\cline{2-3}
& Dust'' & Radiation'' \\
SPATIAL GEOMETRY & $P=0$ & $P=\frac{1}{3} \rho$ \\
\hline \\
\multirow{2}{*}{3-sphere, $K=1$} & $a=\frac{1}{2}C \left( 1 - \cos{\eta} \right)$ & $a=\sqrt{C'} \left( 1- \left( 1 - \frac{\tau}{\sqrt{C'}} \right)^2 \right)^{\frac{1}{2}}$ \\
& $\tau=\frac{1}{2}C \left( \eta - \sin{\eta} \right)$ & \\
\hline
Flat, $k=0$ & $a= \left( \frac{9C}{4} \right)^{\frac{1}{3}} \tau^{\frac{2}{3}}$ & $a=\left( 4C' \right)^{\frac{1}{4}} \tau^{\frac{1}{2}}$ \\
\hline
\multirow{2}{*}{3-hyperboloid, $k=-1$} & $a=\frac{1}{2} C \left( \cosh{\eta} - 1 \right)$ & $a=\sqrt{C'} \left( \left( 1 + \frac{\tau}{\sqrt{C'}} \right)^2 -1 \right)^{\frac{1}{2}}$ \\
& $\tau=\frac{1}{2}C \left( \sinh{\eta} - \eta \right)$ & \\
\hline
\end{tabular}
\end{center}

but i'd like any advice on how to make it look a bit more professional. for example, that line that's incomplete in the middle - how do i sort that?

thanks.

#### D H

Staff Emeritus
Delete the '\\' after the \hline after the "SPATIAL GEOMETRY" line.

#### latentcorpse

cheers. i also get a line sticking out the bottom between the spatial geometry and dust columns. any advice on how to deal with that?

#### n.karthick

If you want "Spatial Geoemtry" to be in the middle vertically you can put this
\multirow{3}{*}{SPATIAL GEOMETRY}
in the first row itself.

#### Stalafin

Although n.karthick already necroposted, I guess, I can just add something as well:

Never EVER use the standard LaTeX tabular environment with vertical lines. It's absolutely horrible.

Use the booktabs package, and arrange your table layout by justifying your cells' contents.

#### JJackiw

The left side of $A^*$ is $A = \left[ \begin{smallmatrix} 9 &7\\ 1 &1 \end{smallmatrix} \right]$ and the right side of $A^*$ is $I = \left[ \begin{smallmatrix} 1 &0\\ 0 &1 \end{smallmatrix} \right]$. The idea is to reduce the left side of $A^*$ from $A$ to $I$ in order to produce the right side of $A^*_t$ from $I$ to $A^{-1}$.

#### JJackiw

The left side of $A^*$ is $A = \left[ \begin{smallmatrix} 9 &7\\ 1 &1 \end{smallmatrix} \right]$ and the right side of $A^*$ is $I = \left[ \begin{smallmatrix} 1 &0\\ 0 &1 \end{smallmatrix} \right]$. The idea is to reduce the left side of $A^*$ from $A$ to $I$ in order to produce the right side of $A^*_t$ from $I$ to $A^{-1}$.

Now the left side of $A^*_t$ is $I = \left[ \begin{smallmatrix} 1 &0\\ 0 &1 \end{smallmatrix} \right]$ and the right side of $A^*_t$ is $A^{-1} = \left[ \frac{1}{2} \begin{smallmatrix} 1 &-7\\ -1 &9 \end{smallmatrix} \right]$. In other words, as $A$ is reduced from $A$ to $I$, $A^{-1}$ is simultaneously produced from $I$ to $A^{-1}$.

#### JJackiw

The left side of $A^*$ is $A = \left[ \begin{smallmatrix} 9 &7\\ 1 &1 \end{smallmatrix} \right]$ and the right side of $A^*$ is $I = \left[ \begin{smallmatrix} 1 &0\\ 0 &1 \end{smallmatrix} \right]$. The idea is to reduce the left side of $A^*$ from $A$ to $I$ in order to produce the right side of $A^*_t$ from $I$ to $A^{-1}$.

Now the left side of $A^*_t$ is $I = \left[ \begin{smallmatrix} 1 &0\\ 0 &1 \end{smallmatrix} \right]$ and the right side of $A^*_t$ is $A^{-1} = \frac{1}{2} \left[ \begin{smallmatrix} 1 &-7\\ -1 &9 \end{smallmatrix} \right]$. In other words, as $A$ is reduced from $A$ to $I$, $A^{-1}$ is simultaneously produced from $I$ to $A^{-1}$.

#### JJackiw

Your problem states that $325$ people attended the theatre that day, grossing $\ 2675$, at $\ 9$ per ticket per adult and $\ 7$ per ticket per child. This means that $\ 9$ times the number of adults plus $\ 7$ times the number of children produced $\ 2675$, and that the total number of adults plus children was $325$. This is your system of linear equations:

\begin{align*} 9x_1 + 7x_2 &= 2675\\ \phantom{9}x_1 + \phantom{7}x_2 &= 325 \end{align*}

You mentioned that you needed to use matrices to solve the problem. Then you will need to convert your system of linear equations to matrix form, as follows:

$$\begin{equation*} \begin{bmatrix} 9 & 7\\ 1 & 1 \end{bmatrix} \begin{bmatrix} x_1\\ x_2 \end{bmatrix} = \begin{bmatrix} 2675\\ 325 \end{bmatrix} \end{equation*}$$

This will produce a matrix equation of the form $AX = B$ for coefficient matrix $A = \left[ \begin{smallmatrix} 9 & 7\\ 1 & 1 \end{smallmatrix} \right]$, solution matrix $X = \left[ \begin{smallmatrix} x_1\\ x_2 \end{smallmatrix} \right]$, constant matrix $B = \left[ \begin{smallmatrix} 2675\\ 325 \end{smallmatrix} \right]$ and identity matrix $I = \left[ \begin{smallmatrix} 1 &0\\ 0 &1 \end{smallmatrix} \right]$ such that:

\begin{align*} AX &= B\\ A^{-1}AX &= A^{-1}B\\ IX &= A^{-1}B\\ X &= A^{-1}B \end{align*}

Given $X$ and $B$, you need to find $A^{-1}$, the inverse matrix of $A$, if it exists, to solve the equation. Using elementary row operations, $r_i$, on $A^*$, the augmented matrix of $A$, allows you to obtain $A^{-1}$:

\begin{align*} A^* &= [A|I] \xrightarrow{r_1} \cdots \xrightarrow{r_n} [I|A^{-1}] = A^*_t\\ &= \begin{bmatrix} 9 &7 &| &1 &0\\ 1 &1 &| &0 &1 \end{bmatrix} \xrightarrow{r_1} \cdots \xrightarrow{r_4} \begin{bmatrix} 1 &0 &| &\frac{1}{2} &-\frac{7}{2}\\ 0 &1 &| &-\frac{1}{2} &\frac{9}{2} \end{bmatrix} = A^*_t \end{align*}
(Refer to the Appendix for a description of the elementary row operations which transform $A^*$ to $A^*_t$.)

So that:

\begin{align*} A^{-1} &= \phantom{\dfrac{1}{2}} \begin{bmatrix} \frac{1}{2} &-\frac{7}{2}\\ -\frac{1}{2} &\frac{9}{2} \end{bmatrix}\\ &= \dfrac{1}{2} \begin{bmatrix} 1 &-7\\ -1 &9 \end{bmatrix} \end{align*}
Since $X = A^{-1} B$ for $X = \left[ \begin{smallmatrix} x_1\\ x_2 \end{smallmatrix} \right]$, $A^{-1} = \frac{1}{2} \left[ \begin{smallmatrix} 1 &-7\\ -1 &9 \end{smallmatrix} \right]$ and $B = \left[ \begin{smallmatrix} 2675\\ 325 \end{smallmatrix} \right]$, then:

\begin{align*} \begin{bmatrix} x_1\\ x_2 \end{bmatrix} &= \dfrac{1}{2} \begin{bmatrix} 1 &-7\\ -1 &9 \end{bmatrix} \begin{bmatrix} 2675\\ 325 \end{bmatrix}\\ &= \dfrac{1}{2} \begin{bmatrix} 2675 - 7 \cdot 325\\ 9 \cdot 325 - 2675 \end{bmatrix}\\ &= \dfrac{1}{2} \begin{bmatrix} 2675-2275\\ 2925-2675 \end{bmatrix}\\ &= \phantom{\frac{1}{2}} \begin{bmatrix} 200\\ 125 \end{bmatrix} \end{align*}

Therefore, $x_1=200$ adults and $x_2=125$ children attended the theatre that day.

Last edited:

#### JJackiw

Appendix

The left side of $A^*$ is $A = \left[ \begin{smallmatrix} 9 &7\\ 1 &1 \end{smallmatrix} \right]$ and the right side of $A^*$ is $I = \left[ \begin{smallmatrix} 1 &0\\ 0 &1 \end{smallmatrix} \right]$. The idea is to reduce the left side of $A^*$ from $A$ to $I$ in order to reproduce the right side of $A^*_t$ from $I$ to $A^{-1}$.

\begin{align*} A^* &= \; \, \begin{bmatrix} 9 &7 &|&1 &0\\ 1 &1 &|&0 &1 \end{bmatrix}\\ &\xrightarrow{r_1} \begin{bmatrix} 1 &1 &| &0 &1\\ 9 &7 &| &1 &0 \end{bmatrix}\\ &\xrightarrow{r_2} \begin{bmatrix} 1 &1 &| &0 &1\\ 0 &-2 &| &1 &-9 \end{bmatrix}\\ &\xrightarrow{r_3} \begin{bmatrix} 1 &1 &| &0 &1\\ 0 &1 &| &-\frac{1}{2} &\frac{9}{2} \end{bmatrix}\\ &\xrightarrow{r_4} \begin{bmatrix} 1 &0 &| &\frac{1}{2} &-\frac{7}{2}\\ 0 &1 &| &-\frac{1}{2} &\frac{9}{2} \end{bmatrix}\\ &\; \, = A^*_t \end{align*}

Now the left side of $A^*_t$ is $I = \left[ \begin{smallmatrix} 1 &0\\ 0 &1 \end{smallmatrix} \right]$ and the right side of $A^*_t$ is $A^{-1} = \left[ \begin{smallmatrix} 1/2 &-7/2\\ -1/2 &9/2 \end{smallmatrix} \right]$. In other words, as $A$ is reduced from $A$ to $I$, $A^{-1}$ is simultaneously reproduced from $I$ to $A^{-1}$.

### The Physics Forums Way

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving