1

enter image description here

I need a tcbitemize-structure like this with a total height of 6cm.

How can I set, that the 1st row has a height of ca. 2cm only? (2nd row: "rest".)

\documentclass{article}
\usepackage[showframe=true]{geometry}

\usepackage[most]{tcolorbox}
\tcbset{
SymbolStyle/.style={boxrule=4pt,colframe=blue}, 
NoGaps/.style={boxsep=0pt, 
left=0pt, right=0pt, top=0pt, bottom=0pt,}, 
}

\begin{document}
\begin{tcolorbox}[
colframe=red,  boxrule=2pt, 
NoGaps, 
]
\begin{tcbitemize}[
% Problem here ======================
%row 1/.style={height=2cm,},  % no effect
raster height=6cm, % raster rows=2,
raster equal height=rows,
% ===============================
sharp corners, boxrule=1pt,
NoGaps, boxsep=3pt,
raster columns=100,
raster column skip=0pt,
raster row skip=0pt,
colback=white
]
\tcbitem[raster multicolumn=25, SymbolStyle, 
%height=4cm  % no effect
]  X
\tcbitem[raster multicolumn=15] Y
\tcbitem[raster multicolumn=60] Z
\tcbitem[raster multicolumn=60] a \\ 1 \\ 2\\ 3 \\ 4\\ 5 \\ 6 \\ 7 \\8
\tcbitem[raster multicolumn=40] b
\end{tcbitemize}
\end{tcolorbox}
\end{document}

2 Answers 2

3

The option specifying height of first row is named raster row 1, not row 1. Option tcb/raster row m is documented in documentation of tcolorbox, section 15.4.

\documentclass{article}
\usepackage[showframe=true]{geometry}

\usepackage[most]{tcolorbox}
\tcbset{
  SymbolStyle/.style={boxrule=4pt, colframe=blue}, 
  NoGaps/.style={boxsep=0pt, left=0pt, right=0pt, top=0pt, bottom=0pt},
  draw height/.style={
    enhanced,
    finish={
      \draw[blue,very thick,<->] 
        (frame.south) -- node[right,pos=.75] {#1} +(0,#1); 
    }
  }
}

\begin{document}
\begin{tcolorbox}[
  colframe=red, boxrule=2pt,
  NoGaps, 
  height=6cm,
  draw height=6cm
]
  \begin{tcbitemize}[
    enhanced,
    raster row 1/.style={height=2cm},
    % 4pt = doubled the width of outer boxrule
    raster row 2/.style={height=4cm-4pt},
    raster equal height=rows,
    sharp corners, boxrule=1pt,
    NoGaps, boxsep=3pt,
    raster columns=100,
    raster column skip=0pt,
    raster row skip=0pt,
    raster before skip=0pt,
    raster after skip=0pt,
    colback=white,
  ]
    \tcbitem[raster multicolumn=25, SymbolStyle]  X
    \tcbitem[raster multicolumn=15] Y
    \tcbitem[raster multicolumn=60, draw height=2cm] Z
    \tcbitem[raster multicolumn=60] a \\ 1 \\ 2\\ 3 \\ 4\\ 5 \\ 6 \\ 7 \\8
    \tcbitem[raster multicolumn=40] b
  \end{tcbitemize}
\end{tcolorbox}

\end{document}

enter image description here

The option draw height is just for drawing measurement arrows, and you can safely delete it in actual use.

5
  • Ah, thanks a lot. This helps me good!
    – cis
    Jul 13, 2020 at 19:27
  • It's strange: At your picture it looks all correct. But if I copy your code I get something wrong with the total height (6cm); see: i.stack.imgur.com/jvF1b.png
    – cis
    Jul 15, 2020 at 13:41
  • Yes, the entire box should only be 6cm high. However, as you already indicated, this should again be such an arithmetic task. Therefore: Is putting the tcbitemize environment in another tcolorbox the only way to create a frame around tcbitemize? Or is there a command (unknown to me)?
    – cis
    Jul 15, 2020 at 14:23
  • @cls Fixed with a manual height calculation raster row 2/.style={height=4cm-4pt}. Jul 15, 2020 at 15:30
  • Thx again. ....
    – cis
    Jul 15, 2020 at 16:29
1

Such irregular structure can be easily obtained with a tcbposter (also from tcolorbox package like tcbraster). Altough a poster is supposed to have a regular structure, it's possible to change height, width and placement for all boxes. It's even possible to define boxes which height is defined by the space between other boxes.

Following code shows how to obtain the desired structure with a tcbposter. In this case a poster with one column and two rows is used as main structure. span option can define each box width, while column=1, column*=1 and xshift are used to fix horizontal position of boxes. The firs row boxes are defined as below=top because this way their height is fixed by their contents or tcolorbox height option. Second row boxes are defined to be between = ... and bottom to fill all remaining vertical space.

\documentclass{article}

\usepackage{geometry}

\usepackage[most]{tcolorbox}
\tcbset{
    SymbolStyle/.style={boxrule=4pt,colframe=blue},
    NoGaps/.style={boxsep=0pt, left=0pt, right=0pt, top=0pt, bottom=0pt},
}

\begin{document}
\begin{tcbposter}[
    poster = {%showframe,
     columns=1, rows = 2, spacing=0pt, height=6cm},
    boxes = {sharp corners, colframe=red, boxrule=1pt, NoGaps, boxsep=3pt, colback=white, enhanced}
]
\posterbox[SymbolStyle, height=2cm]{name=X, column=1, below=top, span=.25}{X}
\posterbox[height=2cm]{name=Y, row=1, span=.15, xshift=.25\linewidth}{Y}
\posterbox[height=2cm]{name=Z, column*=1, span=.60, below=top}{Z}
\posterbox{name=a, between=X and bottom, span=.6, column=1}{a\\ 1\\ 2\\ 3\\ 4\\ 5\\ 6\\ 7\\ 8}
\posterbox{name=b, between=Z and bottom, span=.6, column*=1}{b}
\end{tcbposter}
\end{document}

enter image description here

1
  • Interesting. Since the vertical dimensions are important (e.g. first column in the first row: "25%") and with regard to the content X, Y, .... (here on behalf of entire texts), I think that it is not a bad idea to use tcbitemize, because there less needs to be set. But I keep the tcbposter implementation in mind.
    – cis
    Jul 14, 2020 at 14:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.