0

I'd like to use a foreach loop inside the tcbitemize environment.

MWE:

\documentclass[11pt]{article}
\usepackage[utf8]{inputenc} 
\usepackage[many]{tcolorbox}


\begin{document}


\begin{tcbitemize}[blanker, raster columns=4, raster equal height=rows]
\foreach \x in {1,...,4}{
\tcbitem {abcd}
}
\end{tcbitemize}

\end{document}

I get the error "Missing number treated as zero"

Can anyone help please?

Thx

1

2 Answers 2

2

Does this satisfy -- from page 312 of the tcolorbox manual

https://mirror.niser.ac.in/ctan/macros/latex/contrib/tcolorbox/tcolorbox.pdf

You can see the difference by using option blankest

The colors

   raster every box/.style= {size=small,
                             colframe=red!50!black,
                             colback=red!10!white,
                             valign=center,
                             halign=center}

have been added only for emphasis and can be removed/ edited

MWE without option blankest

\documentclass[11pt]{article}

\usepackage[most]{tcolorbox}


\begin{document}
     \begin{tcbraster}[raster columns=4, raster equal height,
        raster every box/.style={size=small,colframe=red!50!black,colback=red!10!white,
            valign=center,halign=center}]
        
        \foreach \x in {1,...,4}{%
            \begin{tcolorbox}
                \x 
        \end{tcolorbox}}
    
    \end{tcbraster}
    
\end{document}

enter image description here

MWE with option blankest

\documentclass[11pt]{article}

\usepackage[most]{tcolorbox}


\begin{document}
     \begin{tcbraster}[blankest, raster columns=4, raster equal height,
        raster every box/.style={size=small,colframe=red!50!black,colback=red!10!white,
            valign=center,halign=center}]
        
        \foreach \x in {1,...,4}{%
            \begin{tcolorbox}
                \x 
        \end{tcolorbox}}
    
    \end{tcbraster}
    
\end{document}

enter image description here

0

Do you mean like that?

\documentclass[11pt]{article}

\usepackage[most]{tcolorbox}


\begin{document}
    
    \foreach \x in {1,...,4}{%
    \begin{tcbitemize}[blanker, raster columns=4, raster equal height=rows]
    
        \tcbitem \x 
        
    \end{tcbitemize}}
    
\end{document}

output

1
  • Actually not. If I could use the foreach inside the environment, the single tcbitems would be in 4 columns. Your code instead is generating 4 different tcbitemize environments below of each other.
    – user125198
    Commented Nov 24, 2022 at 12:53

You must log in to answer this question.

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