这是我当前的代码:
\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}
我想将行水平居中,以便得到如下效果:
有任何想法吗?
编辑:现在我可以使用 将行居中\renewcommand\tabularxcolumn[1]{m{#1}}
,但无法使用 修改宽度百分比,\newcolumntype{m}{>{\hsize=.5\hsize}X}
因为它无法编译。有没有同时实现两者的解决方案?
答案1
做不是 使用预定义的列类型 b 和 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}
[...]
答案2
您对系数的计算是错误的:系数的总和必须等于总列数X
。例如,如果您想要有 3 个 X 列,其中 1 个是其他两个的一半宽,那么您必须有前言
\begin{tabularx{>{\hsize=1.2\hsize}X>{\hsize=1.2\hsize}X>{\hsize=0.6\hsize}X}
无论如何,我建议对三个较大的单元格使用标准 X 列,对其他四个单元格使用 c 列,并结合使用 命令\thead
,makecell
这样可以实现换行和单元格的通用格式:
\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}