# Table organization

In fact, I want the vectors of tension to be centered on the middle and I don't know why there is no space between "vectors of tension". Also, the way the state of switches are presented isn't good. I want to have a good form of this table.

Here is the code that I used:

 \documentclass{article}
\usepackage{amsmath}
\usepackage{array}
\renewcommand{\arraystretch}{1.3}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{caption}
\begin{document}

\begin{table}
\centering
\caption{Les tensions délivrées par l'onduleur selon l'état des
interrupteurs}
\begin{tabular}{@{} c c c  c c c c @{}}
\toprule
$Vectors of tension$ & \multicolumn{3}{c}{state of switchs}  &
\multicolumn{3}{c}{Output voltage} \\
\cmidrule(l){2-4}
\cmidrule(l){5-7}
& a & b & c  & $V_a$ & $V_b$ & $V_c$ \\
\midrule
$V_0$ & 0  &  0 & 0 & 0 & 0 & 0  \\ \\
$V_1$ & 1  &  0 & 0 & $2U_{dc}$/3 & $-U_{dc}$/3 & $-U_{dc}$/3 \\ \\
$V_2$ & 1  &  1 & 0 & $U_{dc}$/3 & $U_{dc}$/3 & $-2U_{dc}$/3 \\ \\
$V_3$ & 0  &  1 & 0 & $-U_{dc}$/3 & $2U_{dc}$/3 & $-U_{dc}$/3 \\ \\
$V_4$ & 0  &  1 & 1 & $-2U_{dc}$/3 & $U_{dc}$/3 & $U_{dc}$/3 \\ \\
$V_5$ & 0  &  0 & 1 & $-U_{dc}$/3 & $-U_{dc}$/3 & $2U_{dc}$/3 \\ \\
$V_6$ & 1  &  0 & 1 & $U_{dc}$/3 & $-2U_{dc}$/3 & $U_{dc}$/3 \\ \\
$V_7$ & 1  &  1 & 1 & 0 & 0 & 0 \\ \\
\bottomrule
\end{tabular}
\end{table}
\end{document}


If you put something within $...$ LaTeX thinks it is a mathematical expression.

To improve the "State of switches" columns, you can use p{...} column type.

I've used also \makecell for the first column header.

\documentclass{article}
\usepackage{amsmath}
\usepackage{array}
\renewcommand{\arraystretch}{1.3}
\newcolumntype{P}{>{\centering\arraybackslash$}p{1.6em}<{$}}
\newcolumntype{C}{>{\centering\arraybackslash$}c<{$}}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{makecell}
\usepackage{caption}

\begin{document}

\begin{table}
\centering
\caption{Les tensions délivrées par l'onduleur selon l'état des
interrupteurs}
\begin{tabular}{@{} C *3P *3C @{}}
\toprule
\multirow{2}{*}{\makecell{Vectors\\ of\\ tension}} & \multicolumn{3}{c}{State of switches}  &
\multicolumn{3}{c}{Output voltage} \\
\cmidrule(lr){2-4}
\cmidrule(lr){5-7}
& a& b & c  & V_a & V_b & V_c \\
\midrule
V_0 & 0  &  0 & 0 & 0 & 0 & 0  \\[1ex]
V_1 & 1  &  0 & 0 & 2U_{dc}/3 & -U_{dc}/3 & -U_{dc}/3 \\[1ex]
V_2 & 1  &  1 & 0 & U_{dc}/3 & U_{dc}/3 & -2U_{dc}/3 \\[1ex]
V_3 & 0  &  1 & 0 & -U_{dc}/3 & 2U_{dc}/3 & -U_{dc}/3 \\[1ex]
V_4 & 0  &  1 & 1 & -2U_{dc}/3 & U_{dc}/3 & U_{dc}/3 \\[1ex]
V_5 & 0  &  0 & 1 & -U_{dc}/3 & -U_{dc}/3 & 2U_{dc}/3 \\[1ex]
V_6 & 1  &  0 & 1 & U_{dc}/3 & -2U_{dc}/3 & U_{dc}/3 \\[1ex]
V_7 & 1  &  1 & 1 & 0 & 0 & 0 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}


Edit:

If you don't want to redefine \arraystretch, you could fine-tune the vertical position of the \multirow like this:

\documentclass{article}
\usepackage{amsmath}
\usepackage{array}
\newcolumntype{P}{>{\centering\arraybackslash$}p{1.6em}<{$}}
\newcolumntype{C}{>{\centering\arraybackslash$}c<{$}}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{makecell}
\usepackage{caption}

\begin{document}

\begin{table}
\centering
\caption{Les tensions délivrées par l'onduleur selon l'état des
interrupteurs}
\begin{tabular}{@{} C *3P *3C @{}}
\toprule
\multirow{2}{*}[-.5ex]{\makecell{Vectors\\ of tension}} & \multicolumn{3}{c}{State of switches}  &
\multicolumn{3}{c}{Output voltage} \\
\cmidrule(lr){2-4}
\cmidrule(lr){5-7}
& a& b & c  & V_a & V_b & V_c \\
\midrule
V_0 & 0  &  0 & 0 & 0 & 0 & 0  \\[1.5ex]
V_1 & 1  &  0 & 0 & 2U_{dc}/3 & -U_{dc}/3 & -U_{dc}/3 \\[1.5ex]
V_2 & 1  &  1 & 0 & U_{dc}/3 & U_{dc}/3 & -2U_{dc}/3 \\[1.5ex]
V_3 & 0  &  1 & 0 & -U_{dc}/3 & 2U_{dc}/3 & -U_{dc}/3 \\[1.5ex]
V_4 & 0  &  1 & 1 & -2U_{dc}/3 & U_{dc}/3 & U_{dc}/3 \\[1.5ex]
V_5 & 0  &  0 & 1 & -U_{dc}/3 & -U_{dc}/3 & 2U_{dc}/3 \\[1.5ex]
V_6 & 1  &  0 & 1 & U_{dc}/3 & -2U_{dc}/3 & U_{dc}/3 \\[1.5ex]
V_7 & 1  &  1 & 1 & 0 & 0 & 0 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}


However, you could modify \arraystretch for one table only, see here: Separate \arraystretch value for every table.

• Everything is good but there is a problem look below – kerdouj kardouj Jul 28 '18 at 20:29
• Do you have \renewcommand{\arraystretch}{1.3} in your actual document? – CarLaTeX Jul 28 '18 at 20:31
• @CarLaTeX, i would not encourage op to his wrong use \\ \\  to make more vertical space between table rows. it should be replaced with something else (for example with \\[1ex]). – Zarko Jul 28 '18 at 20:40
• Isn't ther another way to enlarge the sapce instead of renewcommand{\arraystretch}{1.3} – kerdouj kardouj Jul 28 '18 at 21:12
• @kerdoujkardouj See my edit. – CarLaTeX Jul 29 '18 at 5:24

\makebox(30,-10){\shortstack{Vectors\\ of\\ tension}} &
\multicolumn{3}{c}{\text{State of switches}}  &
\multicolumn{3}{c}{\text{Output voltage}} \\\cmidrule(lr){2-4}\cmidrule(lr){5-7}
& a  & b & c & \MC{V_a}   & \MC{V_b}   & \MC{V_c} \\ \midrule
V_0 & 0  & 0 & 0 & \0         & \0         & \0  \\
V_1 & 1  & 0 & 0 & 2U_{dc}/3  & -U_{dc}/3  & -U_{dc}/3 \\
V_2 & 1  & 1 & 0 & U_{dc}/3   & U_{dc}/3   & -2U_{dc}/3 \\
V_3 & 0  & 1 & 0 & -U_{dc}/3  & 2U_{dc}/3  & -U_{dc}/3 \\
V_4 & 0  & 1 & 1 & -2U_{dc}/3 & U_{dc}/3   & U_{dc}/3 \\
V_5 & 0  & 0 & 1 & -U_{dc}/3  & -U_{dc}/3  & 2U_{dc}/3 \\
V_6 & 1  & 0 & 1 & U_{dc}/3   & -2U_{dc}/3 & U_{dc}/3 \\
V_7 & 1  & 1 & 1 & \0         & \0         & \0 \\
\bottomrule
\end{array}\$
\end{table}

\end{document}