#StackBounty: #floats #tcolorbox #minipage tcolorbox/minipage: How to automatically set the image height to that of its parent's?

Bounty: 50

For the following, I need to

1- automatically set each image height to that of the parent minipage/tcolorbox instead of doing it manually by height=2cm

2- understand why example-image-a inside the minipage is going over the right margin

enter image description here

documentclass[12pt,a4paper]{article}
usepackage{graphicx}
usepackage[most]{tcolorbox}
usepackage[showframe]{geometry}

begin{document}

noindent
setlength{fboxsep}{0pt}%
fbox{%
    begin{minipage}[t][2cm][c]{dimexprtextwidth/3}
        First line\ Second Line
    end{minipage}}%
fbox{%
    begin{minipage}[t][2cm][c]{dimexprtextwidth/3}
        centering Centered Text
    end{minipage}}%
fbox{%
    begin{minipage}[t][2cm][c]{dimexprtextwidth/3}
        flushright includegraphics[height=2cm]{example-image-a}
    end{minipage}}%


vspace{2baselineskip}

begin{tcbraster}[
        raster columns=3, raster rows=1,
        raster height = 2cm, sharp corners,
        valign=center,
        raster column skip = 0mm,
        boxrule = 0.5pt, colback = white,
        boxsep=0mm, left=0pt, right=0pt
    ]
    begin{tcolorbox}[left=0pt,right=0pt]
        First line\ Second Line
    end{tcolorbox}
    begin{tcolorbox}[halign=center]
        Centered Text
    end{tcolorbox}
    begin{tcolorbox}[halign=right]
        includegraphics[height=2cm]{example-image-b}
    end{tcolorbox}
end{tcbraster}

end{document}


Get this bounty!!!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.