# positioning and alignment of table content

In fact, I want to arrange this table by doing this:

• I want the numbers from 1 to 6 to be on the middle and not on the first line.
• I want the expressions to be aligned

Here is the code that I used:

\begin{table}
\centering
\caption{Expressions des instants de commutation pour chaque secteur}
\begin{tabular}{@{} c c  @{}}
\toprule
Sector number & Expressions  \\
\midrule
1 & $T_a$=$\sqrt{3}$.$T_s$.$\frac{V_r}{U_{dc}}$.sin($\frac{\pi} {3}$-$\gamma$)\\
& $T_b$=$\sqrt{3}$.$T_s$.$\frac{V_r}{U_{dc}}$.sin($\gamma$) \\ \\
2 & $T_a$=$\sqrt{3}$.$T_s$.$\frac{V_r}{U_{dc}}$.sin($\frac{2\pi} {3}$-$\gamma$)\\
& $T_b$=$\sqrt{3}$.$T_s$.$\frac{V_r}{U_{dc}}$.sin($\gamma$-$\frac{\pi}{3}$)
\\ \\
3 & $T_a$=$\sqrt{3}$.$T_s$.$\frac{V_r}{U_{dc}}$.sin($\pi$-$\gamma$)\\
& $T_b$=$\sqrt{3}$.$T_s$.$\frac{V_r}{U_{dc}}$.sin($\gamma$-$\frac{2\pi}{3}$)
\\ \\
4 & $T_a$=$\sqrt{3}$.$T_s$.$\frac{V_r}{U_{dc}}$.sin($\frac{4\pi} {3}$-$\gamma$)\\
& $T_b$=$\sqrt{3}$.$T_s$.$\frac{V_r}{U_{dc}}$.sin($\gamma$-$\pi$) \\ \\
5 & $T_a$=$\sqrt{3}$.$T_s$.$\frac{V_r}{U_{dc}}$.sin($\frac{5\pi} {3}$-$\gamma$)\\
& $T_b$=$\sqrt{3}$.$T_s$.$\frac{V_r}{U_{dc}}$.sin($\gamma$-$\frac{4\pi} {3}$)
\\ \\
6 & $T_a$=$\sqrt{3}$.$T_s$.$\frac{V_r}{U_{dc}}$.sin(2$\pi$-$\gamma$)\\
& $T_b$=$\sqrt{3}$.$T_s$.$\frac{V_r}{U_{dc}}$.sin($\gamma$-$\frac{5\pi} {3}$)
\\ \\
\bottomrule
\end{tabular}
\end{table}
• Please don't post code fragments and please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. – Ruixi Zhang Jul 28 '18 at 19:19
• You could think about an alternative way of presenting this, as you have to print the same stuff so often. What about adding to the caption $T_a = c \cdot \sin\alpha$ and $T_b = c \cdot \sin\beta$ with $c=...$ and then having columns just for the different arguments of sine? – nox Jul 28 '18 at 19:56
• There is no need to vertically center the number; the small vertical space between rows two and three makes very clear that 1 refers to both rows one and two; similarly for the next groups. Centering the number actually gives a odd look to the table. A (low) period never stands for multiplication; just remove them. – egreg Jul 28 '18 at 21:29

To put the numbers from 1 to 6 in the middle: use \multirow; to align the expression use l instead of c as column type.

But what are all those $in your expressions? You need only one$ at the beginning and one at the end, you could also avoid to write them in every row with this column type specification: >{$}l<{$}.

I think you need to read some beginner's guide, please see here: What are good learning resources for a LaTeX beginner?.

Moreover, use \cdot for . and \sin for sin, and I think there could be also other possible improvements...

\documentclass{article}
\usepackage{amsmath}
\usepackage{array}
\renewcommand{\arraystretch}{1.3}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{caption}
\begin{document}
\begin{table}
\centering
\caption{Expressions des instants de commutation pour chaque secteur}
\begin{tabular}{@{} c >{$}l<{$}  @{}}
\toprule
Sector number & \multicolumn{1}{c}{Expressions}  \\
\midrule
\multirow{2}{*}{1} & T_a=\sqrt{3}\cdot T_s\cdot \frac{V_r}{U_{dc}}\cdot \sin{(\frac{\pi}
{3}-\gamma)}\\
& T_b=\sqrt{3}\cdot T_s\cdot\frac{V_r}{U_{dc}}\cdot\sin{(\gamma)} \\[2ex]
\multirow{2}{*}{2} & T_a=\sqrt{3}\cdot T_s\cdot\frac{V_r}{U_{dc}}\cdot\sin{(\frac{2\pi}
{3}-\gamma)}\\
& T_b=\sqrt{3}\cdot T_s\cdot\frac{V_r}{U_{dc}}\cdot\sin{(\gamma-\frac{\pi}{3})}
\\[2ex]
\multirow{2}{*}{3} & T_a=\sqrt{3}\cdot T_s\cdot\frac{V_r}{U_{dc}}\cdot\sin{(\pi-\gamma)}\\
& T_b=\sqrt{3}\cdot T_s\cdot\frac{V_r}{U_{dc}}\cdot\sin{(\gamma-\frac{2\pi}{3})}
\\[2ex]
\multirow{2}{*}{4} & T_a=\sqrt{3}\cdot T_s\cdot\frac{V_r}{U_{dc}}\cdot\sin{(\frac{4\pi}
{3}-\gamma)}\\
& T_b=\sqrt{3}\cdot T_s\cdot\frac{V_r}{U_{dc}}\cdot\sin{(\gamma-\pi)} \\[2ex]
\multirow{2}{*}{5} & T_a=\sqrt{3}\cdot T_s\cdot\frac{V_r}{U_{dc}}\cdot\sin{(\frac{5\pi}
{3}-\gamma)}\\
& T_b=\sqrt{3}\cdot T_s\cdot\frac{V_r}{U_{dc}}\cdot\sin{(\gamma-\frac{4\pi}
{3})}
\\[2ex]
\multirow{2}{*}{6} & T_a=\sqrt{3}\cdot T_s\cdot\frac{V_r}{U_{dc}}\cdot\sin{(2\pi-\gamma)}\\
& T_b=\sqrt{3}\cdot T_s\cdot\frac{V_r}{U_{dc}}\cdot\sin{(\gamma-\frac{5\pi}
{3})}
\\
\bottomrule
\end{tabular}
\end{table}
\end{document}

• Ah, you were faster, looks good. You can use \begin{tabular}{@{} c >{$}r<{$}@{$\;$}>{$}l<{$} @{}} with \multicolumn{2}{c}{Expressions} and replace all =s with &=s. – nox Jul 28 '18 at 19:38
• @nox Thank you, but I'm not sure that is the OP's desiderata. – CarLaTeX Jul 28 '18 at 19:40
• Sure, but optionally one could mention it. It's useful to align the equations. Raw, like it is now, the equation after T_b is a little shifted. – nox Jul 28 '18 at 19:47
• @nox Why don't you add a new answer? I think you could improve also the fractions and the parenthesis height... – CarLaTeX Jul 28 '18 at 19:55

First off, please take care on how you input math formulas: there are really many errors in

$T_a$=$\sqrt{3}$.$T_s$.$\frac{V_r}{U_{dc}}$.sin($\frac{\pi}{3}$-$\gamma$)

It should be a single formula, using \sin for the sine function; the low period never stands for multiplication in mathematics. Either use \cdot or, even better, nothing at all; however, a thin space is good between a “square root of 3” factor and the following term:

$T_a=\sqrt{3}\,T_s\frac{V_r}{U_{dc}}\sin(\frac{\pi}{3}-\gamma)$

Compare the two outputs.

Now let's consider the table. There is no need to vertically center the sector numbers: a small space between two groups is sufficient; actually the table looks a bit odd with the centered numbers. Anyhow, if you really want it, use \multirow. Never use \\ for adding vertical space between rows: \addlinespace is what you want.

The expressions should be left aligned: they have slightly different widths and centering them would create a jagged column.

Next, a devious trick: since all formulas have a common factor, define a macro for it, which eases input and also allows for adding a phantom that will avoid clashes between the fractions (a \Big bar). This macro is only defined in the particular table environment.

\documentclass{article}
\usepackage{booktabs}

\begin{document}

\begin{table}
\centering
\caption{Expressions des instants de commutation pour chaque secteur}

\newcommand{\commonfactor}{%
\vphantom{\Big|}%
\sqrt{3}\,T_s\frac{V_r}{U_{dc}}%
}

\begin{tabular}{@{} c l  @{}}
\toprule
Sector & \multicolumn{1}{c}{Expressions des instants} \\
number & \multicolumn{1}{c}{de commutation} \\
\midrule
1 & $T_a=\commonfactor\sin(\frac{\pi}{3}-\gamma)$ \\
& $T_b=\commonfactor\sin(\gamma)$ \\
2 & $T_a=\commonfactor\sin(\frac{2\pi}{3}-\gamma)$ \\
& $T_b=\commonfactor\sin(\gamma-\frac{\pi}{3})$ \\
3 & $T_a=\commonfactor\sin(\pi-\gamma)$ \\
& $T_b=\commonfactor\sin(\gamma-\frac{2\pi}{3})$ \\
4 & $T_a=\commonfactor\sin(\frac{4\pi}{3}-\gamma)$ \\
& $T_b=\commonfactor\sin(\gamma-\pi)$ \\
5 & $T_a=\commonfactor\sin(\frac{5\pi}{3}-\gamma)$ \\
& $T_b=\commonfactor\sin(\gamma-\frac{4\pi}{3})$ \\
6 & $T_a=\commonfactor\sin(2\pi-\gamma)$\\
& $T_b=\commonfactor\sin(\gamma-\frac{5\pi}{3})$ \\
\bottomrule
\end{tabular}

\end{table}

\end{document}

If you don't have space constraints (two column typesetting), you can do even better:

\documentclass{article}
\usepackage{booktabs}

\begin{document}

\begin{table}
\centering
\caption{Expressions des instants de commutation pour chaque secteur}

\newcommand{\commonfactor}{%
%  \vphantom{\Big|}%
\sqrt{3}\,T_s\frac{V_r}{U_{dc}}%
}

\begin{tabular}{@{} c l l @{}}
\toprule
Sector & \multicolumn{2}{c}{Expressions des instants de commutation} \\
\midrule
1 & $T_a=\commonfactor\sin(\frac{\pi}{3}-\gamma)$
& $T_b=\commonfactor\sin(\gamma)$ \\
2 & $T_a=\commonfactor\sin(\frac{2\pi}{3}-\gamma)$
& $T_b=\commonfactor\sin(\gamma-\frac{\pi}{3})$ \\
3 & $T_a=\commonfactor\sin(\pi-\gamma)$
& $T_b=\commonfactor\sin(\gamma-\frac{2\pi}{3})$ \\
4 & $T_a=\commonfactor\sin(\frac{4\pi}{3}-\gamma)$
& $T_b=\commonfactor\sin(\gamma-\pi)$ \\
5 & $T_a=\commonfactor\sin(\frac{5\pi}{3}-\gamma)$
& $T_b=\commonfactor\sin(\gamma-\frac{4\pi}{3})$ \\
6 & $T_a=\commonfactor\sin(2\pi-\gamma)$
& $T_b=\commonfactor\sin(\gamma-\frac{5\pi}{3})$ \\
\bottomrule
\end{tabular}

\end{table}

\end{document}

As you see, I commented out the \vphantom{\Big|} in the definition, because here it's not needed.

Here is my try. The first table is quite similar to the one from @CarLaTeX (but was created independently ;)). I use a little more complex table to assure horizontal alignment of the equations.

The second table is my recommendation though. This is much more compact and probably better to remember.

\documentclass{article}
\usepackage{amsmath}
\usepackage{array}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{calc}

\begin{document}

\begin{table}
\renewcommand{\arraystretch}{1.3}
\centering
\caption{Expressions des instants de commutation pour chaque secteur}
\begin{tabular}{@{} c >{$}r<{$}@{$\;$}>{$}l<{$}  @{}}
\toprule
Sector number & \multicolumn{2}{c}{Expressions}  \\
\midrule
\multirow{2}{*}{1}
& T_a=&\sqrt{3} \cdot T_s \cdot \frac{V_r}{U_{dc}} \cdot \sin(\frac{\pi}{3}-\gamma)\\
& T_b=&\sqrt{3} \cdot T_s \cdot \frac{V_r}{U_{dc}} \cdot \sin(\gamma)
\\[2ex]
\multirow{2}{*}{2}
& T_a=&\sqrt{3} \cdot T_s \cdot \frac{V_r}{U_{dc}} \cdot \sin(\frac{2\pi}{3}-\gamma)\\
& T_b=&\sqrt{3} \cdot T_s \cdot \frac{V_r}{U_{dc}} \cdot \sin(\gamma-\frac{\pi}{3})
\\[2ex]
\multirow{2}{*}{3}
& T_a=&\sqrt{3} \cdot T_s \cdot \frac{V_r}{U_{dc}} \cdot \sin(\pi-\gamma)\\
& T_b=&\sqrt{3} \cdot T_s \cdot \frac{V_r}{U_{dc}} \cdot \sin(\gamma-\frac{2\pi}{3})
\\[2ex]
\multirow{2}{*}{4}
& T_a=&\sqrt{3} \cdot T_s \cdot \frac{V_r}{U_{dc}} \cdot \sin(\frac{4\pi}{3}-\gamma)\\
& T_b=&\sqrt{3} \cdot T_s \cdot \frac{V_r}{U_{dc}} \cdot \sin(\gamma-\pi)
\\[2ex]
\multirow{2}{*}{5}
& T_a=&\sqrt{3} \cdot T_s \cdot \frac{V_r}{U_{dc}} \cdot \sin(\frac{5\pi}{3}-\gamma)\\
& T_b=&\sqrt{3} \cdot T_s \cdot \frac{V_r}{U_{dc}} \cdot \sin(\gamma-\frac{4\pi}{3})
\\[2ex]
\multirow{2}{*}{6}
& T_a=&\sqrt{3} \cdot T_s \cdot \frac{V_r}{U_{dc}} \cdot \sin(2\pi-\gamma)\\
& T_b=&\sqrt{3} \cdot T_s \cdot \frac{V_r}{U_{dc}} \cdot \sin(\gamma-\frac{5\pi}{3})
\\[2ex]
\bottomrule
\end{tabular}
\end{table}

\begin{table}
\renewcommand{\arraystretch}{1.3}
\centering
\caption{Expressions des instants de commutation pour chaque secteur}
\parbox{\widthof{$T_a = c \cdot \sin\alpha$,}}{%
\setlength{\abovedisplayskip}{0pt}
\setlength{\belowdisplayskip}{1ex}
\begin{align*}
T_a &= c \cdot \sin\alpha\\
T_b &= c \cdot \sin\beta
with $c=\sqrt{3} \cdot T_s \cdot \frac{V_r}{U_{dc}}$

\begin{tabular}{@{} c >{$}c<{$} @{\qquad} >{$}c<{$}  @{}}
\toprule
Sector number & \alpha & \beta \\
\midrule
1 & \frac{\pi}{3}-\gamma  & \gamma \\
2 & \frac{2\pi}{3}-\gamma & \gamma-\frac{\pi}{3} \\
3 & \pi-\gamma            & \gamma-\frac{2\pi}{3} \\
4 & \frac{4\pi}{3}-\gamma & \gamma-\pi \\
5 & \frac{5\pi}{3}-\gamma & \gamma-\frac{4\pi}{3} \\
6 & 2\pi-\gamma           & \gamma-\frac{5\pi}{3} \\
\bottomrule
\end{tabular}
\end{table}

\end{document}

Another solution without multirow, but with a series of aligned environments in the second column, and a smaller spacing between groups of rows:

\documentclass[french]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage{amsmath}
\usepackage{array}
\renewcommand{\arraystretch}{1.3}
\usepackage{booktabs}
\usepackage{caption}

\begin{document}

\begin{table}
\centering
\caption{Expressions des instants de commutation pour chaque secteur}
\begin{tabular}{@{}c>{$}l<{$} @{}}
\toprule
Sector number & \multicolumn{1}{c}{Expressions} \\
\midrule
1 & \begin{aligned} T_a & =\sqrt{3}\cdot T_s\cdot \frac{V_r}{U_{dc}}\cdot \sin{(\frac{\pi}
{3}-\gamma)}\\
T_b & =\sqrt{3}\cdot T_s\cdot\frac{V_r}{U_{dc}}\cdot\sin{(\gamma)}
\end{aligned} \\
{2} & \begin{aligned} T_a & =\sqrt{3}\cdot T_s\cdot\frac{V_r}{U_{dc}}\cdot\sin{(\frac{2\pi}
{3}-\gamma)}\\
T_b & =\sqrt{3}\cdot T_s\cdot\frac{V_r}{U_{dc}}\cdot\sin{(\gamma-\frac{\pi}{3})}
\end{aligned} \\
3 & \begin{aligned} T_a & =\sqrt{3}\cdot T_s\cdot\frac{V_r}{U_{dc}}\cdot\sin{(\pi-\gamma)}\\
T_b & =\sqrt{3}\cdot T_s\cdot\frac{V_r}{U_{dc}}\cdot\sin{(\gamma-\frac{2\pi}{3})}
\end{aligned} \\
4 & \begin{aligned} T_a & =\sqrt{3}\cdot T_s\cdot\frac{V_r}{U_{dc}}\cdot\sin{(\frac{4\pi}
{3}-\gamma)}\\
T_b & =\sqrt{3}\cdot T_s\cdot\frac{V_r}{U_{dc}}\cdot\sin{(\gamma-\pi)}
\end{aligned} \\
5 & \begin{aligned} T_a & =\sqrt{3}\cdot T_s\cdot\frac{V_r}{U_{dc}}\cdot\sin{(\frac{5\pi}
{3}-\gamma)}\\
T_b & =\sqrt{3}\cdot T_s\cdot\frac{V_r}{U_{dc}}\cdot\sin{(\gamma-\frac{4\pi}
{3})}
\end{aligned} \\