答案1
作为tikz
图像,使用fit
和matrix
库和enumitem
包:
\documentclass[tikz, margin=5mm]{standalone}
\usetikzlibrary{fit,
matrix}
\usepackage{enumitem}
\begin{document}
\begin{center}
\setlist[itemize]{nosep,
leftmargin = * ,
before = \vspace{-0.4\baselineskip},
}
\begin{tikzpicture}[
F/.style args = {#1/#2/#3}{draw, fill=#1,
label={[text width=120mm,
text=#2,
align=center]center:#3},
inner sep=0pt, outer sep=0pt,
node contents={}
},
font = \sffamily
]
\matrix (m) [matrix of nodes,
nodes in empty cells,
nodes={thin, draw,
minimum height=4ex, text width=30mm,
inner sep=1mm, outer sep=0pt, anchor=north},
column sep=2mm,
row sep=2mm,
row 3/.style = {nodes={fill=black, text=white}},
row 4/.style = {nodes={minimum height=5.4\baselineskip}},
row 5/.style = {row sep=\pgflinewidth,
nodes={fill=black, text=white}},
]
{
& & & \\
& & & \\
Primary Objectives
& Experimental design
& Fixed Section/Part
& Testing Variables \\
\begin{itemize}
\item first item
\item second item
\item third item has at least two lines
\end{itemize}\vfill
& \begin{itemize}
\item first item
\item second item
\item third item has at least two lines
\item forth item
\end{itemize}
& \begin{itemize}
\item first item
\item second item
\item third item has at least two lines
\item forth item
\end{itemize}
& \begin{itemize}
\item first item
\item second item
\item third item has at least two lines
\item forth item
\end{itemize} \\
& & & \\
& & & \\[4mm]
& & & \\
& & & \\
};
\node[F=gray!30/black/Study 1,
fit=(m-1-1) (m-1-4)];
\node[F=white/black/{Aim: Investigate the peformance /
and some more text},
fit=(m-2-1) (m-2-4)];
\node[F=black/white/Hyaphotesis,
fit=(m-5-1) (m-5-4)];
\node[F=white/black/\begin{itemize}
\item H1: Investigate the peformance
\item H2: Investigate the peformance
\end{itemize},
minimum height=2\baselineskip,
fit=(m-6-1) (m-6-4)];
\node[F=gray!30/black/Study 2,
fit=(m-7-1) (m-7-4)];
\node[F=white/black/{Aim: Investigate the peformance /
and some more text},
fit=(m-8-1) (m-8-4)];
\end{tikzpicture}
\end{center}
\end{document}
注意:如果您想在图表中添加更多“适合”节点,例如节点
\node[F=gray!30/black/Study 3, fit=(m-9-1) (m-9-4)];
您需要先将矩阵扩展一行并使其具有空单元格。
答案2
以下内容tabularx
可作为起点:
\documentclass{article}
\usepackage{tabularx}
\usepackage[table]{xcolor}
\usepackage{calc}
\usepackage{hhline}
\begin{document}
\noindent
\begin{tabularx}{\textwidth}{|*{3}{>{\raggedright\arraybackslash}X|c|}X|}
\hline
\multicolumn{7}{|>{\centering\arraybackslash}p{\textwidth-2\tabcolsep-2\arrayrulewidth}|}{\cellcolor{gray}Study 1}\\
\hline
\multicolumn{7}{c}{}\\
\hline
\multicolumn{7}{|>{\centering\arraybackslash}p{\textwidth-2\tabcolsep-2\arrayrulewidth}|}{Aim: some text here}\\
\hline
\multicolumn{7}{c}{}\\
\hhline{-~-~-~-}
\cellcolor{black}\textcolor{white}{Primary Objectives} && \cellcolor{black}\textcolor{white}{Experimental Design} && \cellcolor{black}\textcolor{white} {Fixed Section/ Part} && \cellcolor{black}\textcolor{white} {Testing Variables}\\
\hhline{-~-~-~-}
\multicolumn{7}{c}{}\\
\hhline{-~-~-~-}
some text here && some other text here && more in this cell && additional text here\\
\hhline{-~-~-~-}
\multicolumn{7}{c}{}\\
\hline
\multicolumn{7}{|>{\centering\arraybackslash}p{\textwidth-2\tabcolsep-2\arrayrulewidth}|}{\cellcolor{black}\textcolor{white}{Hypothesis}}\\
\hline
\end{tabularx}
\end{document}
答案3
我认为 leandriis 的答案是正确的,但是如果你想使用 Ti钾Z,使用矩阵。然后您可以使用辅助文件来同步相关维度。
\documentclass{article}
\usepackage{geometry}
\usepackage{tikz}
\usetikzlibrary{matrix,calc,positioning}
\makeatletter
\newcommand{\WriteAux}[1]{%
\immediate\write\@mainaux{\xdef\string#1{#1}\relax}}
\makeatother
\pgfkeys{initialize dimension/.code={\unless\ifdefined#1
\def#1{0pt}
\fi}}
\begin{document}
\begin{table}
\centering
\begin{tikzpicture}[font=\sffamily,node distance=1ex]
\pgfkeys{initialize dimension/.list={\myheightA,\myheightB,\mywidth}}
\node[draw,text width=\mywidth,align=center,fill=gray](Study){Study 1};
\node[below=of Study,draw,text width=\mywidth,align=center](aim){Aim: Investigate the
performance\,/\,Investigate Investigate Investigate Investigate};
\node[below=of aim,matrix of nodes,nodes={text width=0.2\textwidth,align=left,
fill,text=white,minimum height=\myheightA,inner sep=2pt,anchor=north},
column sep=1ex,inner sep=0pt] (matA) {
{Primary Objectives} &
{Experimental design} &
{Fixed Section/Part} &
{Primary Objectives} \\
};
\node[below=of matA,matrix of nodes,nodes={text width=0.2\textwidth,align=left,
draw,minimum height=\myheightB,inner sep=2pt,anchor=north},
column sep=1ex,inner sep=0pt] (matB) {
{\vspace*{-\baselineskip}\begin{itemize}
\item bla
\item blub
\end{itemize}} &
{\vspace*{-\baselineskip}\begin{itemize}
\item bla
\item blub
\end{itemize}} &
{\vspace*{-\baselineskip}\begin{itemize}
\item bla
\item blub
\item pft
\end{itemize}} &
{\vspace*{-\baselineskip}\begin{itemize}
\item bla
\item blub
\end{itemize}} \\
};
\node[below=of matB,text width=\mywidth,fill,text=white,draw,align=center] (Hypo)
{Hypotheses};
\node[below=0pt of Hypo,text width=\mywidth,align=left,draw] (Pft)
{\vspace*{-\baselineskip}\begin{itemize}
\item bla
\item blub
\end{itemize}};
\node[below=1.5em of Pft,draw,text width=\mywidth,align=center,fill=gray](Study2){Study 2};
\node[below=of Study2,draw,text width=\mywidth,align=center](aim2){Aim: Investigate the
performance\,/\,Investigate Investigate Investigate Investigate};
% book keeping:
\path let \p1=($(matB-1-1.north)-(matB-1-1.south)$),
\p2=($(matB-1-2.north)-(matB-1-2.south)$),
\p3=($(matB-1-3.north)-(matB-1-3.south)$),
\p4=($(matB-1-4.north)-(matB-1-4.south)$),
\n1={max(\y1,\y2,\y3,\y4)},
\p5=($(matB.east)-(matB.west)$),
\p6=($(matA-1-1.north)-(matA-1-1.south)$),
\p7=($(matA-1-2.north)-(matA-1-2.south)$),
\p8=($(matA-1-3.north)-(matA-1-3.south)$),
\p9=($(matA-1-4.north)-(matA-1-4.south)$),
\n2={max(\y6,\y7,\y8,\y9)} in
\pgfextra{\pgfmathsetmacro{\mywidth}{\x5-8pt}\edef\mywidth{\mywidth pt}\edef\myheightA{\n2}\edef\myheightB{\n1}%
\WriteAux{\mywidth}\WriteAux{\myheightA}\WriteAux{\myheightB}};
\end{tikzpicture}
\caption{Some table.}
\end{table}
\end{document}
答案4
对于这种清晰的结构,我认为使用 atcbraster
或tcbitemize
from更容易tcolorbox
。这里有一个起点示例:
\documentclass[a4paper]{article}
\usepackage[most]{tcolorbox}
\tcbset{
sharp corners,
fontupper=\sffamily,
halign=center,
study/.style={colback=black!30},
aim/.style={colback=white},
text/.style={colback=white, halign=left},
name/.style={colback=black, colupper=white}
}
\begin{document}
\begin{tcbitemize}[raster columns=4]
\tcbitem[study, raster multicolumn=4] Study 1
\tcbitem[aim, raster multicolumn=4] Aim: Investigate the performance/Investigate Investigate
\tcbitem[name] Primary Objectyives
\tcbitem[name] Experimental Design
\tcbitem[name] Fixed Section/Part
\tcbitem[name] Testing Variables
\tcbitem[text, halign=left] - Investigate\\ - System Investigate\\ - Investigate
\tcbitem[text] - Investigate\\ - System Investigate\\ - Investigate
\tcbitem[text] - Investigate\\ - System Investigate\\ - Investigate
\tcbitem[text] - Investigate\\ - System Investigate\\ - Investigate
\tcbitem[name, raster multicolumn=4] Hypotheses
\tcbitem[text, raster multicolumn=4] \begin{itemize}
\item H1: Investigate the performance/Investigate
\item H2: Investigate the performance/Investigate
\end{itemize}
\tcbitem[study, raster multicolumn=4] Study 2
\tcbitem[aim, raster multicolumn=4] Aim: Investigate the performance/Investigate Investigate
\end{tcbitemize}
\end{document}