\tabular \tabularx 和 \multicolumn 的问题

\tabular \tabularx 和 \multicolumn 的问题

我正在尝试编写以下“哥特式”表格,但是在文本均匀分布的间距和大小方面遇到了很多麻烦。

我使用表格尝试以下操作:

    \begin{table}
        \begin{center}
            \begin{tabular*}{\textwidth}{p{0.2\textwidth}p{0.2\textwidth}p{0.2\textwidth}p{0.2\textwidth}p{0.2\textwidth}}
                \hline \hline 
                \rule[-1ex]{0pt}{4ex} \multirow{6}{*}{\includegraphics[width=20mm]{./Muscles/biceps.jpg}} & \bf{Origin} & \multicolumn{3}{l}{Short head: tip of coracoid process of scapula; Long head: supraglenoid tubercle of scapula}\\
                \cline{2-5} \rule[-1ex]{0pt}{4ex} & \bf{Insertion} & \multicolumn{3}{l}{Tuberosity of radius and fascia of forearm via bicipital aponeurosis} \\
                \cline{2-5} \rule[-1ex]{0pt}{4ex} & \bf{Action} & \multicolumn{3}{l}{Supinates forearm and, when it is supine, flexes forearm} \\
                \cline{2-5} \rule[-1ex]{0pt}{4ex} & \bf{Innervation} & \multicolumn{3}{l}{Musculocutaneous nerve (C5 and C6 ) (C5, C6)} \\
                \cline{2-5} \rule[-1ex]{0pt}{4ex} & $F^{max}_{iso}$ & $\alpha$ & $l^{CE}_{opt}$ & $l^{T}_{sclack}$ \\
                \rule[-1ex]{0pt}{4ex} & [N] & [deg] & [m] & [m] \\
                \hline \hline
            \end{tabular*}
            \caption{Threshold and saturation values for the experimental subject.}
            \label{tabpar2}
        \end{center}
    \end{table}

通过此代码,我获得以下内容,其中错误是行末没有中断: 带表格的结果

另一方面,如果我尝试以下代码,则换行符和最后一列将均匀分布,但多列不起作用:

    \begin{table}
        \begin{center}
            \begin{tabularx}{\textwidth}{clXXX}
                \hline \hline 
                \rule[-1ex]{0pt}{4ex} \multirow{6}{*}{\includegraphics[width=20mm]{./Muscles/biceps.jpg}} & \bf{Origin} & \multicolumn{3}{X}{Short head: tip of coracoid process of scapula; Long head: supraglenoid tubercle of scapula}\\
                \cline{2-5} \rule[-1ex]{0pt}{4ex} & \bf{Insertion} & \multicolumn{3}{X}{Tuberosity of radius and fascia of forearm via bicipital aponeurosis} \\
                \cline{2-5} \rule[-1ex]{0pt}{4ex} & \bf{Action} & \multicolumn{3}{X}{Supinates forearm and, when it is supine, flexes forearm} \\
                \cline{2-5} \rule[-1ex]{0pt}{4ex} & \bf{Innervation} & \multicolumn{3}{X}{Musculocutaneous nerve (C5 and C6 ) (C5, C6)} \\
                \cline{2-5} \rule[-1ex]{0pt}{4ex} & $F^{max}_{iso}$ & $\alpha$ & $l^{CE}_{opt}$ & $l^{T}_{sclack}$ \\
                \rule[-1ex]{0pt}{4ex} & [N] & [deg] & [m] & [m] \\
                \hline \hline
            \end{tabularx}
            \caption{Threshold and saturation values for the experimental subject.}
            \label{tabpar2}
        \end{center}
    \end{table}

结果如下: 带表格 X 的结果

有什么解决办法可以解决这个问题吗???

多谢

答案1

诀窍基本上是使用

\multicolumn{3}{>{\hsize=3\hsize}X}

稍作调整。我会为这种表格定义一个新的环境,以图像数据作为参数。图像本身由固定\muscleimage命令放置,以尽可能避免复杂的代码。

\documentclass{article}
\usepackage[demo]{graphicx} % demo is just for the example
\usepackage{tabularx,booktabs,amsmath,adjustbox}

\newcommand{\muscleimage}{}
\newenvironment{muscle}[2][]
 {%
  \renewcommand{\muscleimage}{%
    \adjustbox{valign=t,set depth=0pt}{\includegraphics[#1]{#2}}%
  }%
  \tabularx{\textwidth}{clXXX}
 }
 {%
  \endtabularx
 }
\newcommand{\fulltable}[1]{%
  \multicolumn{3}{>{\hsize=\dimexpr3\hsize+4\tabcolsep\raggedright\arraybackslash}X}{#1}%
}

\begin{document}

\begin{table}
\centering
\begin{muscle}[height=40mm,width=20mm]{./Muscles/biceps.jpg}
\toprule
\muscleimage
& \textbf{Origin}
& \fulltable{
    Short head: tip of coracoid process of scapula; Long head: supraglenoid tubercle of scapula
  } \\
\cmidrule{2-5}
& \textbf{Insertion}
& \fulltable{
    Tuberosity of radius and fascia of forearm via bicipital aponeurosis
  } \\
\cmidrule{2-5}
& \textbf{Action}
& \fulltable{
    Supinates forearm and, when it is supine, flexes forearm
  } \\
\cmidrule{2-5}
& \textbf{Innervation}
& \fulltable{
    Musculocutaneous nerve (C5 and C6 ) (C5, C6)
  } \\
\cmidrule{2-5}
& $F^{\textup{max}}_{\textup{iso}}$
& $\alpha$ & $l^{\textup{CE}}_{\textup{opt}}$
& $l^{T}_{\textup{sclack}}$ \\
& [N] & [deg] & [m] & [m] \\
\bottomrule
\end{muscle}
\caption{Threshold and saturation values for the experimental subject.}
\label{tabpar2}
\end{table}

\end{document}

在此处输入图片描述

答案2

tabularx以下是使用和 的解决方案booktabs。我制作了最后三列X,并定义了一种新的Y列类型,其行为与 X 相同,但宽度是原来的三倍,用于multicolumn{3}。无需不可见的垂直规则:它们在序言中被替换为特别指定\aboverulesep和的值\belowrulesep。该multirow命令可能需要另一次调整才能垂直居中,具体取决于实际图像。

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[showframe, nomarginpar]{geometry}
\usepackage{multirow}
\usepackage{mathtools}
\usepackage{array, caption, tabularx, booktabs}
\usepackage[demo]{graphicx}

\setlength{\aboverulesep}{1ex}
\setlength{\belowrulesep}{1.5ex}
\newcolumntype{Y}{{>{\hsize=3\hsize}X}}

\begin{document}
\begin{table}
    \centering
        \begin{tabularx}{\linewidth}{ll*{3}{X}}
            \toprule\midrule
            \multirow{6}{*}[-5.25ex]{\includegraphics[width=20mm]{./Muscles/biceps.jpg}} & \bf{Origin} & \multicolumn{3}{Y}{Short head: tip of coracoid process of scapula; Long head: supraglenoid tubercle of scapula}\\
            \cmidrule{2-5} & \bf{Insertion} & \multicolumn{3}{Y}{Tuberosity of radius and fascia of forearm via bicipital aponeurosis} \\
            \cmidrule{2-5} & \bf{Action} & \multicolumn{3}{Y}{Supinates forearm and, when it is supine, flexes forearm} \\
            \cmidrule{2-5} & \bf{Innervation} & \multicolumn{3}{Y}{Musculocutaneous nerve (C5 and C6 ) (C5, C6)} \\
            \cmidrule{2-5}& $F^{\max}_\mathrm{iso}$ & $\alpha$ & $l^{CE}_\mathrm{opt}$ & $l^{T}_\mathrm{sclack}$ \\
    \addlinespace[1.5ex]
             & [N] & [deg] & [m] & [m] \\
            \midrule \bottomrule
        \end{tabularx}
        \caption{Threshold and saturation values for the experimental subject.}
        \label{tabpar2}
\end{table}

\end{document} 

在此处输入图片描述

相关内容