多个图形与栅格并排显示 tcoloborx

多个图形与栅格并排显示 tcoloborx

语境

基于这个答案,我可以将 2 个数字并排放置调整宽度,子图高度相同

在此处输入图片描述

相同的方法适用于多个图表,以获得类似

在此处输入图片描述

我创建了\newcommand 并排的 2、3、4 个图表。但是,使用按键自动完成此任务肯定能让我受益匪浅。

我的问题

我怎样才能调整\width每个raster(相同高度)以使它们能够和谐地适合\textwidth

我该如何使用tcolorbox raster这个任务?

在此处输入图片描述

到目前为止,我的立场如下

在此处输入图片描述

转向

在此处输入图片描述

平均能量损失

\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}

下一步

在以后的问题中,我会问如何输入带有标题的图形列表以避免硬编码。但一步一步来 :)

编辑1

使用raster equal height答案中描述的方法会导致

在此处输入图片描述

那是不是我想要达到的目标。

答案1

使用raster equal height我得到这个输出:

在此处输入图片描述

\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,
        raster equal height, % <-- HERE
    ]
        
\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}

相关内容