创建具有多列和多行的复杂表格

创建具有多列和多行的复杂表格

我正在尝试在 latex 文档中以更简单的格式重新创建下表。但是我越处理它,它就越乱。我真的不明白当我使用\multirow\multicolumn

矩阵

这就是我目前所拥有的。我确实更喜欢我的桌子的外观,而不是图片中的设计,但布局难以阅读。

\begin{table}[h]
\centering
\begin{tabular}{l||c c c c c c c}
 Variables & \multicolumn{7}{c}{Values} \\
 \hline \hline

Approach & \multicolumn{2}{c}{\textbf{\textit{Qualitative}}} \multicolumn{2}{c}{Quantitative} & \multicolumn{3}{c}{ }  \\
 \hline

 Artifact Focus & \multicolumn{2}{c}{\textbf{\textit{Technical}}} & \multicolumn{2}{c}{Organizational} & \multicolumn{3}{c}{Strategic} \\
 \hline

 Artifact Type & \multicolumn{1}{c}{Construct} & \multicolumn{1}{c}{Model} & \multicolumn{2}{c}{\textbf{\textit{Method}}} & \multicolumn{2}{c}{Instantiation} & \multicolumn{2}{c}{Method} \\
 \hline

Epistemology & \multicolumn{3}{c}{\textbf{\textit{Positivism}}} & \multicolumn{4}{c}{Interpretivism}  \\
\hline

Function & \multicolumn{2}{c}{\textbf{\textit{Knowledge}}} & \multicolumn{2}{c}{Control} & \multicolumn{2}{c}{Development} & \multicolumn{1}{c}{Legitimization} \\
\hline

\multirow{2}{*}{Method} & Action research & \textbf{\textit{Case study}} & Field experiment \\  Formal proof & Controlled experiment & Prototype & Survey \\
\hline

 Object & \multicolumn{3}{c}{\textbf{\textit{Artifact}}} & \multicolumn{4}{c}{Artifact construction}  \\
\hline

Ontology & \multicolumn{3}{c}{\textbf{\textit{Realism}}} & \multicolumn{4}{c}{Nominalism}  \\
\hline

Perspective & \multicolumn{2}{c}{Economic} & \multicolumn{2}{c}{Deployment} & \multicolumn{2}{c}{\textbf{\textit{Engineering}}} & \multicolumn{1}{c}{Epistemological} \\
\hline

Position & \multicolumn{3}{c}{Internally} & \multicolumn{4}{c}{\textbf{\textit{Externally}}} \\
 \hline

Reference Point & \multicolumn{2}{c}{Artifact against research gap} & \multicolumn{2}{c}{\textbf{\textit{Artifact against real world}}} & \multicolumn{3}{c}{Research gap against real world} \\
\hline

Time & \multicolumn{3}{c}{Ex Ante} & \multicolumn{4}{c}{\textbf{\textit{Ex Post}}}
 \hline 

\end{tabular}
\caption{Evaluation configuration}
\label{tab:dsr}
\end{table}

答案1

此表的要点是将固定宽度的行切割成等距宽度的块。每行都有不同数量的此类块,由垂直线分隔。

我们可以创建宏\l来完成这项工作。不需要表/表格环境。例如:

\def\tstrut{\vrule height12pt depth5pt width0pt}
\def\l#1{\hbox to15cm\bgroup \tstrut\vrule \lA#1||}
\def\lA#1|{\ifx|#1|\egroup\hrule \else \hfil\lB{#1}\hfil\vrule \expandafter\lA\fi}
\def\lB#1{\hbox to0pt{\hss\ignorespaces#1\unskip\hss}}

\vbox{\hrule
   \l{ Qualitative | Quantitative }
   \l{ Technical | Organizational | Strategic }
   \l{ Construct | Model | Method | Instantiation | Theory }
   \l{ Positivism | Interpretivism }
   \l{ Knowledge function | Control function | Development function | Legitimization function }
   \l{ Action reserach | Case study | Field experiment | Formal proofs }
}

\bye

给出结果:

表格

编辑:作为对您的评论的回应,我可以向您展示如何创建包括左列跨行项在内的整个表格。

但是,因为我不支持 LaTeX,所以我的解决方案不是用 LaTeX 编写的。下面的代码是在纯 TeX 中使用 OPmac 宏包(这里仅用于颜色管理和字体调整)工作的。你可以从代码中得到启发,将颜色管理替换为类似 LaTeX 的形式。该\hbox/\vbox算法适用于 LaTeX / 纯 TeX。我希望我的代码表明有关的知识\hbox/\vbox一定会有用。

\input opmac
\def\Grey{\setcmykcolor{0 0 0 .8}}
\input chelvet
\typosize[8.5/11]
\rulewidth=.8pt

\def\tstrut{\vrule height12pt depth5pt width0pt}
\def\doublestrut{\def\tstrut{\vrule height20pt depth14.8pt width0pt}}
\def\cbox#1#2#3#4{\hbox{\rlap{#2\tstrut\vrule width#1}\hbox to#1{\hfil#3#4\hfil}}}
\def\l#1{\hbox to13cm\bgroup \tstrut\vrule \lA#1||}
\def\lA#1|{\ifx|#1|\egroup\hrule \else \hfil\lB{#1}\hfil\vrule \expandafter\lA\fi}
\def\lB#1{\hbox to0pt{\hss\ignorespaces#1\unskip\hss}}
\def\c#1{\cbox{2.2cm}\Grey\White{#1}}

\hbox{\let\Grey=\Black    \c{Variable}\kern1mm \cbox{13cm}\Black\White{Value}}
\nointerlineskip \kern1mm
\hbox{%
\vtop{\lineskip=.8pt \kern0pt
   \c{Approach}
   \c{Artifact Focus}
   \c{Artifact Type}
   \c{Epistemology}
   \c{Function}
   {\doublestrut\c{Method}}
   \c{Object}
}\kern1mm
\vtop{\hrule
   \l{ Qualitative | Quantitative }
   \l{ Technical | Organizational | Strategic }
   \l{ Construct | Model | Method | Instantiation | Theory }
   \l{ Positivism | Interpretivism }
   \l{ Knowledge function | Control function | Development function | Legitimization function }
   \l{ Action reserach | Case study | Field experiment | Formal proofs }
   \l{ Controlled experiment | Prototype | Survey }
   \l{ Artifact | Artifact construction }
}%
}
\bye

结果:

表2

相关内容