Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Box in commutative diagram

Tags:

latex

tikz

In the following commuting diagram, I would like to draw a box containing the bottom triangle defined by nodes D, E and F. Do you know how I could do that?

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd}

\begin{document}

\[
\begin{tikzcd}[row sep=2.5em]
& \text{A}  \\
\arrow[rightarrow]{d}{R_4}\text{B} \arrow[leftarrow]{ur}{R_1} 
\arrow[dashed,leftrightarrow]{rr}{R_3} && \text{C} \\
\arrow[leftrightarrow]{rd}{R_1}\text{D}\arrow[leftrightarrow]{rr}{R_3} & &  
\text{E} \arrow[leftrightarrow]{ld}{R_2}\\
& \text{F} &
\end{tikzcd}
\]

\end{document}

enter image description here

like image 987
Aleph Avatar asked Oct 26 '25 14:10

Aleph


1 Answers

Searching here and there, I put together the following:

\documentclass{article}
\usepackage{amsmath}
%\usepackage{tikz-cd}
\usepackage{tikz}
\usetikzlibrary{cd}
\usetikzlibrary{fit, patterns}

\begin{document}

\[
\tikz[%remember picture, 
overlay]{
    \filldraw[fill=yellow!50,draw=red!50!yellow] (-.5,-3.2) rectangle (3.8,-.4);
}
\begin{tikzcd}[row sep=2.5em]
& \text{A}  \\
\arrow[rightarrow]{d}{R_4}\text{B} \arrow[leftarrow]{ur}{R_1} 
\arrow[dashed,leftrightarrow]{rr}{R_3} && \text{C} \\[3em]
\arrow[leftrightarrow]{rd}{R_1}\text{D}\arrow[leftrightarrow]{rr}{R_3} & &  
\text{E} \arrow[leftrightarrow]{ld}{R_2}\\
& \text{F} &
\end{tikzcd}
\]

\end{document}

It outputs:

screenshot of output

I didn't edit any of your code within \[ and \], except for adding [3em] in line 18 for the sake of vertical spacing.

The style (colors, margins) may be changed up to your personal taste!

like image 95
MattAllegro Avatar answered Oct 29 '25 10:10

MattAllegro



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!