# Aligning object in a commutative diagram

MWE:

\documentclass[a4paper]{article}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tikz-cd}
\usepackage{faktor}
\begin{document}
I'd like the first line of the following diagram to be aligned like the first line of the second diagram, with the parentheses centered:
$\begin{tikzcd}[row sep={0cm}, column sep={2cm}] \faktor{\begin{Bmatrix} \text{Rivestimenti connessi} \\ \text{per archi di (X,x_0)} \end{Bmatrix}}{\cong_b} \arrow[r, "\phi", leftrightarrow] & \begin{Bmatrix} \text{Sottogruppi di} \\ \text{\pi_1(X,x_0)} \end{Bmatrix} \\ \Bigl(p \colon (\tilde{X},\tilde{x}_0) \to (X,x_0)\Bigr) \arrow[r, mapsto] & p_*\bigl(\pi_1(\tilde{X},\tilde{x}_0)\bigr) \end{tikzcd}$
Second diagram:
$\begin{tikzcd}[row sep={0cm}, column sep={2cm}] \begin{Bmatrix} \text{Rivestimenti connessi} \\ \text{per archi di (X,x_0)} \end{Bmatrix} \arrow[r, "\phi", leftrightarrow] & \begin{Bmatrix} \text{Sottogruppi di} \\ \text{\pi_1(X,x_0)} \end{Bmatrix} \\ \Bigl(p \colon (\tilde{X},\tilde{x}_0) \to (X,x_0)\Bigr) \arrow[r, mapsto] & p_*\bigl(\pi_1(\tilde{X},\tilde{x}_0)\bigr) \end{tikzcd}$
\end{document}

• Do you mean you want the top-left entry vertically centred to match the top-right entry, or horizontally centred to match the bottom-left entry, or both? Jun 1, 2019 at 18:49
• If you mean the vertical placement of the top left object, then the problem is obviously the usage of the faktor package. Jun 1, 2019 at 20:14

Quick and dirty.

\documentclass[a4paper]{article}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tikz-cd}
\usepackage{faktor}
\begin{document}
I'd like the first line of the following diagram to be aligned like the first line of the second diagram, with the parentheses centered:
$\begin{tikzcd}[row sep={0cm}, column sep={2cm}] \raisebox{-0.8em}{\faktor{\begin{Bmatrix} \text{Rivestimenti connessi} \\ \text{per archi di (X,x_0)} \end{Bmatrix}}{\cong_b}} \arrow[r, "\phi", leftrightarrow] & \begin{Bmatrix} \text{Sottogruppi di} \\ \text{\pi_1(X,x_0)} \end{Bmatrix} \\ \Bigl(p \colon (\tilde{X},\tilde{x}_0) \to (X,x_0)\Bigr) \arrow[r, mapsto] & p_*\bigl(\pi_1(\tilde{X},\tilde{x}_0)\bigr) \end{tikzcd}$
Second diagram:
$\begin{tikzcd}[row sep={0cm}, column sep={2cm}] \begin{Bmatrix} \text{Rivestimenti connessi} \\ \text{per archi di (X,x_0)} \end{Bmatrix} \arrow[r, "\phi", leftrightarrow] & \begin{Bmatrix} \text{Sottogruppi di} \\ \text{\pi_1(X,x_0)} \end{Bmatrix} \\ \Bigl(p \colon (\tilde{X},\tilde{x}_0) \to (X,x_0)\Bigr) \arrow[r, mapsto] & p_*\bigl(\pi_1(\tilde{X},\tilde{x}_0)\bigr) \end{tikzcd}$
\end{document}


If you do not want to guess this value but compute it, you can do so as follows (with some tricks from this answer):

\documentclass[a4paper]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tikz-cd}
\usetikzlibrary{calc}
\usepackage{faktor}
\begin{document}
I'd like the first line of the following diagram to be aligned like the first line of the second diagram, with the parentheses centered:
$\begin{tikzcd}[row sep={0cm}, column sep={2cm},execute at end picture={% \path let \p1=((\tikzcdmatrixname-1-2.north)-(\tikzcdmatrixname-1-1.north)) in \pgfextra{\typeout{required\space raise=\y1}};}] \raisebox{-7.25006pt}{\faktor{\begin{Bmatrix} \text{Rivestimenti connessi} \\ \text{per archi di (X,x_0)} \end{Bmatrix}}{\cong_b}} \arrow[r, "\phi", leftrightarrow] & \begin{Bmatrix} \text{Sottogruppi di} \\ \text{\pi_1(X,x_0)} \end{Bmatrix} \\ \Bigl(p \colon (\tilde{X},\tilde{x}_0) \to (X,x_0)\Bigr) \arrow[r, mapsto] & p_*\bigl(\pi_1(\tilde{X},\tilde{x}_0)\bigr) \end{tikzcd}$
Second diagram:
$\begin{tikzcd}[row sep={0cm}, column sep={2cm}] \begin{Bmatrix} \text{Rivestimenti connessi} \\ \text{per archi di (X,x_0)} \end{Bmatrix} \arrow[r, "\phi", leftrightarrow] & \begin{Bmatrix} \text{Sottogruppi di} \\ \text{\pi_1(X,x_0)} \end{Bmatrix} \\ \Bigl(p \colon (\tilde{X},\tilde{x}_0) \to (X,x_0)\Bigr) \arrow[r, mapsto] & p_*\bigl(\pi_1(\tilde{X},\tilde{x}_0)\bigr) \end{tikzcd}$
\end{document}


If you mean the vertical placement, then the culprit is \faktor.1

\documentclass[a4paper]{article}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tikz-cd}
\usepackage{faktor}

\begin{document}
I'd like the first line of the following diagram to be aligned like the first line of the second diagram, with the parentheses centered:
$\begin{tikzcd}[row sep={0cm}, column sep={2cm}] \begin{Bmatrix} \text{Rivestimenti connessi} \\ \text{per archi di (X,x_0)} \end{Bmatrix}_{\raisebox{\depth}[0pt][0pt]{\big/{\cong_b}}} \arrow[r, "\phi", leftrightarrow] & \begin{Bmatrix} \text{Sottogruppi di} \\ \text{\pi_1(X,x_0)} \end{Bmatrix} \\ \bigl(p \colon (\tilde{X},\tilde{x}_0) \to (X,x_0)\bigr) \arrow[r, mapsto] & p_*\bigl(\pi_1(\tilde{X},\tilde{x}_0)\bigr) \end{tikzcd}$
Alternative, more in line with conventional mathematical typesetting
$\begin{tikzcd}[row sep={0cm}, column sep={2cm}] \begin{Bmatrix} \text{Rivestimenti connessi} \\ \text{per archi di (X,x_0)} \end{Bmatrix}\Big/{\cong_b} \arrow[r, "\phi", leftrightarrow] & \begin{Bmatrix} \text{Sottogruppi di} \\ \text{\pi_1(X,x_0)} \end{Bmatrix} \\ \bigl(p \colon (\tilde{X},\tilde{x}_0) \to (X,x_0)\bigr) \arrow[r, mapsto] & p_*\bigl(\pi_1(\tilde{X},\tilde{x}_0)\bigr) \end{tikzcd}$
If you insist in using faktor
$\begin{tikzcd}[row sep={0cm}, column sep={2cm}] \begin{gathered}\faktor{\begin{Bmatrix} \text{Rivestimenti connessi} \\ \text{per archi di (X,x_0)} \end{Bmatrix}}{{\cong_b}}\end{gathered} \arrow[r, "\phi", leftrightarrow] & \begin{Bmatrix} \text{Sottogruppi di} \\ \text{\pi_1(X,x_0)} \end{Bmatrix} \\ \bigl(p \colon (\tilde{X},\tilde{x}_0) \to (X,x_0)\bigr) \arrow[r, mapsto] & p_*\bigl(\pi_1(\tilde{X},\tilde{x}_0)\bigr) \end{tikzcd}$
Second diagram:
$\begin{tikzcd}[row sep={0cm}, column sep={2cm}] \begin{Bmatrix} \text{Rivestimenti connessi} \\ \text{per archi di (X,x_0)} \end{Bmatrix} \arrow[r, "\phi", leftrightarrow] & \begin{Bmatrix} \text{Sottogruppi di} \\ \text{\pi_1(X,x_0)} \end{Bmatrix} \\ \bigl(p \colon (\tilde{X},\tilde{x}_0) \to (X,x_0)\bigr) \arrow[r, mapsto] & p_*\bigl(\pi_1(\tilde{X},\tilde{x}_0)\bigr) \end{tikzcd}$
\end{document}


### Footnote

1 I find the output of faktor ugly and unnecessary: I've rarely seen such constructions in mainstream mathematical publications.

• @marmot Uh! Thanks, forgot to copy the right code. Jun 1, 2019 at 21:24

Using only the mathmode:

\documentclass[a4paper]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\makeatletter
\def\mapstofill@{\arrowfill@{\mapstochar\relbar}\relbar\rightarrow}
\newcommand*\xmapsto[2][]{\ext@arrow 0000\mapstofill@{#1}{#2}}
\newcommand\xlongleftrightarrow[2][]{\ext@arrow 0055{\longleftrightarrowfill@}{#1}{#2}}
\def\longleftrightarrowfill@{\arrowfill@\leftarrow\relbar\rightarrow}
\makeatother
\newcommand\TAB[1]{\tabular{@{}l@{}}#1\endtabular}

\begin{document}
I'd like the first line of the following diagram to be aligned like the first line of the second diagram,
with the parentheses centered:
\begin{flalign*}
\left\{\TAB{Rivestimenti connessi\\per archi di $(X,x_0)$}\right\}_{\slash\cong_b}
\xlongleftrightarrow{\makebox[2cm]{$\phi$}}
\TAB{Sottogruppi di\\ $\pi_1(X,x_0)$}    \\
\Bigl(p \colon (\tilde{X},\tilde{x}_0) \to (X,x_0)\Bigr) \xmapsto{\makebox[3cm]{}}
p_*\bigl(\pi_1(\tilde{X},\tilde{x}_0)\bigr)
\end{flalign*}

\end{document}