Height of tcolorbox changed by g y p q
You need a \phantom
of the character that makes the difference. I've chosen to put the same phantom (a tall and a deep character) in each box:
\documentclass{article}
\usepackage{tcolorbox}
\usepackage{multicol}
\begin{document}
\begin{multicols}{2}
\begin{tcolorbox}
Hello\phantom{Hy}
\end{tcolorbox}
\columnbreak
\begin{tcolorbox}
Bye\phantom{Hy}
\end{tcolorbox}
\end{multicols}
\end{document}
Strictly speaking you can use \vphantom
for a vertical correction, and probably should in this case. Even better is \strut
, especially if you want to define your own new box:
\documentclass{article}
\usepackage{tcolorbox}
\newtcolorbox{oneliner}{fontupper=\strut}
\usepackage{multicol}
\begin{document}
\begin{multicols}{2}
\begin{oneliner}
Hello
\end{oneliner}
\columnbreak
\begin{oneliner}
Bye
\end{oneliner}
\end{multicols}
\end{document}
Pages 15 and 29 of the tcolorbox manual explain how to make your own box, and the meaning of the various options. \vphantom{y}
in place of \strut
in the new box definitions doesn't work -- the phantom is set on one line and the real text underneath.
Another alternative is equal height group
. All boxes from same group will have similar height (after two compilations), it doesn't matter if the are on same line or not.
\documentclass{article}
\usepackage{tcolorbox}
\usepackage{multicol}
\begin{document}
\begin{multicols}{2}
\begin{tcolorbox}[equal height group=A]
Hello
\end{tcolorbox}
\columnbreak
\begin{tcolorbox}[equal height group=A]
Bye
\end{tcolorbox}
\end{multicols}
\begin{multicols}{2}
\begin{tcolorbox}[equal height group=A]
aeo
\end{tcolorbox}
\columnbreak
\begin{tcolorbox}
aeo
\end{tcolorbox}
\end{multicols}
\end{document}
yet another workaround could be to use \strut
:
\documentclass{article}
\usepackage{tcolorbox}
\usepackage{multicol}
\begin{document}
\begin{multicols}{2}
\begin{tcolorbox}
\strut Hello
\end{tcolorbox}
\columnbreak
\begin{tcolorbox}
\strut Bye
\end{tcolorbox}
\end{multicols}
\end{document}