# Curly braces in Hasse diagram

I need to create a Hasse diagram (i.e., lattice diagram) in LaTeX. Right now, I have the following code in tikz-cd.

\documentclass{standalone}

\usepackage{amsmath,tikz, tikz-cd}

\begin{document}
\begin{tikzpicture}[baseline= (a).base]
\node[scale=.85] (a) at (0,0){
\begin{tikzcd}[every arrow/.append style={dash}]
& & K_1
\arrow[ddll]
\arrow[d]\\
& & k_1
\arrow[ddll,sloped,pos=0.7,"\text{degree $p$}"]\\
K_0 \arrow[d,swap,"\text{degree 2} \, \,"] & & \\
k_0 & &
\end{tikzcd}
};
\end{tikzpicture}
\end{document}


I would like to add labeled vertical brackets to the diagram off to the side, preferably curly braces. For instance, I would like a vertical brace to the left of the diagram, labeled with 'H' and spanning from K_0 on the bottom to K_1 on the top. (Note: this is not the entire diagram -- the brace should extend down to K_0, not all the way down to k_0 at the bottom of the diagram.)

What is the simplest way to add these braces? Can I do it in tikz-cd? If not, what is the simplest alternative?

## 4 Answers

I don't know how to add a brace emcompassing only part of the height of the figure with tikz, but it's easy to obtain it with pstricks:

\documentclass[border=3mm]{standalone}

\usepackage{amsmath, pstricks-add}
\usepackage{auto-pst-pdf}

\begin{document}
\psset{linejoin=1}
\everypsbox{\footnotesize}
$\begin{psmatrix}[rowsep=1.3cm, colsep=2.5cm] \pnode[-4pt, 1.5ex]{K1}\phantom{K₁} & K₁ \\ & k₁ \\ \pnode[-4pt, -0.5ex]{K0}K₀ \\ k₀ \psset{nodesep=4pt, labelsep=2pt} \ncline{3,1}{1,2}\ncline{4,1}{2,2}\nbput[nrot=:U]{\text{degree$ p $}} \ncline{1,2}{2,2}\ncline{4,1}{3,1}\naput[nrot=:U]{\text{degree$ 2 $}} \psset{braceWidthInner=3pt,braceWidthOuter=3pt, braceWidth =0.8pt, nodesepB=-4pt, nodesepA=-1pt} \psbrace(K1)(K0){H} \end{psmatrix}$

\end{document}


• It doesn't look that easy, since I don't know pstricks! But I'll try to learn enough to figure out what you did. Thanks. – Barry Jun 19 '17 at 21:26
• It's much easier to learn than TikZ, because it uses a LaTeX syntax, and it's well documented (by modules, no more than 130 pages each time). – Bernard Jun 19 '17 at 21:30
• @Barry: If you want to understand what happens, take a look at the documentation of pst-node , and especially § 7, Mathematical diagrams and graphs, pp. 21–23. – Bernard Jun 19 '17 at 21:49

A simple cases environment will do:

\documentclass[border=3mm]{standalone}

\usepackage{amsmath, tikz, tikz-cd}

\begin{document}

$H \begin{cases} \begin{tikzpicture}[baseline= (a).base] \node[scale=.85] (a) at (0,0){ \begin{tikzcd}[every arrow/.append style={dash}] & & K_1 \arrow[ddll] \arrow[d]\\ & & k_1 \arrow[ddll,sloped,pos=0.7,"\text{degree$p$}"]\\ K_0 \arrow[d,swap,"\text{degree 2} \, \,"] & & \\ k_0 & & \end{tikzcd} }; \end{tikzpicture} \end{cases}$

\end{document}


• This extends all the way to the bottom of the diagram, which I don't want. Perhaps the capitalization in my OP made it unclear. I have updated the OP to make clear that the brace should extend only partway down. – Barry Jun 18 '17 at 18:37

With \left\lbrace and \right.

\documentclass[border=3mm]{standalone}

\usepackage{amsmath,tikz, tikz-cd}

\begin{document}
$H \left\lbrace \begin{tikzpicture}[baseline= (a).base] \node[scale=.85] (a) at (0,0){ \begin{tikzcd}[every arrow/.append style={dash}] & & K_1 \arrow[ddll] \arrow[d]\\ & & k_1 \arrow[ddll,sloped,pos=0.7,"\text{degree$p$}"]\\ K_0 \arrow[d,swap,"\text{degree 2} \, \,"] & & \\ k_0 & & \end{tikzcd} }; \end{tikzpicture} \right.$
\end{document}

• This extends all the way to the bottom of the diagram, which I don't want. Perhaps the capitalization in my OP made it unclear. I have updated the OP to make clear that the brace should extend only partway down. – Barry Jun 18 '17 at 18:37

A solution for tikz-cd using decorations.pathreplacing

\documentclass{standalone}

\usepackage{amsmath,tikz}
\usetikzlibrary{cd,decorations.pathreplacing}

\begin{document}
\begin{tikzcd}[every arrow/.append style={dash}]
\vphantom{K_1} \arrow[dd, start anchor=north, end anchor=south, no head, xshift=-1em, decorate, decoration={brace,mirror}, "H" left=3pt] & & K_1 \arrow[ddll] \arrow[d]\\
& & k_1 \arrow[ddll,sloped,pos=0.7,"\text{degree $p$}"]\\
K_0
\arrow[d,swap,"\text{degree 2} \, \,"] & & \\
k_0 & &
\end{tikzcd}
\end{document}


Note \vphantom{K_1} to ensure that the anchor north is at the correct place.

Following answers of other questions were helpful

and also following weblink