TransWikia.com

Align framed environment boxes accurately

TeX - LaTeX Asked by Xandros on September 3, 2021

I’m trying to draw a figure consisting of two boxes, using the framed environment, aligned side by side, each containing a small header and an align* environment. I’d like some symmetry. I.E. that the top and bottom lines of the boxes line up and the boxes are of equal width and symmetrical about the center of the page.

This is what I’ve got so far (Making use of some shorthands in the align environments, but I’d like a solution that does not depend on the contents of the aligns):

begin{figure}
centering
begin{minipage}{0.45textwidth}
    begin{framed}
    centering
    textbf{Unit}

    scalebox{.9}{parbox{linewidth}{%
    begin{align*}
        unit{A}:&quad A rightarrow allEnpstar A
        unit{A}(env)=&quadfinpr{Id{A(env,e)}}{ein E}
    end{align*}
    }}
end{framed}
end{minipage}
quad
begin{minipage}{0.45textwidth}
begin{framed}
    centering
    textbf{Co-Unit}

    scalebox{.9}{parbox{linewidth}{%
    begin{align*}
        counit{B} : &quad pstarallEn B rightarrow B
        counit{B}(env, e') =&quad pi_{e'} : Pi_{ein E}B(env, e)rightarrow B(env, e')
    end{align*}
    }}
end{framed}
end{minipage}

caption{The unit and co-unit of the adjunction}
    label{UnitCoUnitDefinition}
end{figure}

Currently

If you look carefully, these boxes aren’t quite aligned vertically.

Unaligned

Is there a way to fix the size of the boxes to be equal regardless of the contents of the boxes?

One Answer

I use TikZ to handle this.

documentclass{article}
usepackage{tikz}
usepackage{amsmath}
tikzset{
    every node/.style={
        draw,text centered,
        text width=.45textwidth,
        minimum height=2.5cm,
        inner sep=0pt
    }
}
begin{document}
begin{figure}
    centering
    tikznode {%
    textbf{Unit}
    begin{align*}
        A&=B+C+D
        Btimes C&=1+4
    end{align*}};%
    quad%
    tikz node {%
    textbf{Co-unit}
    begin{align*}
        A&=B+C+D
        Btimes C&=1+4
    end{align*}};%
    caption{The unit and co-unit of the adjunction}
    label{UnitCoUnitDefinition}
end{figure}
end{document}

enter image description here

Answered by user156344 on September 3, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP