1

I'm trying to meld tcolorbox with an array in order to nicely identify exercices, with corresponding grade and difficulty level. I cannot get rid of the right angles (see pic below). I'd like to have the box rule "above" the array, in order to mask the rectangular cell and their right angles.

Additionnally, if someone could give me any clue for the best way to vertically center the text with respect to its actual height (with no space reservation in case of some letters could extend below the base line)...

I'm using LuaLaTeX. Here is the code I wrote to get the result show in the pic.

\documentclass[12pt, english, french]{article}
\usepackage{babel}
\frenchsetup{og=«, fg=»}
\usepackage{fontspec}
\setmainfont{Erewhon}
\setsansfont[Scale=MatchLowercase]{Cabin}
\setmonofont[Scale=MatchLowercase,HyphenChar=None]{Inconsolatazi4}
\usepackage[most]{tcolorbox}
\usepackage{array, colortbl, fourier-otf, fontawesome, multicol, multirow, xcolor}

\begin{document}

\tcbox[left=0ex, right=0ex, top=0ex, bottom=0ex, boxsep=0pt, boxrule=2pt]
    {\begin{tabular}{p{3cm}m{1.5cm}}
        \multirow{2}{*}{Exercice 17}     & \cellcolor{cyan}\textcolor{white}{1\iere} \\
                                         & \cellcolor{black!50!white}\textcolor{white}{\scriptsize \faStar\faStar\faStarO}
     \end{tabular}}

\end{document}

Thanks & regards !

tcolorbox with rounded corners outside and rectangular array cells inside

2 Answers 2

1

This is not related with OP question but I've supposed that this tabular is going to be used to mark several exercises and it's possible to use some tcolorbox tools to reduce and simplify the typing.

If every box marks a different exercise, we can use auto counter in \newtcbox declaration to automatically compute the number after Exercice.

And being the box contents so regular, it's possible to include it with before upper and after upper options. This way a tcbox with two mandatory parameters and a third empty content can do the work.

\documentclass[12pt, english, french]{article}
\usepackage{babel}
\usepackage[most]{tcolorbox}
\usepackage{array}
\usepackage{colortbl}
\usepackage{multirow}
\usepackage{fontawesome}

\newtcbox[auto counter]{exercicebox}[2]{%
    enhanced, clip upper, boxrule=2pt, 
    left=0pt, top=0pt, bottom=0pt, right=0pt, boxsep=0pt, 
    before upper={\begin{tabular}{p{3cm}m{1.5cm}}\multirow{2}{*}{Exercice~\thetcbcounter}&
         \cellcolor{cyan}\textcolor{white}{#1}\\ & \cellcolor{black!50!white}\textcolor{white}{\scriptsize #2}},
    after upper={\end{tabular}},
}

\begin{document}

\exercicebox{1\iere}{\faStar\faStar\faStarO}{}

\exercicebox{2\ieme}{\faStar\faStar\faStar\faStarO}{}

\end{document}

enter image description here

0

Thanks to How to define an inner margin for a tcolorbox?, here is the solution to my main problem :

\documentclass[12pt, english, french]{article}
\usepackage{babel}
\frenchsetup{og=«, fg=»}
\usepackage{fontspec}
\setmainfont{Erewhon}
\setsansfont[Scale=MatchLowercase]{Cabin}
\setmonofont[Scale=MatchLowercase,HyphenChar=None]{Inconsolatazi4}
\usepackage[most]{tcolorbox}
\usepackage{array, colortbl, fourier-otf, fontawesome, multicol, multirow, xcolor}

\begin{document}

\tcbox[enhanced,clip upper, left=0ex, right=0ex, top=0ex, bottom=0ex, boxsep=0pt, boxrule=2pt]
{\begin{tabular}{p{3cm}m{1.5cm}}
        \multirow{2}{*}{Exercice 17}     & \cellcolor{cyan}\textcolor{white}{1\iere} \\
%        \cline{2-2}
        & \cellcolor{black!50!white}\textcolor{white}{\scriptsize \faStar\faStar\faStarO}
\end{tabular}}
    
\end{document}

And here is the result of the code above : enter image description here

For the positioning problem, playing with \raisebox should be sufficient, even if it's rather ugly.

You must log in to answer this question.

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