我试图将两个实例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}