我正在制作一个 DAG/图表,它最终应该看起来像两个正方形共用一个角。我在将代码推进到以“%”开头的最后两行时遇到了麻烦:
$\CD
(0,0) @ >1/2>> (1,0) @>1/3>> (2,0) @. @. @. @. \\
@V 1/2 VV @V2/3 VV @V1 VV @. @. @. @. \\
(1,1) @ >2/3>> (2,1) @>1/2>> (3,1) @. @. @. @. \\
@V 1/3 VV @V1/2 VV @V1 VV @. @. @. @. \\
(2,2) @ > 1 >> (3,2) @>1/2>> (4,2) @>1/2>> (5,2)@>1/3>> (6,2)@. @. \\
% @. @. @V1/2VV @V2/3VV @V1 VV @. @. \\
% @. @. (5,3) @>2/3>> (6,3)@>1/2>> (7,3)@. @.
\endCD
$
任何帮助,将不胜感激。
答案1
当您简单加载时,环境CD
并未预先定义amsmath
。您还需要加载amscd
。
也用\begin{CD}
和\end{CD}
来包围身体,而不是\CD
和\endCD
。
\documentclass{article}
\usepackage{amsmath,amscd}
\begin{document}
\[
\begin{CD}
(0,0) @ >1/2>> (1,0) @>1/3>> (2,0) @. @. @. @. \\
@V 1/2 VV @V2/3 VV @V1 VV @. @. @. @. \\
(1,1) @ >2/3>> (2,1) @>1/2>> (3,1) @. @. @. @. \\
@V 1/3 VV @V1/2 VV @V1 VV @. @. @. @. \\
(2,2) @ > 1 >> (3,2) @>1/2>> (4,2) @>1/2>> (5,2)@>1/3>> (6,2)@. @. \\
@. @. @V1/2VV @V2/3VV @V1 VV @. @. \\
@. @. (5,3) @>2/3>> (6,3)@>1/2>> (7,3)@. @.
\end{CD}
\]
\end{document}
您可能想要切换到更现代、更强大的tikz-cd
软件包:
\documentclass{article}
\usepackage{amsmath,tikz-cd}
\begin{document}
\[
\begin{tikzcd}[row sep=2.5em]
% first row
(0,0) \arrow[r,"1/2"] \arrow[d,"1/2"'] &
(1,0) \arrow[r,"1/3"] \arrow[d,"2/3"'] &
(2,0) \arrow[d,"1"'] \\
% second row
(1,1) \arrow[r,"2/3"] \arrow[d,"1/3"'] &
(2,1) \arrow[r,"1/2"] \arrow[d,"1/2"'] &
(3,1) \arrow[d,"1"'] \\
% third row
(2,2) \arrow[r,"1"] &
(3,2) \arrow[r,"1/2"] &
(4,2) \arrow[r,"1/2"] \arrow[d,"1/2"'] &
(5,2) \arrow[r,"1/3"] \arrow[d,"2/3"'] &
(6,2) \arrow[d,"1"'] \\
% fourth row
& &
(5,3) \arrow[r,"2/3"] &
(6,3) \arrow[r,"1/2"] &
(7,3)
\end{tikzcd}
\]
\end{document}
标签'
关闭后的意思是“交换标签的默认位置”。"