我正在尝试让它看起来更好:
即:用花括号括住所有内容,tikzcd 图表相对于其他两条线垂直居中。有什么建议吗?
\documentclass[letter, 11pt]{article}
\usepackage{multirow}
\usepackage{amsmath}
\usepackage{tikz-cd}
\tikzset{
commutative diagrams/.cd,
arrow style=tikz,
diagrams={>={Computer Modern Rightarrow[length=5pt,width=5pt]}},
}
\begin{document}
\begin{align*}
M :=
\left\{\begin{array}{c|c}
f:A \to B & \multirow{2}{*}{
\begin{tikzcd}[ampersand replacement=\&,column sep=1em]
X \times Y \ar[r, "m"] \ar[d, "r"']\& Z \times W \ar[r, "n"] \& V\\
X \times Y \ar[r, "m"] \& Z \times \ar[r, "n"]W \& V \ar[u, "h"']
\end{tikzcd}
} \\
g: A \times X \to Y & \\
\end{array}\right\}
\end{align*}
\end{document}
答案1
另一种简单的解决方案:
\documentclass[letter, 11pt]{article}
\usepackage{amsmath}
\usepackage{tikz-cd}
\tikzset{
commutative diagrams/.cd,
arrow style=tikz,
diagrams={>={Computer Modern Rightarrow[length=5pt,width=5pt]}},
}
\begin{document}
\[
M :=
\left\{\begin{array}{c|c}
\begin{gathered}
f:A \to B \\
g: A \times X \to Y
\end{gathered} & \begin{tikzcd}[ampersand replacement=\&]
X \times Y \ar[r, "m"] \ar[d, "r"']\& Z \times W \ar[r, "n"] \& V\\
X \times Y \ar[r, "m"] \& Z \times \ar[r, "n"]W \& V \ar[u, "h"']
\end{tikzcd}
\end{array}\right\}
\]
\end{document}
附录:一些题外话:
为了确定箭头样式,您可以
\tikzset
使用 (shorter)\tikzcdset
,例如:\tikzcdset{arrow style=tikz, diagrams={>=Straight Barb} % I liked such arrows :-) }
你的情况你不需要
ampersand replacement=\&
由于代码的一致性,箭头最好写在节点内容之后,即:改为
Z \times \ar[r, "n"]W
更好Z\times W \ar[r, "n"]
,不管生成的图表是否相同\documentclass[margin=3mm, varwidth]{standalone} \usepackage{amsmath} \usepackage{tikz-cd} \tikzcdset{arrow style=tikz, diagrams={>=Straight Barb} } \begin{document} \[ M := \left\{\begin{array}{c|c} \begin{gathered} f:A \to B \\ g: A \times X \to Y \end{gathered} & \begin{tikzcd}%[sep=large] % i like bigger diagram :-) X\times Y \ar[r, "m"] \ar[d, "r"'] & Z\times W \ar[r, "n"] & V\\ X\times Y \ar[r, "m"] & Z\times W \ar[r, "n"] & V \ar[u, "h"'] \end{tikzcd} \end{array}\right\} \] \end{document}
给出:
答案2
我认为您不应该使用\left
和\right
。
此外,letter
尚未定义。使用letterpaper
。
\documentclass[letterpaper,11pt]{article}
\usepackage{mathtools}
\usepackage{tikz-cd}
\tikzset{
commutative diagrams/.cd,
arrow style=tikz,
diagrams={>={Computer Modern Rightarrow[length=5pt,width=5pt]}},
}
\makeatletter
\newcommand{\vast}{\bBigg@{4}}
\makeatother
\begin{document}
\[
M\coloneqq\vast\{
\begin{array}{c}
f:A\to B\\
g:A\times X\to Y
\end{array}\vast|\begin{tikzcd}[ampersand replacement=\&,column sep=1em]
X \times Y \ar[r, "m"] \ar[d, "r"']\& Z \times W \ar[r, "n"] \& V\\
X \times Y \ar[r, "m"] \& Z \times \ar[r, "n"]W \& V \ar[u, "h"']
\end{tikzcd}
\vast\}
\]
\end{document}
箭头完全不一致...但是,因为这是你的意图,所以我保留它。
答案3
\documentclass[letter, 11pt]{article}
\usepackage{amsmath}
\usepackage{tikz-cd}
\tikzset{
commutative diagrams/.cd,
arrow style=tikz,
diagrams={>={Computer Modern Rightarrow[length=5pt,width=5pt]}},
}
\begin{document}
\begin{align*}
M := \left\{
\begin{array}{ll}
f: & A \to B \\
g: & A \times X \to Y \\
\end{array}
\middle|
\begin{tikzcd}[ampersand replacement=\&,column sep=1em]
X \times Y \ar[r, "m"] \ar[d, "r"']\& Z \times W \ar[r, "n"] \& V\\
X \times Y \ar[r, "m"] \& Z \times \ar[r, "n"]W \& V \ar[u, "h"']
\end{tikzcd}
\right\}
\end{align*}
\end{document}
答案4
mathtools
在这里我使用+包添加我的建议xy
。
\documentclass[12pt]{article}
\usepackage[all]{xy}
\usepackage{mathtools,amssymb}
\begin{document}
\[M\coloneqq \begin{Bmatrix}
\begin{matrix}
f:&A \rightarrow B \\
g:& A \times X \rightarrow Y
\end{matrix}\mathrel{\Bigg|}\vcenter{\xymatrix@R=.9pc{
X \times Y \ar[r]^{m} \ar[d]_r & Z \times W \ar[r]^(.6){n} & V \\
X \times Y \ar[r]^m & Z \times W \ar[r]^(.6){n} & V \ar[u]_h
}}\end{Bmatrix}
\]
\end{document}