如何使两个盒子具有相同的高度(打破后)......?

如何使两个盒子具有相同的高度(打破后)......?
\documentclass[10pt,a4paper]{book} %Compilation : xelatex 
    \usepackage[margin=10mm]{geometry} 
    \usepackage{amsmath, amsfonts, amssymb} 
    \usepackage{tcolorbox, paracol, blindtext} 
    
    \pagestyle{empty}

%=============================================================
%=============================================================

\tcbuselibrary{breakable, external, fitting,
    hooks, , magazine, most, poster, 
    raster, skins, theorems, vignette, 
    %xprase, documentation, 
    %listings, minted
}

\usetikzlibrary{decorations.pathmorphing, patterns}

%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

\newtcolorbox[]{boxe}[1][]{enhanced standard jigsaw, breakable,
    colback=white, colframe=red,
    equal height group=boxe
}


\begin{document}
    \begin{paracol}{2}
        \begin{boxe}
            \blindtext[5]
        \end{boxe}
        \switchcolumn
        \begin{boxe}
            \blindtext[6]
        \end{boxe}
    \end{paracol}   
\end{document}

在此处输入图片描述

答案1

最终,两个盒子之间的差异将相同。因此,您可以使用 saveboxes 测量高度和深度,并为较短的盒子添加支柱。棘手的部分是获取 tcolorbox 内列的宽度。

这实际上为两个框都添加了支柱,但其中一个框高为 0pt。

\documentclass[10pt,a4paper]{book} %Compilation : xelatex 
\usepackage[margin=10mm]{geometry} 
\usepackage{amsmath, amsfonts, amssymb} 
\usepackage{tcolorbox, paracol, blindtext}

\pagestyle{empty}

%=============================================================
%=============================================================

\tcbuselibrary{breakable, external, fitting,
    hooks, , magazine, most, poster, 
    raster, skins, theorems, vignette, 
    %xprase, documentation, 
    %listings, minted
}

\usetikzlibrary{decorations.pathmorphing, patterns}

%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

\newtcolorbox[]{boxe}[1][]{enhanced standard jigsaw, breakable,
    colback=white, colframe=red,
    equal height group=boxe% not needed
}
\newlength{\szero}
\newlength{\sone}

\begin{document}
\setbox0=\vbox{\hsize=234.00325pt % from \the\linewidth
  \blindtext[5]}
\setbox1=\vbox{\hsize=234.00325pt
  \blindtext[6]}
\setlength{\szero}{\dimexpr \ht1-\ht0+\dp1-\dp0}% strut height
\setlength{\sone}{-\szero}%
\ifdim\szero<0pt \szero=0pt
\else\sone=0pt
\fi

    \begin{paracol}{2}
        \begin{boxe}
            %\the\linewidth
            \unvbox0
            
            \rule{0pt}{\szero}
        \end{boxe}
        \switchcolumn
        \begin{boxe}
            \unvbox1
            
            \rule{0pt}{\sone}
        \end{boxe}
    \end{paracol}   
\end{document}

此版本有一个“可破坏支柱”。然而,两个箱子的尺寸并不完全相同。

\documentclass[10pt,a4paper]{book} %Compilation : xelatex 
\usepackage[margin=10mm]{geometry} 
\usepackage{amsmath, amsfonts, amssymb} 
\usepackage{tcolorbox, paracol, blindtext}

\pagestyle{empty}

%=============================================================
%=============================================================

\tcbuselibrary{breakable, external, fitting,
    hooks, , magazine, most, poster, 
    raster, skins, theorems, vignette, 
    %xprase, documentation, 
    %listings, minted
}

\usetikzlibrary{decorations.pathmorphing, patterns}

%+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

\newtcolorbox[]{boxe}[1][]{enhanced standard jigsaw, breakable,
    colback=white, colframe=red,
    equal height group=boxe% not needed
}
\newsavebox{\boxA}
\newsavebox{\boxB}
\newlength{\strutA}

\newcommand{\multistrut}[1]% #1 = length
{\bgroup
  \parskip=0pt
  \dimen0=#1\relax
  \loop\ifdim\dimen0>\baselineskip
    \par\strut
    \advance\dimen0 by -\baselineskip
  \repeat
  \hrule height\dimen0 width0pt
\egroup}

\newcommand{\equalize}[2]{%#1 = \boxA contents, #2 = \boxB contents
  \setbox\boxA=\vbox{\hsize=234.00325pt % from \the\linewidth
    #1}%
  \setbox\boxB=\vbox{\hsize=234.00325pt
    #2}%
  \setlength{\strutA}{\dimexpr \ht\boxB-\ht\boxA+\dp\boxB-\dp\boxA}% strut height
  \ifdim\strutA<0pt \setbox\boxB=\vbox{\hsize=234.00325pt
    \unvbox\boxB \multistrut{-\strutA}}%
  \else\setbox\boxA=\vbox{\hsize=234.00325pt
    \unvbox\boxA \multistrut{\strutA}}%
  \fi}

\begin{document}

    \equalize{\blindtext[2]}{\blindtext[6]}
    \begin{paracol}{2}
        \begin{boxe}
            %\the\linewidth
            \unvbox\boxA
        \end{boxe}
        \switchcolumn
        \begin{boxe}
            \unvbox\boxB
        \end{boxe}
    \end{paracol}   
\end{document}

相关内容