# Horizontal centering in tabularx cells

This is my current code:

\newcolumntype{b}{X}
\newcolumntype{m}{>{\hsize=.5\hsize}X}
\newcolumntype{s}{>{\hsize=.2\hsize}X}
\begin{table}
\caption{Summary of the Most Common BCI Control Signals}
\centering
\begin{tabularx}{\textwidth}{sbmmsbb}
\hline
\textbf{Name} & \textbf{Phenomena} & \textbf{Type} & \textbf{No. commands} & \textbf{Training} & \textbf{Advantages} & \textbf{Disadvantages} \vspace{4pt}\\
\hline

SSVEP & Oscillatory signals at the same frequency than a flickering visual stimuli & Exogenous & High & No & Very high transmission rates \newline No training required & Possible visual fatigue and epileptic seizures \newline No. commands limited by the standardized refreshing rate of LCD screens \newline Requires gaze control\vspace{4pt}\\
\hline
\end{tabularx}
\end{table}


I want to horizontally center the row in order to get something like this:

Any ideas?

EDIT: Now I can center the rows using \renewcommand\tabularxcolumn[1]{m{#1}}, but I cannot modify the percentage of widths using \newcolumntype{m}{>{\hsize=.5\hsize}X} because it does not compile. Any solution to have both at the same time?

• What you are asking for is usually referred to as "vertical centering". Have a look at tex.stackexchange.com/questions/343028/…. – zetaeffe Jan 11 at 10:19
• @zetaeffe oops you are right I misread and have deleted my comment (showing how to do horizontal centering) – David Carlisle Jan 11 at 10:40
• @zetaeffe Thank you! The redefining of '\renewcommand\tabularxcolumn[1]{m{#1}}' works. However, it seems that there is some incompatibility if I also use '\newcolumntype{m}{>{\hsize=.5\hsize}X}' to redefine the widths... Is there any way to achieve this? – Víctor Martínez Jan 11 at 11:16
• Regarding your edit: Using \newcolumntype{a}{>{\hsize=.5\hsize}X} will work. If you include \renewcommand\tabularxcolumn[1]{m{#1}} into your document, an m type column (vertically centered, fixed width, automatical linebreaks) is already defined, so using \newcolumntype{m} will lead to an error. – leandriis Jan 11 at 11:27

Do not use the predefined column types b and m:

[...]
\usepackage{tabularx}
\renewcommand\tabularxcolumn[1]{m{#1}}
\newcolumntype{B}{X}
\newcolumntype{M}{>{\hsize=.5\hsize}X}
\newcolumntype{s}{>{\hsize=.2\hsize}X}

\begin{document}

\begin{table}
\caption{Summary of the Most Common BCI Control Signals}
\begin{tabularx}{\textwidth}{sBMMsBB}
[...]


Your computation of the coefficients is wrong: the sum of the coefficients must be equal to the total number of X columns. For instance, if you want to have 3 X columns, of which 1 is half as wide as the other two, you have to have as preamble

\begin{tabularx{>{\hsize=1.2\hsize}X>{\hsize=1.2\hsize}X>{\hsize=0.6\hsize}X}


Anyway, I suggest using standard X columns for the three larger ones, and c columns for the other four, combined with the \thead command from makecell, which allows for line breaks and a common formatting of cells:

\documentclass{article}
\usepackage[showframe, hmargin=2cm]{geometry}
\usepackage{tabularx, ragged2e, caption, makecell}
\renewcommand{\tabularxcolumn}[1]{>{\RaggedRight}m{#1}}
\setlength{\extrarowheight}{2pt}

\begin{document}

\begin{table}[!htb]
\caption{Summary of the Most Common BCI Control Signals}
\centering\setlength{\tabcolsep}{3pt}
\begin{tabularx}{\textwidth}{cXcccXX}
\hline

• With ragged2e you do not need \arraybackslash – user2478 Jan 11 at 11:57