我想使用colorbox
和按照特定顺序放置一些表格minipage
。这是我使用的代码:
\fcolorbox{white}{blue!20}{
\begin{minipage}[t]{.45\textwidth}
\begin{tabular}{ll}
A & A \\
A & A\\
A & A\\
\end{tabular}
\end{minipage}
}
\begin{minipage}[t]{.45\textwidth}
\fcolorbox{white}{red!20}{
\begin{minipage}[t]{\textwidth}
\begin{tabular}{ll}
B & B \\
B & B\\
\end{tabular}
\end{minipage}} %\vfill
\fcolorbox{white}{green!20}{
\begin{minipage}[t]{\textwidth}
\begin{tabular}{ll}
C & C \\
C & C\\
\end{tabular}
\end{minipage}}\vfill
\end{minipage}
但如下图所示,我无法调整顶部的框(参见蓝色和红色框,它们应该是顶部调整的)。
如果您有任何关于如何顶部、水平调整箱子的想法,我们将不胜感激。
答案1
您可以定义不可见的\hrule
名称\hrulei
,并将其放到您想要垂直对齐的地方:
\def\hrulei{\hrule height0pt\relax}
\hbox{%
\fcolorbox{white}{blue!20}{%
\begin{minipage}[t]{.45\textwidth}
\hrulei
\begin{tabular}{ll}
A & A \\
A & A\\
A & A\\
\end{tabular}
\end{minipage}
}\kern2pt %<<< space between blue column and next column
\begin{minipage}[t]{.45\textwidth}
\fcolorbox{white}{red!20}{%
\begin{minipage}[t]{\textwidth}
\hrulei
\begin{tabular}{ll}
B & B \\
B & B\\
\end{tabular}
\end{minipage}} %\vfill
\fcolorbox{white}{green!20}{%
\begin{minipage}[t]{\textwidth}
\begin{tabular}{ll}
C & C \\
C & C\\
\end{tabular}
\end{minipage}}\vfill
\end{minipage}
}
答案2
我宁愿使用tabularx
表格,而不是小页面:
\documentclass{article}
\usepackage[table]{xcolor}
\usepackage{tabularx}
\begin{document}
\begin{table}[ht]
\setlength\arrayrulewidth{4pt}
\setlength\extrarowheight{2pt}
\arrayrulecolor{white}
\begin{tabularx}{0.9\linewidth}{X|X}
\cellcolor{blue!30}
\begin{tabular}{ll}
A & A \\
A & A\\
A & A\\
\end{tabular} & \cellcolor{red!30}
\begin{tabular}{ll}
B & B \\
B & B\\
\end{tabular} \\
\hline
& \cellcolor{green!20}
\begin{tabular}{ll}
C & C \\
C & C\\
\end{tabular}
\end{tabularx}
\end{table}
\end{document}