在 tabularx 表中的特定单元格中添加居中换行符

在 tabularx 表中的特定单元格中添加居中换行符

我知道这是一个常见问题,但我尝试了几种解决方案,但都不起作用。我想在“after”之后创建一个新的断点,并且内容仍然居中:

我想要的转变

这是从这张大表中得到的:

完整表格

这是代码。我正在使用tabularx。我感兴趣的行标有%%%%%%% THIS LINE %%%%%%%%%

\begin{table}[p]
    \caption{Studies that have performed beat-to-beat analyses of the electrocardiogram for predicting atrial fibrillation.}
    \label{table:AF_prediction_b2b}
    \footnotesize
    \setlist[itemize]{nosep,
        leftmargin=*,
        before=\vspace{-0.6\baselineskip},
        after=\vspace{-\baselineskip}
    }
    \setlength\tabcolsep{6pt}
    \begin{tabularx}{\linewidth}{@{}
            >{\hsize=0.5\hsize}L
            >{\hsize=0.5\hsize}L
            c L
            >{\hsize=0.9\hsize}L
            >{\hsize=0.7\hsize}L
            @{}}
        \toprule
        \thead[bl]{Study \\ name}
        &   \thead[lb]{Cohort\\ dimension}
        &   \thead[lb]{Time before\\ AF onset}
        &   \thead[bl]{ECG\\ features}
        &   \thead[lb]{Used metric}
        &   \thead[lb]{Model\\ (accuracy)}            \\
        \midrule
        Martinez \textit{et al.} \cite{Martinez2012}
        &   24 PAF
        &   2h
        &   \begin{itemize}
            \item   P-wave intervals
            \item   Heart rate
        \end{itemize}                                                                                                                   &   Linear regression slope of the variability
        &   Linear discriminant (\SI{90.79}{\%})                \\
        \addlinespace
        Martinez \textit{et al.} \cite{Martinez2014}
        &   46 PAF + 53 healthy
        &   2h
        &   \begin{itemize}
            \item   P-wave morphology: area, conduction velocity, arc-length
        \end{itemize}
        &   Linear regression slope of the variability
        &   Decision tree (\si{86.33}{\%})                      \\
        \addlinespace
        Martinez \textit{et al.} \cite{Martinez2015a}
        &   46 PAF + 53 healthy
        &   2h
        &   \begin{itemize}
            \item   Gaussian fit parameters (A,C, W) and error
        \end{itemize}
        &   Linear regression slope of the variability
        &   Stepwise discriminant analysis (\SI{86.69}{\%}) \\
        \addlinespace
        Sovilj \textit{et al.} \cite{Sovilj2010}
        &    14 POAF + 36 healthy
        &   48h after CABG %%%%%%% THIS LINE %%%%%%%%%
        &   \begin{itemize}
            \item   P-wave intervals
            \item   Heart rate
            \item   Wavelet energies and entropy
        \end{itemize}
        &   Cumulative rank with statistically significant features
        &   Decision tree [applied over the time-course] (\SI{85.3}{\%}) \\
        \addlinespace
        Ovreiu \textit{et al.} \cite{Ovreiu2011}
        &   37 POAF + 53 healthy
        &   30m
        &   \begin{itemize}
            \item   Number of premature atrial complexes
            \item   HRV: mean, SDRR, rMSSD, total power, LF/HF, entropy
            \item   P-wave duration, amplitude, shape, inflection point, energy ratio
        \end{itemize}
        &   Mean value
        & Neuro-fuzzy (\SI{70}{\%})                                     \\
        \addlinespace
        Martinez \textit{et al.} \cite{Martinez2015}
        &   46 PAF
        &   2h
        &   \begin{itemize}
            \item   P-wave intervals
            \item   P-wave area, arc-length
        \end{itemize}
        &   Central tendency measurement
        &   Decision tree (\SI{90}{\%})                                 \\
        \addlinespace
        Alcaraz \textit{et al.} \cite{Alcaraz2015b}
        &   46 PAF + 53 healthy
        &   2h
        &   \begin{itemize}
            \item   P-wave frequency energies
        \end{itemize}
        &   Linear regression slope of the variability
        &   Stepwise discriminant analysis (\SI{80}{\%})                \\

        \addlinespace
        Censi \textit{et al.} \cite{Censi2016}
        &   73 pers. AF + 20 healthy
        &   n/a
        &   \begin{itemize}
            \item P-wave duration and dispersion
            \item P-wave morphology: polarity changes, fragmented conduction index
            \item P-wave variability: amplitude dispersion index, correlation coefficient, DTW
        \end{itemize}
        &   Mean value
        &   Receiver operating characteristic curves (\SI{100}{\%})                \\

        \bottomrule
    \end{tabularx}
\footnotesize
\end{table}

谁能帮我?

答案1

您正在使用makecell; 然后

\makecell[tc]{48h after \\ CABG}

就足够了。

答案2

使用tabularx环境时,必须确保\hsize修饰符的总和等于类型的列数X。如果您将第三列的列类型从 更改cC(请参阅下面的 定义C),并且如果您解决了第一句中提到的问题,您甚至不需要通过指令指定显式换行符\thead

在此处输入图片描述

\documentclass{article}
% Set page size parameters suitably
\usepackage[letterpaper,margin=1in]{geometry} 
\usepackage[english]{babel}

\usepackage{tabularx,ragged2e,booktabs,siunitx}
\newcolumntype{L}{>{\RaggedRight\arraybackslash\hspace{0pt}}X}
\newcolumntype{C}{>{\Centering\arraybackslash\hspace{0pt}}X}

\usepackage[skip=0.333\baselineskip]{caption} % optional

\usepackage{enumitem}
%% Define a custom itemize-like environment:
\newlist{mylist}{itemize}{1}
\setlist[mylist]{label={\footnotesize\textbullet},
         nosep, leftmargin=*, 
         before=\begin{minipage}[t]{\hsize},
         after=\end{minipage}}

\begin{document}
\begin{table}[p]
\caption{Studies that have performed beat-to-beat analyses of the electrocardiogram for predicting atrial fibrillation.}
\label{table:AF_prediction_b2b}
    %\footnotesize -- doesn't seem to be necessary
    \setlength\tabcolsep{4pt}
    \begin{tabularx}{\textwidth}{@{}
            %% Note: 0.6+0.7+0.9+1.9+1.0+0.9 = 6
            >{\hsize=0.6\hsize}L
            >{\hsize=0.7\hsize}L 
            >{\hsize=0.9\hsize}C
            >{\hsize=1.9\hsize}L
            >{\hsize=1.0\hsize}L
            >{\hsize=0.9\hsize}L
            @{}}
        \toprule
        Study name
        & Cohort dimension
        & Time before AF onset
        & ECG features
        & Used metric
        & Model \newline (accuracy) \\
        \midrule
        Martinez \textit{et~al.} \cite{Martinez2012}
        &   24 PAF
        &   2h
        &   \begin{mylist}
            \item   P-wave intervals
            \item   Heart rate
            \end{mylist}
        &   Linear regression slope of the variability
        &   Linear discriminant (\SI{90.79}{\%})                \\
        \addlinespace
        Martinez \textit{et~al.} \cite{Martinez2014}
        &   46 PAF + 53 healthy
        &   2h
        &   \begin{mylist}
            \item P-wave morphology: area, conduction velocity, arc-length
            \end{mylist}
        &   Linear regression slope of the variability
        &   Decision tree (\si{86.33}{\%})                      \\
        \addlinespace
        Martinez \textit{et~al.} \cite{Martinez2015a}
        &   46 PAF + 53 healthy
        &   2h
        &   \begin{mylist}
            \item   Gaussian fit parameters (A, C, W) and error
            \end{mylist}
        &   Linear regression slope of the variability
        &   Stepwise discriminant analysis (\SI{86.69}{\%}) \\
        \addlinespace
        Sovilj \textit{et~al.} \cite{Sovilj2010}
        &   14 POAF + 36 healthy
        &   48h after CABG %%%%%%% THIS LINE %%%%%%%%%
        &   \begin{mylist}
            \item   P-wave intervals
            \item   Heart rate
            \item   Wavelet energies and entropy
            \end{mylist}
        &   Cumulative rank with statistically significant features
        &   Decision tree [applied over the time-course] (\SI{85.3}{\%}) \\
        \addlinespace
        Ovreiu \textit{et~al.} \cite{Ovreiu2011}
        &   37 POAF + 53 healthy
        &   30m
        &   \begin{mylist}
            \item   Number of premature atrial complexes
            \item   HRV: mean, SDRR, rMSSD, total power, LF/HF, entropy
            \item   P-wave duration, amplitude, shape, inflection point, energy ratio
            \end{mylist}
        &   Mean value
        & Neuro-fuzzy (\SI{70}{\%})                                     \\
        \addlinespace
        Martinez \textit{et~al.} \cite{Martinez2015}
        &   46 PAF
        &   2h
        &   \begin{mylist}
            \item   P-wave intervals
            \item   P-wave area, arc-length
            \end{mylist}
        &   Central tendency measurement
        &   Decision tree (\SI{90}{\%})                                 \\
        \addlinespace
        Alcaraz \textit{et~al.} \cite{Alcaraz2015b}
        &   46 PAF + 53 healthy
        &   2h
        &   \begin{mylist}
            \item   P-wave frequency energies
            \end{mylist}
        &   Linear regression slope of the variability
        &   Stepwise discriminant analysis (\SI{80}{\%})                \\
        \addlinespace
        Censi \textit{et~al.} \cite{Censi2016}
        &   73 pers. AF + 20 healthy
        &   n/a
        &   \begin{mylist}
            \item P-wave duration and dispersion
            \item P-wave morphology: polarity changes, fragmented conduction index
            \item P-wave variability: amplitude dispersion index, correlation coefficient, DTW
            \end{mylist}
        &   Mean value
        &   Receiver operating characteristic curves (\SI{100}{\%})                
        \\
        \bottomrule
    \end{tabularx}
\footnotesize
\end{table}
\end{document} 

相关内容