Context
Based on this answer, I can have 2 figures side by side with adjusted width, same height for sub-figures.
The same approach works for multiple graphs to get something like
I created \newcommand to include 2, 3, 4 graphs side by side. However, I could certainly benefit from automation of this task with keys.
My question
How can I adjust the \width of each raster (same height) so they can fit harmoniously on the \textwidth ?
How can I use tcolorbox raster for this task ?
So far, here is where I stand
turning to
MWE
\documentclass[twoside,a4paper]{book}
\usepackage{caption}
\usepackage[
showframe,
top = 1.8cm,
bottom = 2cm,
outer = 7cm,
inner = 2cm,
heightrounded,
marginparwidth = 5.0cm,
marginparsep = 0.5cm
]{geometry}
\usepackage[most]{tcolorbox}
\usetikzlibrary{shadows,patterns} % preamble
\tcbuselibrary{raster}
\usepackage{lipsum}
\usepackage{tabularray}
\def\fullPage{\dimexpr \marginparwidth+\marginparsep+\textwidth\relax}
\newcommand{\myGraphiX}[2][2]{
\begin{tcbraster}[
% raster width = \fullPage,
% raster width = \textwidth,
raster columns = #1,
% raster force size = false,
% raster equal height=rows,
size = fbox,
colframe = blue!50,
colback = white,
fonttitle = \bfseries,
center title,
drop fuzzy shadow,
]
\captionsetup{labelfont = {color = blue,bf,sf}}
\tcbincludegraphics[title = 1st image]{example-image-golden}
\tcbincludegraphics[title = 2nd image]{example-grid-100x100pt}
\tcbincludegraphics[title = 3rd prime]{example-grid-100x100pt}
\tcbincludegraphics[title = 4th matu]{example-image-duck}
\tcbincludegraphics[title = 5th matu]{example-image-a}
\tcbincludegraphics[title = 6th matu]{example-image-b}
\tcbincludegraphics[title = 7th matu]{example-grid-100x100pt}
\tcbincludegraphics[title = 8th matu]{example-image-c}
\begin{tcbitemize}[
raster multicolumn = #1, %Does not seem to work
halign = left,
colframe = white,
colback = white,
]
\tcbitem \captionof{table}{#2}
\end{tcbitemize}
\end{tcbraster}
}
\begin{document}
\chapter{Auto adjustment to figure height}
\myGraphiX[4]{\lipsum[1][1]}
\myGraphiX[8]{\lipsum[1][2]}
\myGraphiX[2]{\lipsum[1][3]}
\end{document}
Next steps
In a future question, I'll ask how to enter a list of figures with their captions to avoid hardcoding. But one step at a time :)
Edit 1
Using raster equal height as described in the anwer leads to
that is not what I am trying to reach.







raster equal height– DG' Mar 01 '22 at 09:20tcbrasterdivideslinewidthin several equal width columns. If you want/need different width columns, you have to adjust them by hand. – Ignasi Mar 01 '22 at 19:40