## LaTeX forum ⇒ Text Formatting ⇒ Vertical Centering in tabularx Topic is solved

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Timothée
Posts: 1
Joined: Fri Apr 19, 2019 10:44 am

### Vertical Centering in tabularx  Topic is solved

I have seen many topics on this subject, but it doesn't work with me.

I have a table, and I want to vertical align all the columns.

Consider this code:

\begin{table}[h]\centering\sffamily \begin{tabularx}{\linewidth}{|X|c|c|c|c|c|c|X|}  \hline    \multicolumn{2}{|c|}{Topologie} & \#c & Motif & $v \in V$ obligatoire & $D$ & $\Delta$ & Complexité  \\    \hline   $G$ & $H$ & \multirow{2}{*}{$2$} & \multirow{2}{*}{$=$} & \multirow{2}{*}{$\varnothing$} & \multirow{2}{*}{$\{1, qlc \}$} & \multirow{2}{*}{qlc} & \multirow{2}{*}{Inapprox} \\  \cline{1-2}   Graphe complet, intervalles propres, split-graph, étoile, $2$-coloration valide, graphe-bloc, arbre & qlc &  &  &   &  &  &  \\  \hline\end{tabularx} \normalfont\caption{Synthèse des conditions étudiées.}\label{tab:Appr}\end{table}

As is, this produces:

TAB1.png (17.68 KiB) Viewed 114 times

But I want something like this :

TAB2.png (21.05 KiB) Viewed 114 times

So, how can I have a column verticaly align ?

rais
Posts: 197
Joined: Sun Nov 16, 2014 8:51 pm
Well, you'll have to redefine the X column to be based on a m-column instead of a p-column, see \tabularxcolumn in tabularx' documentation.
Then you have to take into account, that the number of lines is increased by the number of line breaks introduced by the contents of these X columns. As such, 2 is not enough for your \multirow commands.
Or you rearrange the table a bit, no longer needing the \multirows alltogether:
\documentclass[a4paper]{report}\usepackage[T1]{fontenc}\usepackage[french]{babel}\usepackage[left=2cm,right=4cm]{geometry}\usepackage{amssymb}\usepackage{tabularx}\renewcommand\tabularxcolumn[1]{m{#1}}\begin{document}\begin{table}[ht]\centering\sffamily\begin{tabularx}{\linewidth}{|@{}c@{}|c|c|c|c|c|X|}  \hline    Topologie & \#c & Motif & $v \in V$ obligatoire & $D$ & $\Delta$ & Complexité  \\    \hline    {\begin{tabularx}{4cm}{X|c}    $G$ & $H$\\    \hline    Graphe complet, intervalles propres, split-graph, étoile, $2$-coloration valide, graphe-bloc, arbre & qlc\\     \end{tabularx}} &   $2$ & $=$ &$\varnothing$ & $\{1, qlc \}$ & qlc & Inapprox\\  \hline\end{tabularx}\normalfont\caption{Synthèse des conditions étudiées.}\label{tab:Appr}\end{table}\end{document}

Happy Easter;-)
Rainer