1

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}

enter image description here

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

enter image description here

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?

  • 2
    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
1

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}
[...]
1

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{\theadfont}{\normalsize\bfseries}
\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
        \thead{Name} & \thead{Phenomena} & \thead{Type} & \thead{No. \\commands} & \thead{Training} & \thead{Advantages} & \thead{Disadvantages} \\
        \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}

\end{document} 

enter image description here

  • 1
    With ragged2e you do not need \arraybackslash – user2478 Jan 11 at 11:57
  • I didn't know that. Thanks for the information! – Bernard Jan 11 at 12:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.