1

everyone! I'm new to tcolorbox and I want to achieve something that I didn't think would take so much time without any results. Usually, documentation and googling gets me there. But, for this one I had no luck and the tcolorbox documentation is just overwhelming. I present the code of my work up until now:

\begin{tcolorbox}[colback=blue!83,arc=0pt,outer arc=0pt]
    \begin{minipage}{.25\textwidth} 
        \bf \textcolor{white}{1}  \\  \textcolor{white}{2} \\ \textcolor{white}{3}
    \end{minipage}%
    \begin{minipage}{.75\textwidth} 
        \phantom{1} \\ \phantom{1} \\ \phantom{1} %used for painting
    \end{minipage}
\end{tcolorbox}

I used minipage to separate easier the box and also to try and paint the right minipage with a different color (gray) as I did not manage to do this via the colorbox options. What I did to achieve this was to put the minipage inside an fcolorbox. That didn't give me the desired result as all it painted was the three rows, leaving some space around the gray fcolorbox still painted blue. I also tried other things with similar results. I just want all the right minipage to be gray. Ideally, I want the whole tcolorbox to be something like a 3 by 2 table and also no frame. So the expected output is the following:

enter image description here

2
  • 2
    Is the image you have added your expected output?
    – Imran
    Dec 29, 2021 at 3:37
  • 1
    Yes, I edited my question. I hope it is now clear.
    – Laxuist
    Dec 29, 2021 at 9:41

2 Answers 2

5

Under the assumption that the image you included in your quesion is a sketch of the expected output, I wouldn't recommend tcolorbox to reproduce that. Instead a package dedicated to tables, such as tabularray or nicematrix should come in handy:

enter image description here

\documentclass{article}

\usepackage{xcolor}
\usepackage{tabularray}

\definecolor{myblue}{RGB}{46, 116, 181}
\definecolor{mygray}{RGB}{217, 217, 217}

\begin{document}
\noindent
\begin{tblr}{colspec={X[1]X[3]}, 
             hlines, vlines,
             column{1}={bg=myblue, fg=white, font=\bfseries}, 
             column{2}={bg=mygray}} 
        1 & \\
        2 & \\
        3 & \\
\end{tblr}
\end{document}

\documentclass{article}

\usepackage{xcolor}
\usepackage{nicematrix}

\definecolor{myblue}{RGB}{46, 116, 181}
\definecolor{mygray}{RGB}{217, 217, 217}

\begin{document}
\noindent
\begin{NiceTabularX}{\linewidth}{>{\bfseries\color{white}}X[1]X[3]}[hvlines]
\CodeBefore
\columncolor{myblue}{1}
\columncolor{mygray}{2}
\Body
        1 & \\
        2 & \\
        3 & \\
\end{NiceTabularX}
\end{document}
1
  • I'm sorry for the late response. I had the third dose of the covid19 vaccine which took its toll on me. I really laughed hard when I saw the image in your answer, since I couldn't believe my eyes. I could not imagine that one could get this exact same result. I picked tabularray package solution because I found it really easy to understand and modify the code to produce some other tables, without even reading the documentation. Thank you, once again leandriis!
    – Laxuist
    Jan 10, 2022 at 1:08
3

As leandriis commented, it's better to use a package for tabular or arrays to draw the desired scheme. But with tcolorbox you can also emulate tabulars. This is an example with a tcbitemize.

\documentclass{article}
\usepackage[most]{tcolorbox}
\begin{document}
\begin{tcbitemize}[raster columns=4, raster column skip=-0.5mm, raster row skip=-0.5mm,
raster equal height=rows, 
sharp corners, colback=blue, coltext=white, raster even number/.style={raster multicolumn=3, colback=gray}]
\tcbitem 1
\tcbitem
\tcbitem 2
\tcbitem
\tcbitem 3
\tcbitem
\end{tcbitemize}
\end{document}

enter image description here

1
  • I really appreciate this answer, but I picked leandriis's one for it is clear that tcolorbox is not the way to go here. Thank you, tcbitemize might come in handy some day and I'm not familiar with it.
    – Laxuist
    Jan 10, 2022 at 0:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .