minipage tcolorbox 的垂直对齐

minipage tcolorbox 的垂直对齐

我试图将两个实例tcolorbox并排放置并垂直对齐到顶部。在其他帖子中,我尝试使用此代码的minipage选项[t]

\begin{document}
\begin{minipage}[t]{0.5\textwidth}
\begin{tcolorbox}[colback=isabelline,colframe=antiquewhite!20!black,title=Boundary layer]
\footnotesize{0, no boundary-layer\\
1, YSU scheme\\
2, Mellor-Yamada-Janjic TKE\\
3, NCEP Global Forecast System}
\end{tcolorbox}
\end{minipage}
\begin{minipage}[t]{0.5\textwidth}
\begin{tcolorbox}[colback=isabelline,colframe=antiquewhite!20!black,title=Surface physics]
\footnotesize{0, no surface temp prediction\\
1, thermal diffusion scheme\\
2, Unified Noah land-surface model\\
1, thermal diffusion scheme\\
2, Unified Noah land-surface model\\
1, thermal diffusion scheme\\
2, Unified Noah land-surface model\\
3, RUC land-surface model}
\end{tcolorbox}

\end{minipage}
\end{document}

但结果是它们底部对齐。我遗漏了什么? 在此处输入图片描述

谢谢

答案1

tcolorbox请参阅答案末尾针对此类环境的特殊更新。

用于tcbraster对齐框 - 这为许多设置提供了更清晰的界面tcolorbox

比如说\begin{tcbraster}[raster columns=2,box valign=top]...\end{tcbraster}

请注意,只有tcolorbox环境可能出现在栅格中。

\documentclass{article}

\usepackage[x11names,svgnames,dvipsnames]{xcolor}
\usepackage[most]{tcolorbox}

\begin{document}

\begin{tcbraster}[raster columns=2, raster valign=top]
\begin{tcolorbox}[colback=white!70!yellow,colframe=white!20!black,title=Boundary layer]
\footnotesize 0, no boundary-layer

1, YSU scheme

2, Mellor-Yamada-Janjic TKE

3, NCEP Global Forecast System
\end{tcolorbox}
\begin{tcolorbox}[colback=white!70!yellow,colframe=white!20!black,title=Surface physics]
\footnotesize 0, no surface temp prediction 

1, thermal diffusion scheme

2, Unified Noah land-surface model

1, thermal diffusion scheme

2, Unified Noah land-surface model

1, thermal diffusion scheme

2, Unified Noah land-surface model

3, RUC land-surface model
\end{tcolorbox}
\end{tcbraster}
\end{document}

在此处输入图片描述

更新tcolorbox对此有特别的。

\documentclass{article}

\usepackage[x11names,svgnames,dvipsnames]{xcolor}
\usepackage[most]{tcolorbox}

\newtcolorbox{somebox}[1][]{%
  colback=white!70!yellow,
  colframe=white!20!black,
  #1%
}


\begin{document}
\begin{tcbraster}[raster columns=2, raster valign=top,fontupper=\footnotesize]
\begin{somebox}[title=Boundary layer]
0, no boundary-layer

1, YSU scheme

2, Mellor-Yamada-Janjic TKE

3, NCEP Global Forecast System
\end{somebox}
\begin{somebox}[title=Surface physics]
0, no surface temp prediction 

1, thermal diffusion scheme

2, Unified Noah land-surface model

1, thermal diffusion scheme

2, Unified Noah land-surface model

1, thermal diffusion scheme

2, Unified Noah land-surface model

3, RUC land-surface model
\end{somebox}
\end{tcbraster}
\end{document}

答案2

这里,我使用了\belowbaseline的功能,将每个的值stackengine放置在基线下方,这样它就像一个对齐的框。作为测试,我在第一个框前添加了“查看基线”文本,以便辨别渲染的对齐方式。minipage-\ht\strutbox[t]

\documentclass{article}
\usepackage{tcolorbox,xcolor,stackengine}
\begin{document}
See baseline\belowbaseline[-\ht\strutbox]{\begin{minipage}{0.5\textwidth}
\begin{tcolorbox}[colback=red!3,colframe=yellow!20!black,title=Boundary layer]
\footnotesize{0, no boundary-layer\\
1, YSU scheme\\
2, Mellor-Yamada-Janjic TKE\\
3, NCEP Global Forecast System}
\end{tcolorbox}
\end{minipage}}
\belowbaseline[-\ht\strutbox]{\begin{minipage}{0.5\textwidth}
\begin{tcolorbox}[colback=red!3,colframe=yellow!20!black,title=Surface physics]
\footnotesize{0, no surface temp prediction\\
1, thermal diffusion scheme\\
2, Unified Noah land-surface model\\
1, thermal diffusion scheme\\
2, Unified Noah land-surface model\\
1, thermal diffusion scheme\\
2, Unified Noah land-surface model\\
3, RUC land-surface model}
\end{tcolorbox}
\end{minipage}}
\end{document}

在此处输入图片描述

相关内容