This is a follow-up of Is it possible to fill the second column with something automatically?
I would like to (automatically) reach the following result (fill in the second column with a grid):
\documentclass{book}
\usepackage{geometry}
\usepackage{multicol}
\usepackage[most]{tcolorbox}
\tcbuselibrary{breakable, xparse}
\newtcolorbox[auto counter]{mybox}[2][]{%
breakable,
frame hidden,
opacityback=0,
sharp corners,
before skip=10pt,
enhanced,
left=6pt,
right=0pt,
bottom=0pt,
boxsep=0pt,
rightrule=0pt,
pad at break*=0mm,
borderline west={1.5pt}{0pt}{red},
fonttitle=\bfseries,
coltitle=blue,
title={\thetcbcounter. #2}
}
\usepackage{mwe}
\begin{document}
Some text in one column \blindtext
\begin{multicols}{2}
\begin{mybox}{My title}
Some text in two columns \blindtext
\end{mybox}
\vfill\null
\columnbreak
\begin{mybox}{My second title}
\begin{tikzpicture}
\draw[green,thin, step=.5] (0,0) grid (7,7);
\end{tikzpicture}
\end{mybox}
\end{multicols}
\newpage
Some other text in one column
\begin{multicols}{2}
\begin{mybox}{My third title}
Some other text in two columns \blindtext[2]
\end{mybox}
\vfill\null
\columnbreak
\begin{mybox}{My fourth title}
\begin{tikzpicture}
\draw[green,thin, step=.5] (0,0) grid (7,15);
\end{tikzpicture}
\end{mybox}
\end{multicols}
\end{document}
I tried this dirty hack but, of course, it doesn't work:
\documentclass{book}
\usepackage{geometry}
\usepackage{multicol}
\usepackage[most]{tcolorbox}
\tcbuselibrary{breakable, xparse}
\newtcolorbox[auto counter]{mybox}[2][]{%
breakable,
frame hidden,
opacityback=0,
sharp corners,
before skip=10pt,
enhanced,
left=6pt,
right=0pt,
bottom=0pt,
boxsep=0pt,
rightrule=0pt,
pad at break*=0mm,
borderline west={1.5pt}{0pt}{red},
fonttitle=\bfseries,
coltitle=blue,
title={\thetcbcounter. #2}
}
\newcommand{\squarefill}[2][.5]{\null
\vskip-\baselineskip
\leaders
\hbox to \columnwidth{\hspace{7.5pt}\begin{tikzpicture}
\draw[red,line width=1.5pt, overlay](7.27pt,\pgflinewidth) -- (7.27pt,1); \draw[step=#1,green,thin] (.5,\pgflinewidth) grid (#2*#1,#1);
\end{tikzpicture}}
\vfill\vskip-\baselineskip
\null}
\usepackage{mwe}
\begin{document}
Some text in one column \blindtext
\begin{multicols}{2}
\begin{mybox}{My title}
Some text in two columns \blindtext
\end{mybox}
\vfill\null
\columnbreak
\begin{mybox}{My second title}
\end{mybox}
\squarefill{14}
\end{multicols}
\newpage
Some other text in one column
\begin{multicols}{2}
\begin{mybox}{My third title}
Some other text in two columns \blindtext[2]
\end{mybox}
\vfill\null
\columnbreak
\begin{mybox}{My fourth title}
\end{mybox}
\squarefill{14}
\end{multicols}
\end{document}
A solution without tcolorbox
or TikZ is also acceptable if it gives the desired result.
tcolorbox
following your scheme. But if you always want two columns with controlled height, i think it will be easier to use atcbraster
construction wich will avoid to specifyequal height group
tcbraster
could be the solution, I'll trytcbitemize
version, hope it helps