此 LaTeX 代码:
\documentclass{article}
\usepackage{tikz-cd}
\usepackage{amsmath}
\begin{document}
\begin{figure}[ht]
\begin{tikzcd}[row sep=3cm, column sep=0.9cm]
& \text{binary relations}
\arrow[rd, shift left]
\arrow[ld, shift left] \\
\text{pointfree funcoids between powersets}
\arrow[ru, shift left]
\arrow[rr, shift left]
& & \text{antitone Galois connections between powersets}
\arrow[lu, shift left]
\arrow[ll, shift left]
\end{tikzcd}
\end{figure}
\end{document}
生成太宽的图表:
我想将节点中的文本拆分为多行,例如:
幂集之间的反音伽罗瓦联络
请解释一下如何操作。
答案1
例如,您可以使用\parbox
或tabular
作为长标签:
\documentclass{article}
\usepackage{tikz-cd}
\usepackage{amsmath}
\begin{document}
\begin{tikzcd}[row sep=3cm, column sep=0.9cm]
& \parbox{2cm}{\centering binary relations}
\arrow[rd, shift left]
\arrow[ld, shift left] \\
\parbox{3cm}{\centering pointfree funcoids between powersets}
\arrow[ru, shift left]
\arrow[rr, shift left]
& & \parbox{3cm}{\centering antitone Galois connections between powersets}
\arrow[lu, shift left]
\arrow[ll, shift left]
\end{tikzcd}
\begin{tikzcd}[row sep=3cm, column sep=0.9cm,every cell/.append style={align=center}]
& \text{binary relations}
\arrow[rd, shift left]
\arrow[ld, shift left] \\
\begin{tabular}{c}
pointfree funcoids \\
between powersets
\end{tabular}
\arrow[ru, shift left]
\arrow[rr, shift left]
& & \begin{tabular}{c}
antitone Galois connections \\
between powersets
\end{tabular}
\arrow[lu, shift left]
\arrow[ll, shift left]
\end{tikzcd}
\end{document}
答案2
这是一个解决方案:
\documentclass{article}
\usepackage{tikz-cd}
\usepackage{amsmath}
\newcommand\mlnode[1]{\fbox{\begin{tabular}{@{}c@{}}#1\end{tabular}}}
\begin{document}
\begin{figure}[ht]
\begin{tikzcd}[row sep=3cm, column sep=0.9cm]
& \fbox{binary relations}
\arrow[rd, shift left]
\arrow[ld, shift left] \\
\mlnode{pointfree funcoids\\ between powersets}
\arrow[ru, shift left]
\arrow[rr, shift left]
& & \mlnode{antitone Galois\\ connections\\ between powersets}
\arrow[lu, shift left]
\arrow[ll, shift left]
\end{tikzcd}
\end{figure}
\end{document}
答案3
该tikz-cd
包matrix of math nodes
默认使用不允许直接换行的 。但您不想在这里使用数学,因此您可以通过设置math mode=false
(tikz-cd
将使用matrix of nodes
然后)禁用数学模式,然后将文本放入节点而不使用\text{}
。
完成此操作后,您可以指定text width
并设置align=center
为自动换行和居中对齐。您也可以手动添加换行符\\
,但需要用括号括住相关节点文本。
\documentclass{article}
\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}[
row sep=3cm, column sep=0.9cm, math mode=false,
cells={text width=13em, align=center}
]
& binary relations
\arrow[rd, shift left]
\arrow[ld, shift left] \\
pointfree funcoids between powersets
\arrow[ru, shift left]
\arrow[rr, shift left]
& & {antitone Galois connections \\ between powersets}
\arrow[lu, shift left]
\arrow[ll, shift left]
\end{tikzcd}
\end{document}