2

I want to have an A4 size paper, split it to 8 equal parts and each part have features of tcolorbox package. Using the codes for the other question on TeX.SE, I have prepared this, but the height of the boxes are fixed to the height of the text not the size of the small parts.

It is important for me that the margins in all directions be equal and I do not want extra packages to be loaded.

%pdflatex

\documentclass[a4paper]{article}
\usepackage[margin=5mm,centering,landscape]{geometry}
\usepackage{tcolorbox}
\newcommand\Block[2]{%
\setlength\fboxsep{0pt}\setlength\fboxrule{0.1pt}% delete
\fbox{% delete
\begin{minipage}[c][\dimexpr.5\textheight\relax][c]{\dimexpr0.25\textwidth-3pt\relax}
\centering
\par \begin{tcolorbox}[colback=red!5!white,
colframe=red!75!black,
sharp corners=northwest ,title=#1]
#2
\end{tcolorbox}

\end{minipage}%
  }% delete
}

\begin{document}
\thispagestyle{empty}% optional: suppress page numbering

\noindent
\Block{text}{caption}\hfill%
\Block{text}{caption}\hfill%
\Block{text}{caption}\hfill%
\Block{text}{caption}%
\vfill
\noindent
\Block{text}{caption}\hfill%
\Block{text}{caption}\hfill%
\Block{text}{caption}\hfill%
\Block{text}{caption}
\end{document}

enter image description here

enthu
  • 3,795

1 Answers1

2

Two possible approaches. The first one uses minipages as teh original code did. In the second part, I have used tcbraster to help with the positioning.

enter image description here

\documentclass[a4paper]{article}
\usepackage[margin=5mm,centering,landscape]{geometry}
\usepackage[most]{tcolorbox}
\newcommand\Block[2]{
\begin{minipage}[c][\dimexpr.5\textheight\relax][c]{\dimexpr0.25\textwidth-3pt\relax}
\centering
\par \begin{tcolorbox}[colback=red!5!white,
                       colframe=red!75!black,
                       sharp corners=northwest,
                       title=#1, 
                       height=\dimexpr.5\textheight\relax]
#2
\end{tcolorbox}
\end{minipage}%
}


\newcommand\BlockAlt[2]{%
\begin{tcolorbox}[colback=red!5!white,
                  colframe=red!75!black,
                  sharp corners=northwest,
                  title=#1, 
                  height=\dimexpr.5\textheight-5pt\relax]
#2
\end{tcolorbox}
}

\begin{document}
\thispagestyle{empty}% optional: suppress page numbering

\noindent
\Block{text}{caption}\hfill%
\Block{text}{caption}\hfill%
\Block{text}{caption}\hfill%
\Block{text}{caption}%
\vfill
\noindent
\Block{text}{caption}\hfill%
\Block{text}{caption}\hfill%
\Block{text}{caption}\hfill%
\Block{text}{caption}

\newpage

\begin{tcbraster}[raster columns=4,raster equal height, raster column skip=5pt]
\BlockAlt{text}{caption}%
\BlockAlt{text}{caption}%
\BlockAlt{text}{caption}%
\BlockAlt{text}{caption}%
\BlockAlt{text}{caption}%
\BlockAlt{text}{caption}%
\BlockAlt{text}{caption}%
\BlockAlt{text}{caption}%
\end{tcbraster}
\end{document}

\documentclass[a4paper]{article}
\usepackage[margin=5mm,centering,landscape]{geometry}
\usepackage[most]{tcolorbox}

\newcommand\BlockAlt[2]{%
\begin{tcolorbox}[colback=red!5!white,
                  colframe=red!75!black,
                  sharp corners=northwest,
                  title=#1, 
                  height=3cm] %<---- changed to 3 cm
#2
\end{tcolorbox}
}

\begin{document}
\thispagestyle{empty}% optional: suppress page numbering

\begin{tcbraster}[raster columns=3, %<--- changed to 3, so only 3 boxes will be in one row
                  raster equal height, 
                  raster column skip=2cm, % <--- changed to 2 cm, will make boxes narrower
                  raster row skip=2cm] %<--- added and also set to 2cm for equal spacing around the boxes
\BlockAlt{text}{caption}%
\BlockAlt{text}{caption}%
\BlockAlt{text}{caption}%
\BlockAlt{text}{caption}%
\BlockAlt{text}{caption}%
\BlockAlt{text}{caption}%
\BlockAlt{text}{caption}%
\BlockAlt{text}{caption}%
\end{tcbraster}
\end{document}

enter image description here

leandriis
  • 62,593
  • thank you leandriis, I love the second approach. could you please give comments on the tcbraster and how I may give more precise dimensions to the size of the boxes? – enthu Jan 11 '20 at 06:21
  • I have added an annotated example with slightly different settings for the height of the boxes, and the distance between them. The width of the boxes is determined taking into account the number of boxes in a row and the horizontal distance between adjacent boxes. I hope this helps. – leandriis Jan 11 '20 at 09:50
  • No reason not to accept this perfect answer. :-) – enthu Jan 11 '20 at 12:56