具有复杂多行结构(包括断续线)的 Latex 表

具有复杂多行结构(包括断续线)的 Latex 表

我是 Latex 的新手,我知道基本的编码,但是我想在 Latex 中创建以下复杂表格(见附件),但我找不到成功的方法。我已经阅读了这里讨论的一些帖子,并尝试了多种解决方案,例如“\multirow”或在“&”符号前留出空格,但到目前为止,没有任何效果。在我看来,最困难的部分是在表格中实现复杂的线结构。例如,当我在“具有内部心腔结构的心脏”行后使用“\hline”时,它还会划分包含“R01:幻影的关键器官”的单元格,但这是不可取的。我希望有人能帮我解决这个问题 :) 抱歉,如果我的解释不够清楚,我很乐意在必要时提供额外的信息。提前谢谢您!

亲切问候 Marthe

在此处输入图片描述

我已经尝试了以下方法:

\begin{table}[!ht]
\caption{Overview of design requirements and specifications for the US compatible thorax phantom}
    \begin{tabular}{|p{3cm}|p{4,5cm}|p{2cm}|p{2cm}|p{2cm}|}
        \hline
        \textbf{Requirement} & \textbf{Specification} & \textbf{Absolute requirement} &\textbf{Desire} & \textbf{Nice-to-have} \\
        \hline
        \multirow{6}{*}{R01: Key organs} & Heart with internal heart chamber structures & \centering{X} &  & \\ \cline{2-5}
            & Ribcage & \centering{X} & & \\ \cline{2-5}
            & Sternum & \centering{X} & & \\ \cline{2-5}
            & Surrounding bulk soft tissue & \centering{X} & & \\ \cline{2-5}
            & Intercostal muscle layer & & \centering{X} & \\ \cline{2-5}
            & Skin layer & & & \centering{X} \\ \cline{2-5}
            & Lungs & & & \centering{X} \\
            \hline
            R02: Dimensions of phantom & Real-life scale.
    \end{tabular}
\label{tab:Overview_of_design_requirements_and_specifications_for_the_US_compatible_thorax_phantom}
\end{table}

答案1

以下是关于如何编写表格的开始建议。

\documentclass{article}

\usepackage{multirow, makecell}

\begin{document}

\begin{table}[!ht]
\caption{Overview of design requirements and specifications for the US compatible thorax phantom}
    \begin{tabular}{|p{3cm}|p{4.5cm}|c|c|c|}
        \hline
        \makecell[l]{\textbf{Requirement}\\ {}} & \makecell[l]{\textbf{Specification}\\ {}} & \makecell[l]{\textbf{Absolute}\\ \textbf{requirement}} &\makecell[l]{\textbf{Desire}\\ {}} & \makecell[l]{\textbf{Nice-to-have}\\ {}} \\
        \hline
        \multirow[t]{6}{*}{R01: Key organs} & Heart with internal heart chamber structures & X &  & \\ \cline{2-5}
            & Ribcage & X & & \\ \cline{2-5}
            & Sternum & X & & \\ \cline{2-5}
            & Surrounding bulk soft tissue & X & & \\ \cline{2-5}
            & Intercostal muscle layer & & X & \\ \cline{2-5}
            & Skin layer & & & X \\ \cline{2-5}
            & Lungs & & & X \\
            \hline
            R02: Dimensions of phantom & Real-life scale. \newline
            ROI:            
            \setlength{\parskip}{-12pt} % Adjust spacing between text and itemize environment
            \begin{itemize}
                \setlength{\itemsep}{-6pt} % Adjust spacing between items
                \item Sternum
                \item Depth
            \end{itemize} & X &  & \\ \hline
            R03: Echnographic realism\newline
            -- US Compatible & US properties \newline SOS $\sim$ 1540 m/s & X & & \\ \hline
    \end{tabular}
\label{tab:Overview_of_design_requirements_and_specifications_for_the_US_compatible_thorax_phantom}
\end{table}

\end{document}

在此处输入图片描述

答案2

tabularray

\documentclass{article}
\usepackage{geometry}
\usepackage{caption}
\usepackage{tabularray} 
\UseTblrLibrary{varwidth}
\usepackage{enumitem}

\begin{document}
\begin{table}[!ht]\centering
\caption{Overview of design requirements and specifications for the US compatible thorax phantom}\label{tab:Overview_of_design_requirements_and_specifications_for_the_US_compatible_thorax_phantom}
  \begin{tblr}{
    colspec={Q[l,m,3cm]X[l,m]Q[c,m]Q[c,m]Q[c,m]},
    vlines, hlines,
    row{1}={font=\bfseries},
    measure=vbox,stretch=-1,
    rowsep=4pt,
    }        
    Requirement & Specification & \SetCell{l} {Absolute\\ requirement} & \SetCell{l} Desire & \SetCell{l} Nice-to-have \\
    \SetCell[r=7]{l} R01: Key organs & Heart with internal heart chamber structures & X &  & \\ 
    & Ribcage & X & & \\ 
    & Sternum & X & & \\ 
    & Surrounding bulk soft tissue & X & & \\ 
    & Intercostal muscle layer & & X & \\ 
    & Skin layer & & & X \\ 
    & Lungs & & & X \\
    R02: Dimensions of phantom & {Real-life scale.\\ RDI:}
    \begin{itemize}[nosep]
    \item[-] Sternum + part of ribs 1--6 which cover the heart
    \item[-] Depth: few cm below heart ($\sim 13$cm)
    \end{itemize}\\
  \end{tblr}
\end{table}
\end{document}

在此处输入图片描述

答案3

{NiceTabular}以下是使用来创建表格的方法nicematrix。不过,我建议使用 样式的表格booktabs

\documentclass{article}
\usepackage{geometry}
\usepackage{caption}
\usepackage{nicematrix}
\NiceMatrixOptions{cell-space-limits=4pt}

\begin{document}

\begin{table}[!ht]
\caption{Overview of design requirements and specifications for the US compatible thorax phantom}
\begin{NiceTabular}{Xp{4.5cm}ccc}[hvlines]
\RowStyle{\bfseries}
Requirement & Specification & \Block{}{Absolute\\ requirement} & Desire & Nice-to-have \\
\Block[l]{7-1}{R01: Key organs} & Heart with internal heart chamber structures & X &  & \\ 
    & Ribcage & X & & \\ 
    & Sternum & X & & \\ 
    & Surrounding bulk soft tissue & X & & \\ 
    & Intercostal muscle layer & & X & \\ 
    & Skin layer & & & X \\ 
    & Lungs & & & X \\
    R02: Dimensions of phantom & Real-life scale. \newline
    ROI:            
    \setlength{\parskip}{-12pt} % Adjust spacing between text and itemize environment
    \begin{itemize}
        \setlength{\itemsep}{-6pt} % Adjust spacing between items
        \item Sternum
        \item Depth
    \end{itemize} & X &  & \\ 
    R03: Echnographic realism\newline
    -- US Compatible & US properties \newline SOS $\sim$ 1540 m/s & X & & \\ 
\end{NiceTabular}
\label{tab:Overview_of_design_requirements_and_specifications_for_the_US_compatible_thorax_phantom}
\end{table}

\end{document}

上述代码的输出

相关内容