tcolorbox: Como definir rasterboxes de tamanho mínimo em tcbitemize

tcolorbox: Como definir rasterboxes de tamanho mínimo em tcbitemize

insira a descrição da imagem aqui

Quero as caixas raster horizontalmente tão largas quanto o conteúdo (como na "seção 1"). O que eu tenho que fazer?

\documentclass{article}
\usepackage[most]{tcolorbox}
\tcbset{sharp corners, }

\begin{document}
\section{tight works here}
\tcbox[size=tight,on line]{\Huge B}

\section{tight works not horizontally here}
\begin{tcbitemize}[
raster equal height=rows,  % needed
raster equal skip=0pt, % needed
raster columns=2,
halign=center, valign=center, 
raster force size=false, 
size=tight, % no horizontally effect
]
\tcbitem A
\tcbitem[colframe=red] \Huge B
\end{tcbitemize}

\subsection{In the result it should look like} 
\tcbox[size=tight,on line]{A\vphantom{\Huge B}}\tcbox[size=tight,on line,colframe=red]{\Huge B}
\end{document}

Responder1

Até você explicar por que usar tcbitemizeaqui você tem uma solução com duas tcboxesque mantêm a mesma altura com equal height groupa opção.

\documentclass{article}
\usepackage[most]{tcolorbox}
\tcbset{sharp corners, }

\newtcbox{\mybox}[1][]{size=tight, on line, equal height group=mygroup, valign=bottom, #1}

\begin{document}
\section{tight works here}
\tcbox[size=tight, on line]{\Huge B}

\section{tight works not horizontally here}
\mybox{A}\mybox[colframe=red]{\Huge B}


\subsection{In the result it should look like} 
\tcbox[size=tight,on line]{A\vphantom{\Huge B}}\tcbox[size=tight,on line,colframe=red]{\Huge B}
\end{document}

insira a descrição da imagem aqui

Responder2

Eu resolvi isso com

\def\LeftContent{A}
\pgfmathsetlengthmacro\LeftWidth{width("\LeftContent")}

insira a descrição da imagem aqui

\documentclass{article}
\usepackage[most]{tcolorbox}
\tcbset{sharp corners, }

\begin{document}

\section{tight works here}
\tcbox[size=tight,on line]{\Huge B}

\section{tight works not horizontally here}
\def\LeftContent{\includegraphics[scale=0.1]{example-image.jpg}}%test
\def\LeftContent{A}
\pgfmathsetlengthmacro\LeftWidth{width("\LeftContent")}
\def\RightContent{\Huge B}
\pgfmathsetlengthmacro\RightWidth{width("\RightContent")}
LeftWidth =\LeftWidth, RightWidth =\RightWidth

\begin{tcbitemize}[%NoGaps,
raster equal height=rows,  % needed
raster equal skip=0pt, % needed
raster columns=2,
halign=center, valign=center, 
raster force size=false, % <---
size=tight, % no horizontally effect
]
\tcbitem[size=tight, width=\LeftWidth, valign=bottom] \LeftContent
\tcbitem[colframe=red, width=\RightWidth] \RightContent
\end{tcbitemize}

\subsection{In the result it should look like} 
\tcbox[size=tight,on line]{A\vphantom{\Huge B}}\tcbox[size=tight,on line,colframe=red]{\Huge B}
\end{document}

informação relacionada