多列环境中的垂直间距与表格环境中的垂直间距

多列环境中的垂直间距与表格环境中的垂直间距

我想tabular在环境中并排创建三个表(使用环境)tcolorbox,每个表的起始和结束高度相同。奇怪的是,第三列总是比前两列(垂直对齐)稍微靠南一点。我尝试\raggedcolumns按照其他解决方案的建议添加到序言中,但仍然存在高度差异。我怀疑环境multicol正在努力解决我不知道的高度问题。下面是 MWE(可能比最小值稍微多一点)。

\documentclass[12pt]{article}
\usepackage{amsmath,amsthm,verbatim,amssymb,amsfonts,amscd, graphicx, multicol, xcolor}
\usepackage{fancyhdr,array,tcolorbox,hyperref,faktor}
\tcbuselibrary{breakable}

\newcolumntype{D}{>{\centering\arraybackslash}p{3em}}

\raggedcolumns

\begin{document}

\begin{tcolorbox}[breakable, colbacktitle=white!5!red, title=Motivating Exponential Equations, colback=red!10!white]

A budding alpaca farm in Canada splits its herd up into 3 groups on January $1^{\text{st}}$, 2008. After 3 years, they record the number of alpacas in each herd. Assume each herd grows exponentially.

\begin{multicols}{3}

\[
\begin{tabular}{|*{2}{D|}}
\hline
$t$ & $P_1$ \\
\hline
0 & 8 \\
\hline
1 & \\
\hline
2 & \\
\hline
3 & 64 \\
\hline
\end{tabular}
\]

\columnbreak

\[
\begin{tabular}{|*{2}{D|}}
\hline
$t$ & $P_2$ \\
\hline
0 & 8 \\
\hline
1 & \\
\hline
2 & \\
\hline
3 & 512 \\
\hline
\end{tabular}
\]

\columnbreak

\[
\begin{tabular}{|*{2}{D|}}
\hline
$t$ & $P_3$ \\
\hline
0 & 2 \\
\hline
1 & \\
\hline
2 & \\
\hline
3 & 128 \\
\hline
\end{tabular}
\]

\end{multicols}

Let $P_1 = f(t)$, $P_2 = g(t)$, and $P_3 = h(t)$. Note that $t$ is in years.

\begin{enumerate}

\item Determine function formulas that model $P_1$, $P_2$ and $P_3$.

\item Fill in each of the tables. Determine from the tables when each herd is the same size \textit{at the same time}.

\item Determine algebraically when each pair of herds is the same size.

\end{enumerate}

\end{tcolorbox}

\end{document}

我想避免大幅改变代码以保持一致性(因为这是一个更大项目的一部分),但我会很感激任何建议。

答案1

没有必要将表格环境放在\[和中\],因为它们不是显示的方程式。删除这些命令可使行为multicols符合您的要求:

\documentclass[12pt]{article}
\usepackage{amsmath,amsthm,verbatim,amssymb,amsfonts,amscd, graphicx, multicol, xcolor}
\usepackage{fancyhdr,array,tcolorbox,hyperref,faktor}
\tcbuselibrary{breakable}

\newcolumntype{D}{>{\centering\arraybackslash}p{3em}}

\raggedcolumns

\begin{document}

\begin{tcolorbox}[breakable, colbacktitle=white!5!red, title=Motivating Exponential Equations, colback=red!10!white]

A budding alpaca farm in Canada splits its herd up into 3 groups on January $1^{\text{st}}$, 2008. After 3 years, they record the number of alpacas in each herd. Assume each herd grows exponentially.

\begin{multicols}{3}

\begin{tabular}{|*{2}{D|}}
\hline
$t$ & $P_1$ \\
\hline
0 & 8 \\
\hline
1 & \\
\hline
2 & \\
\hline
3 & 64 \\
\hline
\end{tabular}

\columnbreak

\begin{tabular}{|*{2}{D|}}
\hline
$t$ & $P_2$ \\
\hline
0 & 8 \\
\hline
1 & \\
\hline
2 & \\
\hline
3 & 512 \\
\hline
\end{tabular}

\columnbreak

\begin{tabular}{|*{2}{D|}}
\hline
$t$ & $P_3$ \\
\hline
0 & 2 \\
\hline
1 & \\
\hline
2 & \\
\hline
3 & 128 \\
\hline
\end{tabular}
\end{multicols}

Let $P_1 = f(t)$, $P_2 = g(t)$, and $P_3 = h(t)$. Note that $t$ is in years.

\begin{enumerate}

\item Determine function formulas that model $P_1$, $P_2$ and $P_3$.

\item Fill in each of the tables. Determine from the tables when each herd is the same size \textit{at the same time}.

\item Determine algebraically when each pair of herds is the same size.

\end{enumerate}

\end{tcolorbox}

\end{document}

截屏

multicols但是,我发现为此使用环境很奇怪(multicols通常用于从一列流到下一列的多列文本;当您确切知道在哪里分列时,它并不是真正需要的)。我宁愿使用\begin{tabular*}{\linewidth}{...} ... \end{tabular*}包含三列的,每个内部表格一列,如下所示:

\bigskip
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}*{3}{c}@{}}
  \begin{tabular}{|*{2}{D|}}
    \hline
    $t$ & $P_1$ \\
    \hline
    0 & 8 \\
    \hline
    1 & \\
    \hline
    2 & \\
    \hline
    3 & 64 \\
    \hline
  \end{tabular} &

  \begin{tabular}{|*{2}{D|}}
    \hline
    $t$ & $P_2$ \\
    \hline
    0 & 8 \\
    \hline
    1 & \\
    \hline
    2 & \\
    \hline
    3 & 512 \\
    \hline
  \end{tabular} &

  \begin{tabular}{|*{2}{D|}}
    \hline
    $t$ & $P_3$ \\
    \hline
    0 & 2 \\
    \hline
    1 & \\
    \hline
    2 & \\
    \hline
    3 & 128 \\
    \hline
  \end{tabular}
\end{tabular*}
\bigskip

结果比 更好multicols,因为三个表格确实填满了整行(参见上一个屏幕截图中右侧的间距)。使用tabular*基于 的代码,您将获得:

更好的截图

相关内容