2

I construct a raster by tcbitemize enviroment in tcolorbox. I found that the option raster column 1/.style have a effect on nested tcbitemize as shown in the following example. You can see that the first column of the nested raster is colored with red which is not what I want. How to cancel this effect by lower layer on higher layer of tcolorbox raster?

\documentclass[12pt,a4paper]{article}
\usepackage{tcolorbox}
\tcbuselibrary{skins,breakable,raster}

    \begin{document}
    \begin{tcbitemize}[raster equal height=rows,raster columns=4,raster column 1/.style={colback=red}]
        \tcbitem 1\tcbitem 1\tcbitem 1\tcbitem 1
        \tcbitem 1
        \tcbitem \begin{tcbitemize}[raster columns=2]
                    \tcbitem 2\tcbitem 2
                \end{tcbitemize}
        \tcbitem 1\tcbitem 1    
    \end{tcbitemize}
    \end{document}

enter image description here

4
  • Do you want \begin{tcbitemize}[empty,raster columns=2]? This adds the empty skin.
    – Ross
    Sep 5, 2017 at 2:28
  • What do you want the nested environment to look like? Without the column 1 settings but with what?
    – Ross
    Sep 5, 2017 at 5:42
  • As you see, I just want the nested tcbitemize is not affected by its outer tcbitemize options. In my example, cells of the first column in the nested raster should not be colored with red.
    – lyl
    Sep 5, 2017 at 5:50
  • Using the breakable library in conjunction with nested boxes is rather useless.
    – user31729
    Sep 5, 2017 at 6:54

1 Answer 1

6

The raster columns 1 etc. styles are sticky and persist for the nested boxes as well unless explicitly defined again in a lower layer. Unfortunately neither the reset nor the raster reset option removes those styles.

\colorlet{standardbackground}{yellow}
\tcbset{layerone/.style={raster every box/.style={colback={standardbackground}},raster equal height=rows,raster columns=4,raster column 1/.style={colback=red}}}
\tcbset{layertwo/.style={raster columns=2,raster column 1/.style={colback=standardbackground}}}

define the standard background colour (yellow just for demonstration here) and clear all boxes to this background first, then set the specific settings for the first layer with and the first column to colback=red and redefine the settings for raster column 1 to switch back to the standard background colour.

\documentclass[12pt,a4paper]{article}
\usepackage[most]{tcolorbox}


\colorlet{standardbackground}{yellow}

\tcbset{layerone/.style={raster every box/.style={colback={standardbackground}},raster equal height=rows,raster columns=4,raster column 1/.style={colback=red}}}
\tcbset{layertwo/.style={raster columns=2,raster column 1/.style={colback=standardbackground}}}


\begin{document}
\begin{tcbitemize}[layerone]
  \tcbitem 1\tcbitem 1\tcbitem 1\tcbitem 1
  \tcbitem 1
  \tcbitem 
  \begin{tcbitemize}[layertwo]
    \tcbitem 2\tcbitem 2
  \end{tcbitemize}
  \tcbitem 1\tcbitem 1    
\end{tcbitemize}
\end{document}

enter image description here

4
  • Why must \makeatother be used?
    – lyl
    Sep 5, 2017 at 7:54
  • @lyl: The \makeatother command is a relic of a trial of solution -- I just forgot to remove it.
    – user31729
    Sep 5, 2017 at 9:41
  • @lyl: I have answered your question, please consider to accept the answer, also for answers to other questions from other users or me in order to appreciate the work done in order to help you
    – user31729
    Sep 8, 2017 at 19:03
  • I'm so sorry for delaying giving my response because I just have chance to review my question. Thank you so much for your help in which I get a lot.
    – lyl
    Sep 13, 2017 at 4:38

You must log in to answer this question.

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