我有几个使用 pgfkeys 的宏,是由一位朋友好心编写的(不幸的是,我不是这种高级 pgf/tikz 编码方面的专家)。
其中一个宏绘制了几个正方形及其之间的路径,每个参数都非常灵活且可定制。
\makeatletter
% Setup keys for square macro.
% Used to specify:
% - Labels for arrows.
% - Styles for labels and arrows.
\def\labelstylecodes#1{%
\pgfkeys@split@path%
\edef\label@key{/square/label/\pgfkeyscurrentname}%
\edef\style@key{\pgfkeyscurrentkey/.@val}%
\def\temp@a{#1}%
\def\temp@b{\pgfkeysnovalue}%
\ifx\temp@a\temp@b
\pgfkeysgetvalue{\label@key}\temp@a
\ifx\temp@a\temp@b\else
\pgfkeysalso{commutative diagrams/.cd, \style@key}%
\fi
\else
\pgfkeys{\style@key/.code = \pgfkeysalso{#1}}%
\fi}
\def\arrowstylecodes#1{%
\edef\style@key{\pgfkeyscurrentkey/.@val}%
\def\temp@a{#1}%
\def\temp@b{\pgfkeysnovalue}%
\ifx\temp@a\temp@b
\pgfkeysalso{commutative diagrams/.cd, \style@key}%
\else
\pgfkeys{\style@key/.code = \pgfkeysalso{#1}}%
\fi}
% Don't change these defaults here. These can be changed locally in the
% key-value list provided in a call to the morphism of squares macro.
\pgfkeys{
/square/label/.cd,
0/.initial = {$\bullet$}, 1/.initial = {$\bullet$}, 2/.initial = {$\bullet$},
3/.initial = {$\bullet$},
01/.initial, 12/.initial, 23/.initial,
02/.initial, 03/.initial, 13/.initial,
012/.initial, 013/.initial, 023/.initial, 123/.initial,
0123/.initial,
/square/labelstyle/.cd,
01/.@val/.initial, 12/.@val/.initial, 23/.@val/.initial,
03/.@val/.initial=\pgfkeysalso{swap},
02/.@val/.initial=\pgfkeysalso{description},
13/.@val/.initial=\pgfkeysalso{description},
012/.@val/.initial=\pgfkeysalso{below left = -1pt and -1pt},
013/.@val/.initial=\pgfkeysalso{swap, right},
023/.@val/.initial=\pgfkeysalso{left},
123/.@val/.initial=\pgfkeysalso{swap, below right = -1pt and -1pt},
0123/.@val/.initial,
01/.code=\labelstylecodes{#1}, 02/.code=\labelstylecodes{#1},
03/.code=\labelstylecodes{#1}, 12/.code=\labelstylecodes{#1},
13/.code=\labelstylecodes{#1}, 23/.code=\labelstylecodes{#1},
012/.code=\labelstylecodes{#1}, 013/.code=\labelstylecodes{#1},
023/.code=\labelstylecodes{#1}, 123/.code=\labelstylecodes{#1},
0123/.code=\labelstylecodes{#1},
/square/arrowstyle/.cd,
01/.@val/.initial, 12/.@val/.initial, 23/.@val/.initial,
02/.@val/.initial, 03/.@val/.initial, 13/.@val/.initial,
012/.@val/.initial=\pgfkeysalso{Rightarrow},
013/.@val/.initial=\pgfkeysalso{Rightarrow},
023/.@val/.initial=\pgfkeysalso{Rightarrow},
123/.@val/.initial=\pgfkeysalso{Rightarrow},
0123/.@val/.initial=\pgfkeysalso{triple},
01/.code=\arrowstylecodes{#1}, 02/.code=\arrowstylecodes{#1},
03/.code=\arrowstylecodes{#1}, 12/.code=\arrowstylecodes{#1},
13/.code=\arrowstylecodes{#1}, 23/.code=\arrowstylecodes{#1},
012/.code=\arrowstylecodes{#1}, 013/.code=\arrowstylecodes{#1},
023/.code=\arrowstylecodes{#1}, 123/.code=\arrowstylecodes{#1},
0123/.code=\arrowstylecodes{#1}
}
% Macros to draw 2-cells.
\def\sq@abc{%
\draw [/square/arrowstyle/012] (126:0.25) --
node [/square/labelstyle/012] {
\pgfkeysvalueof{/square/label/012}} (126:0.6);
}
\def\sq@bcd{%
\draw [/square/arrowstyle/123] (54:0.25) --
node [/square/labelstyle/123] {
\pgfkeysvalueof{/square/label/123}} (54:0.6);
}
\def\sq@acd{%
\draw [/square/arrowstyle/023] (-55:0.55) --
node [/square/labelstyle/023] {
\pgfkeysvalueof{/square/label/023}} (-15:0.4);
}
\def\sq@abd{%
\draw [/square/arrowstyle/013] (235:0.55) --
node [/square/labelstyle/013] {
\pgfkeysvalueof{/square/label/013}} (195:0.4);
}
% Macro to draw a single square node.
\def\sq@#1#2{
\begin{scope}[shift=#2, commutative diagrams/every diagram]
\foreach \i in {0,1,2,3} {
\tikzmath{\a = 225 - (90 * \i);}
\node (n{#1}\i) at (\a:1) {
\pgfkeysvalueof{/square/label/\i}};
}
\node (s#1) at (0,0) [circle, inner sep = 0pt,
fit = (n{#1}0.center)(n{#1}1.center)(n{#1}2.center)
(n{#1}3.center)] {};
\begin{scope}[commutative diagrams/.cd, every arrow, every label]
\ifcase #1
\def\list{0/1, 1/2, 2/3, 0/2, 0/3}\or
\def\list{0/1, 1/2, 2/3, 1/3, 0/3}\else
\def\list{}\fi
\foreach \s / \e in \list {
\draw [/square/arrowstyle/\s\e] (n{#1}\s) --
node [/square/labelstyle/\s\e] {
\pgfkeysvalueof{/square/label/\s\e}} (n{#1}\e);
}
\ifcase #1
\sq@abc\sq@acd\or
\sq@abd\sq@bcd
\else\fi
\end{scope}
\end{scope}
}
% The 3-simplex macro itself.
%
% This is the only user callable macro provided here.
%
% Takes a single parameter consisting of a list of key value pairs. These are
% processed using the keys mechanism (pgfkeys) built into TikZ, so they follow
% a familiar format.
%
% /square/label/XXX = .... Set code to typeset label of arrow XXX
% /square/arrowstyle/XXX = ... Set TikZ format for typesetting of arrow XXX.
% Overrides default.
% /square/labelstyle/XXX = ... Set TikZ format for typesetting of label on
% arrow XXX. Overrides default.
%
% Here XXX denotes a sequence of integers identifying a generating cell by
% listing the numbers of the vertices (in order) of the corresponding face of
% the 4-simplex.
%
% You may use the path setting mechanism of pgfkeys to avoid too much path noise
% in a key value list. For example:
%
% \square{/square/label/.cd,
% 0=$0$, 1=$1$, 2=$2$, 3=$3$,
% 01=$a$, 12=$b$, 23=$c$, 02=$f$, 03=$g$, 13=$h$,
% 012=$\alpha$, 023=$\beta$, 123=$\gamma$, 013=$\delta$,
% 0123=$\mathcal{F}$}
%
\def\square#1{
\pgfkeys{#1}
\sq@{0}{(180:1.8)}\sq@{1}{(0:1.8)}
\begin{scope}[commutative diagrams/.cd, every arrow, every label]
\draw [shorten >=10pt, shorten <=10pt, /square/arrowstyle/0123] (s0) --
node [/square/labelstyle/0123] {
\pgfkeysvalueof{/square/label/0123}} (s1);
\end{scope}
}
\makeatother
将上面的代码放在 square.tex 文件中,MWE 将是
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{cd}
\usetikzlibrary{calc}
\usetikzlibrary{math}
\usetikzlibrary{arrows}
\usetikzlibrary{fit}
\usetikzlibrary{positioning}
% Option, used to get squiggly arrows in example.
\usetikzlibrary{decorations.pathmorphing, arrows.meta}
\begin{document}
\input{square}
\begin{tikzpicture}[scale=1.6, font=\footnotesize]
\square{
/square/label/.cd,
01=$f$, 12=$g$, 23=$h$, 03=$i$, 02=$j$, 13=$k$,
012=$\beta$, 023=$\alpha$, 123=$\delta$, 013=$\gamma$,
0123=$\Gamma$,
/square/arrowstyle/.cd,
23={equal}, 01={squiggly},
/square/labelstyle/.cd,
03={swap, near end}
}
\end{tikzpicture}
\end{document}
我对此进行了修改,以获得完全相似的宏,只是与上面的对称。我将其称为正方形。
\makeatletter
% Setup keys for squares macro.
% Used to specify:
% - Labels for arrows.
% - Styles for labels and arrows.
\def\labelstylecode#1{%
\pgfkeys@split@path%
\edef\label@key{/squares/label/\pgfkeyscurrentname}%
\edef\style@key{\pgfkeyscurrentkey/.@val}%
\def\temp@a{#1}%
\def\temp@b{\pgfkeysnovalue}%
\ifx\temp@a\temp@b
\pgfkeysgetvalue{\label@key}\temp@a
\ifx\temp@a\temp@b\else
\pgfkeysalso{commutative diagrams/.cd, \style@key}%
\fi
\else
\pgfkeys{\style@key/.code = \pgfkeysalso{#1}}%
\fi}
\def\arrowstylecode#1{%
\edef\style@key{\pgfkeyscurrentkey/.@val}%
\def\temp@a{#1}%
\def\temp@b{\pgfkeysnovalue}%
\ifx\temp@a\temp@b
\pgfkeysalso{commutative diagrams/.cd, \style@key}%
\else
\pgfkeys{\style@key/.code = \pgfkeysalso{#1}}%
\fi}
% Don't change these defaults here. These can be changed locally in the
% key-value list provided in a call to the morphism of squaress macro.
\pgfkeys{
/squares/label/.cd,
0/.initial = {$\bullet$}, 1/.initial = {$\bullet$}, 2/.initial = {$\bullet$},
3/.initial = {$\bullet$},
01/.initial, 12/.initial, 23/.initial,
02/.initial, 03/.initial, 13/.initial,
012/.initial, 013/.initial, 023/.initial, 123/.initial,
0123/.initial,
/squares/labelstyle/.cd,
01/.@val/.initial=\pgfkeysalso{swap},
12/.@val/.initial=\pgfkeysalso{swap},
23/.@val/.initial=\pgfkeysalso{swap},
03/.@val/.initial,
02/.@val/.initial=\pgfkeysalso{description},
13/.@val/.initial=\pgfkeysalso{description},
012/.@val/.initial=\pgfkeysalso{above left = -1pt and -1pt},
013/.@val/.initial=\pgfkeysalso{swap, right},
023/.@val/.initial=\pgfkeysalso{left},
123/.@val/.initial=\pgfkeysalso{swap, above right = -1pt and -1pt},
0123/.@val/.initial,
01/.code=\labelstylecode{#1}, 02/.code=\labelstylecode{#1},
03/.code=\labelstylecode{#1}, 12/.code=\labelstylecode{#1},
13/.code=\labelstylecode{#1}, 23/.code=\labelstylecode{#1},
012/.code=\labelstylecode{#1}, 013/.code=\labelstylecode{#1},
023/.code=\labelstylecode{#1}, 123/.code=\labelstylecode{#1},
0123/.code=\labelstylecode{#1},
/squares/arrowstyle/.cd,
01/.@val/.initial, 12/.@val/.initial, 23/.@val/.initial,
02/.@val/.initial, 03/.@val/.initial, 13/.@val/.initial,
012/.@val/.initial=\pgfkeysalso{Rightarrow},
013/.@val/.initial=\pgfkeysalso{Rightarrow},
023/.@val/.initial=\pgfkeysalso{Rightarrow},
123/.@val/.initial=\pgfkeysalso{Rightarrow},
0123/.@val/.initial=\pgfkeysalso{Rightarrow},
01/.code=\arrowstylecode{#1}, 02/.code=\arrowstylecode{#1},
03/.code=\arrowstylecode{#1}, 12/.code=\arrowstylecode{#1},
13/.code=\arrowstylecode{#1}, 23/.code=\arrowstylecode{#1},
012/.code=\arrowstylecode{#1}, 013/.code=\arrowstylecode{#1},
023/.code=\arrowstylecode{#1}, 123/.code=\arrowstylecode{#1},
0123/.code=\arrowstylecode{#1}
}
% Macros to draw 2-cells.
\def\sqs@abc{%
\draw [/squares/arrowstyle/012] (235:0.25) --
node [/squares/labelstyle/012] {
\pgfkeysvalueof{/squares/label/012}} (235:0.6);
}
\def\sqs@bcd{%
\draw [/squares/arrowstyle/123] (-54:0.25) --
node [/squares/labelstyle/123] {
\pgfkeysvalueof{/squares/label/123}} (-54:0.6);
}
\def\sqs@acd{%
\draw [/squares/arrowstyle/023] (55:0.55) --
node [/squares/labelstyle/023] {
\pgfkeysvalueof{/squares/label/023}} (15:0.45);
}
\def\sqs@abd{%
\draw [/squares/arrowstyle/013] (125:0.55) --
node [/squares/labelstyle/013] {
\pgfkeysvalueof{/squares/label/013}} (165:0.45);
}
% Macro to draw a single squares node.
\def\sqs@#1#2{
\begin{scope}[shift=#2, commutative diagrams/every diagram]
\foreach \i in {0,1,2,3} {
\tikzmath{\a = 135 + (90 * \i);}
\node (n{#1}\i) at (\a:1) {
\pgfkeysvalueof{/squares/label/\i}};
}
\node (s#1) at (0,0) [circle, inner sep = 0pt,
fit = (n{#1}0.center)(n{#1}1.center)(n{#1}2.center)
(n{#1}3.center)] {};
\begin{scope}[commutative diagrams/.cd, every arrow, every label]
\ifcase #1
\def\list{0/1, 1/2, 2/3, 0/2, 0/3}\or
\def\list{0/1, 1/2, 2/3, 1/3, 0/3}\else
\def\list{}\fi
\foreach \s / \e in \list {
\draw [/squares/arrowstyle/\s\e] (n{#1}\s) --
node [/squares/labelstyle/\s\e] {
\pgfkeysvalueof{/squares/label/\s\e}} (n{#1}\e);
}
\ifcase #1
\sqs@abc\sqs@acd\or
\sqs@abd\sqs@bcd
\else\fi
\end{scope}
\end{scope}
}
% The 3-simplex macro itself.
%
% This is the only user callable macro provided here.
%
% Takes a single parameter consisting of a list of key value pairs. These are
% processed using the keys mechanism (pgfkeys) built into TikZ, so they follow
% a familiar format.
%
% /squares/label/XXX = .... Set code to typeset label of arrow XXX
% /squares/arrowstyle/XXX = ... Set TikZ format for typesetting of arrow XXX.
% Overrides default.
% /squares/labelstyle/XXX = ... Set TikZ format for typesetting of label on
% arrow XXX. Overrides default.
%
% Here XXX denotes a sequence of integers identifying a generating cell by
% listing the numbers of the vertices (in order) of the corresponding face of
% the 4-simplex.
%
% You may use the path setting mechanism of pgfkeys to avoid too much path noise
% in a key value list. For example:
%
% \squares{/squares/label/.cd,
% 0=$0$, 1=$1$, 2=$2$, 3=$3$,
% 01=$a$, 12=$b$, 23=$c$, 02=$f$, 03=$g$, 13=$h$,
% 012=$\alpha$, 023=$\beta$, 123=$\gamma$, 013=$\delta$,
% 0123=$\mathcal{F}$}
%
\def\squares#1{
\pgfkeys{#1}
\sqs@{0}{(180:1.8)}\sqs@{1}{(0:1.8)}
\begin{scope}[commutative diagrams/.cd, every arrow, every label]
\draw [shorten >=10pt, shorten <=10pt, /squares/arrowstyle/0123] (s0) --
node [/squares/labelstyle/0123] {%
\pgfkeysvalueof{/squares/label/0123}} (s1);
\end{scope}
}
\makeatother
到目前为止没有问题。还有最后一个宏,处理一些五边形的迭代五边形。我把这个文件命名为 pent.tex。
\makeatletter
% Setup keys for pentagon macro.
% Used to specify:
% - Labels for arrows.
% - Styles for labels and arrows.
\def\labelstylecode#1{%
\pgfkeys@split@path%
\edef\label@key{/pentagon/label/\pgfkeyscurrentname}%
\edef\style@key{\pgfkeyscurrentkey/.@val}%
\def\temp@a{#1}%
\def\temp@b{\pgfkeysnovalue}%
\ifx\temp@a\temp@b
\pgfkeysgetvalue{\label@key}\temp@a
\ifx\temp@a\temp@b\else
\pgfkeysalso{commutative diagrams/.cd, \style@key}%
\fi
\else
\pgfkeys{\style@key/.code = \pgfkeysalso{#1}}%
\fi}
\def\arrowstylecode#1{%
\edef\style@key{\pgfkeyscurrentkey/.@val}%
\def\temp@a{#1}%
\def\temp@b{\pgfkeysnovalue}%
\ifx\temp@a\temp@b
\pgfkeysalso{commutative diagrams/.cd, \style@key}%
\else
\pgfkeys{\style@key/.code = \pgfkeysalso{#1}}%
\fi}
% Don't change these defaults here. These can be changed locally in the
% key-value list provided in a call to the pentagon of pentagons macro.
\pgfkeys{
/pentagon/label/.cd,
0/.initial = {$\bullet$}, 1/.initial = {$\bullet$}, 2/.initial = {$\bullet$},
3/.initial = {$\bullet$}, 4/.initial = {$\bullet$},
01/.initial, 12/.initial, 23/.initial, 34/.initial, 04/.initial,
02/.initial, 03/.initial, 13/.initial, 14/.initial, 24/.initial,
012/.initial, 013/.initial, 014/.initial, 023/.initial, 024/.initial,
034/.initial, 123/.initial, 124/.initial, 134/.initial, 234/.initial,
0123/.initial, 0124/.initial, 0134/.initial, 0234/.initial, 1234/.initial,
01234/.initial,
/pentagon/labelstyle/.cd,
01/.@val/.initial, 12/.@val/.initial, 23/.@val/.initial, 34/.@val/.initial,
04/.@val/.initial=\pgfkeysalso{swap},
02/.@val/.initial=\pgfkeysalso{description},
03/.@val/.initial=\pgfkeysalso{description},
13/.@val/.initial=\pgfkeysalso{description},
14/.@val/.initial=\pgfkeysalso{description},
24/.@val/.initial=\pgfkeysalso{description},
012/.@val/.initial=\pgfkeysalso{swap, above},
013/.@val/.initial=\pgfkeysalso{below = 1pt},
014/.@val/.initial=\pgfkeysalso{below},
023/.@val/.initial=\pgfkeysalso{swap, above = 1pt},
024/.@val/.initial=\pgfkeysalso{below left = -1pt and -1pt},
034/.@val/.initial=\pgfkeysalso{swap, right},
123/.@val/.initial=\pgfkeysalso{below left = -1pt and -1pt},
124/.@val/.initial=\pgfkeysalso{swap, right},
134/.@val/.initial=\pgfkeysalso{left},
234/.@val/.initial=\pgfkeysalso{swap, below right = -1pt and -1pt},
0123/.@val/.initial,
0124/.@val/.initial=\pgfkeysalso{swap},
0134/.@val/.initial,
0234/.@val/.initial=\pgfkeysalso{swap},
1234/.@val/.initial,
01234/.@val/.initial,
01/.code=\labelstylecode{#1}, 02/.code=\labelstylecode{#1},
03/.code=\labelstylecode{#1}, 04/.code=\labelstylecode{#1},
12/.code=\labelstylecode{#1}, 13/.code=\labelstylecode{#1},
14/.code=\labelstylecode{#1}, 23/.code=\labelstylecode{#1},
24/.code=\labelstylecode{#1}, 34/.code=\labelstylecode{#1},
012/.code=\labelstylecode{#1}, 013/.code=\labelstylecode{#1},
014/.code=\labelstylecode{#1}, 023/.code=\labelstylecode{#1},
024/.code=\labelstylecode{#1}, 034/.code=\labelstylecode{#1},
123/.code=\labelstylecode{#1}, 124/.code=\labelstylecode{#1},
134/.code=\labelstylecode{#1}, 234/.code=\labelstylecode{#1},
0123/.code=\labelstylecode{#1}, 0124/.code=\labelstylecode{#1},
0134/.code=\labelstylecode{#1}, 0234/.code=\labelstylecode{#1},
1234/.code=\labelstylecode{#1}, 01234/.code=\labelstylecode{#1},
/pentagon/arrowstyle/.cd,
01/.@val/.initial, 12/.@val/.initial, 23/.@val/.initial, 34/.@val/.initial,
04/.@val/.initial, 02/.@val/.initial, 03/.@val/.initial, 13/.@val/.initial,
14/.@val/.initial, 24/.@val/.initial,
012/.@val/.initial=\pgfkeysalso{Rightarrow},
013/.@val/.initial=\pgfkeysalso{Rightarrow},
014/.@val/.initial=\pgfkeysalso{Rightarrow},
023/.@val/.initial=\pgfkeysalso{Rightarrow},
024/.@val/.initial=\pgfkeysalso{Rightarrow},
034/.@val/.initial=\pgfkeysalso{Rightarrow},
123/.@val/.initial=\pgfkeysalso{Rightarrow},
124/.@val/.initial=\pgfkeysalso{Rightarrow},
134/.@val/.initial=\pgfkeysalso{Rightarrow},
234/.@val/.initial=\pgfkeysalso{Rightarrow},
0123/.@val/.initial,
0124/.@val/.initial,
0134/.@val/.initial,
0234/.@val/.initial,
1234/.@val/.initial,
01234/.@val/.initial,
01/.code=\arrowstylecode{#1}, 02/.code=\arrowstylecode{#1},
03/.code=\arrowstylecode{#1}, 04/.code=\arrowstylecode{#1},
12/.code=\arrowstylecode{#1}, 13/.code=\arrowstylecode{#1},
14/.code=\arrowstylecode{#1}, 23/.code=\arrowstylecode{#1},
24/.code=\arrowstylecode{#1}, 34/.code=\arrowstylecode{#1},
012/.code=\arrowstylecode{#1}, 013/.code=\arrowstylecode{#1},
014/.code=\arrowstylecode{#1}, 023/.code=\arrowstylecode{#1},
024/.code=\arrowstylecode{#1}, 034/.code=\arrowstylecode{#1},
123/.code=\arrowstylecode{#1}, 124/.code=\arrowstylecode{#1},
134/.code=\arrowstylecode{#1}, 234/.code=\arrowstylecode{#1},
0123/.code=\arrowstylecode{#1}, 0124/.code=\arrowstylecode{#1},
0134/.code=\arrowstylecode{#1}, 0234/.code=\arrowstylecode{#1},
1234/.code=\arrowstylecode{#1}, 01234/.code=\arrowstylecode{#1}
}
% Macros to draw 2-cells.
\def\pent@abc{%
\draw [/pentagon/arrowstyle/012] (198:0.45) --
node [/pentagon/labelstyle/012] {
\pgfkeysvalueof{/pentagon/label/012}} (198:0.8);
}
\def\pent@bcd{%
\draw [/pentagon/arrowstyle/123] (126:0.45) --
node [/pentagon/labelstyle/123] {
\pgfkeysvalueof{/pentagon/label/123}} (126:0.8);
}
\def\pent@cde{%
\draw [/pentagon/arrowstyle/234] (54:0.45) --
node [/pentagon/labelstyle/234] {
\pgfkeysvalueof{/pentagon/label/234}} (54:0.8);
}
\def\pent@ade{%
\draw [/pentagon/arrowstyle/034] (-40:0.6) --
node [/pentagon/labelstyle/034] {
\pgfkeysvalueof{/pentagon/label/034}} (-5:0.5);
}
\def\pent@abe{%014
\draw [/pentagon/arrowstyle/014] (-70:0.55) --
node [/pentagon/labelstyle/014] {
\pgfkeysvalueof{/pentagon/label/014}} (-110:0.55);
}
\def\pent@acd{%
\draw [/pentagon/arrowstyle/023] (55:0.3) --
node [/pentagon/labelstyle/023] {
\pgfkeysvalueof{/pentagon/label/023}} (125:0.3);
}
\def\pent@bde{%
\draw [/pentagon/arrowstyle/134] (-5:0.4) --
node [/pentagon/labelstyle/134] {
\pgfkeysvalueof{/pentagon/label/134}} (35:0.5);
}
\def\pent@ace{%
\draw [/pentagon/arrowstyle/024] (-45:0.45) --
node [/pentagon/labelstyle/024] {
\pgfkeysvalueof{/pentagon/label/024}} (-45:0.1);
}
\def\pent@abd{%
\draw [/pentagon/arrowstyle/013] (-90:0.22) --
node [/pentagon/labelstyle/013] {
\pgfkeysvalueof{/pentagon/label/013}} (-150:0.46);
}
\def\pent@bce{%
\draw [/pentagon/arrowstyle/124] (188:0.4) --
node [/pentagon/labelstyle/124] {
\pgfkeysvalueof{/pentagon/label/124}} (150:0.55);
}
% Macro to draw a single pentagonal node.
\def\pent@#1#2{
\begin{scope}[shift=#2, commutative diagrams/every diagram]
\foreach \i in {0,1,2,3,4} {
\tikzmath{\a = 270 - (72 * \i);}
\node (n{#1}\i) at (\a:1) {
\pgfkeysvalueof{/pentagon/label/\i}};
}
\node (p#1) at (0,0) [circle, inner sep = 0pt,
fit = (n{#1}0.center)(n{#1}1.center)(n{#1}2.center)
(n{#1}3.center)(n{#1}4.center)] {};
\begin{scope}[commutative diagrams/.cd, every arrow, every label]
\ifcase #1
\def\list{0/1, 1/2, 2/3, 3/4, 0/4, 0/2, 0/3}\or
\def\list{0/1, 1/2, 2/3, 3/4, 0/4, 1/3, 1/4}\or
\def\list{0/1, 1/2, 2/3, 3/4, 0/4, 0/2, 2/4}\or
\def\list{0/1, 1/2, 2/3, 3/4, 0/4, 0/3, 1/3}\or
\def\list{0/1, 1/2, 2/3, 3/4, 0/4, 1/4, 2/4}\else
\def\list{}\fi
\foreach \s / \e in \list {
\draw [/pentagon/arrowstyle/\s\e] (n{#1}\s) --
node [/pentagon/labelstyle/\s\e] {
\pgfkeysvalueof{/pentagon/label/\s\e}} (n{#1}\e);
}
\ifcase #1
\pent@abc\pent@acd\pent@ade\or
\pent@bcd\pent@bde\pent@abe\or
\pent@cde\pent@ace\pent@abc\or
\pent@ade\pent@abd\pent@bcd\or
\pent@abe\pent@bce\pent@cde
\else\fi
\end{scope}
\end{scope}
}
% The pentagon of pentagons macro itself.
%
% This is the only user callable macro provided here.
%
% Takes a single parameter consisting of a list of key value pairs. These are
% processed using the keys mechanism (pgfkeys) built into TikZ, so they follow
% a familiar format.
%
% /pentagon/label/XXX = .... Set code to typeset label of arrow XXX
% /pentagon/arrowstyle/XXX = ... Set TikZ format for typesetting of arrow XXX.
% Overrides default.
% /pentagon/labelstyle/XXX = ... Set TikZ format for typesetting of label on
% arrow XXX. Overrides default.
%
% Here XXX denotes a sequence of integers identifying a generating cell by
% listing the numbers of the vertices (in order) of the corresponding face of
% the 4-simplex.
%
% You may use the path setting mechanism of pgfkeys to avoid too much path noise
% in a key value list. For example:
%
% \pentagon{/pentagon/label/.cd,
% 0=$0$, 1=$1$, 2=$2$, 3=$3$, 4=$4$,
% 01=$a$, 12=$b$, 23=$c$, 34=$d$, 04=$e$,
% 02=$f$, 03=$g$, 13=$h$, 14=$k$, 24=$l$,
% 012=$\alpha$, 034=$\beta$, 023=$\gamma$, 123=$\delta$, 134=$\epsilon$,
% 014=$\zeta$, 024=$\eta$, 234=$\theta$, 013=$\iota$, 124=$\kappa$,
% 0123=$\Theta$, 0124=$\Phi$, 0134=$\Psi$, 0234=$\Lambda$, 1234=$\Pi$,
% 01234=$\mathcal{F}$}
%
\def\pentagon#1{
\pgfkeys{#1}
\pent@{2}{(270:3)}\pent@{0}{(198:3)}\pent@{3}{(126:3)}
\pent@{1}{(54:3)}\pent@{4}{(342:3)}
\begin{scope}[commutative diagrams/.cd, every arrow, every label]
\draw [/pentagon/arrowstyle/0123] (p0) --
node [/pentagon/labelstyle/0123] {
\pgfkeysvalueof{/pentagon/label/0123}} (p3);
\draw [/pentagon/arrowstyle/0134] (p3) --
node [/pentagon/labelstyle/0134] {
\pgfkeysvalueof{/pentagon/label/0134}} (p1);
\draw [/pentagon/arrowstyle/1234] (p1) --
node [/pentagon/labelstyle/1234] {
\pgfkeysvalueof{/pentagon/label/1234}} (p4);
\draw [/pentagon/arrowstyle/0234] (p0) --
node [/pentagon/labelstyle/0234] {
\pgfkeysvalueof{/pentagon/label/0234}} (p2);
\draw [/pentagon/arrowstyle/0124] (p2) --
node [/pentagon/labelstyle/0124] {
\pgfkeysvalueof{/pentagon/label/0124}} (p4);
\draw [/pentagon/arrowstyle/01234] (270:0.75) --
node [/pentagon/labelstyle/01234] {
\pgfkeysvalueof{/pentagon/label/01234}} (90:0.75);
\end{scope}
}
\makeatother
问题。虽然正方形和五边形可以完美地协同工作,但当我在同一个主文件中使用五边形和正方形时,就会发生冲突,正方形或五边形的绘制(根据我在主文件中首先调用的那个)会变得奇怪;更准确地说,标签定位会变得混乱。这是一个 MWE:
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
%
\usetikzlibrary{cd}
\usetikzlibrary{calc}
\usetikzlibrary{math}
\usetikzlibrary{arrows}
\usetikzlibrary{fit}
\usetikzlibrary{positioning}
% Option, used to get squiggly arrows in example.
\usetikzlibrary{decorations.pathmorphing, arrows.meta}
\begin{document}
\input{squares}
\input{pent}
%
\noindent Symmetric square
\begin{center}
\begin{tikzpicture}
\squares{
/squares/label/.cd,
01=$f$, 12=$g$, 23=$h$, 03=$i$, 02=$j$, 13=$k$,
012=$\beta$, 023=$\alpha$, 123=$\delta$, 013=$\gamma$,
0123=$\Gamma$
}
\end{tikzpicture}
\end{center}
Pentagon
\begin{center}
\begin{tikzpicture}[scale=1.1]
\pentagon{
/pentagon/label/.cd,
01=$f$, 12=$g$, 23=$h$, 34=$i$, 04=$j$, 02=$k$, 03=$l$,
13=$m$, 14=$n$, 24=$o$,
012=$\alpha$, 023=$\beta$, 034=$\gamma$,
024=$\delta$, 234=$\epsilon$, 014=$\zeta$,
124=$\eta$, 123=$\theta$, 013=$\iota$,
134=$\lambda$,
0234=$A$, 0123=$C$, 0124=$B$,
0134=$D$, 1234=$E$, 01234=$\Theta$
}
\end{tikzpicture}
\end{center}
\end{document}
答案1
问题是\def\labelstylecode
和\def\arrowstylecode
出现在不同的文件中,并且定义不一致。要解决这个问题,请为每个文件分别定义每个宏的一个版本。
更详细地说,可以这样称呼squares.tex
:
\makeatletter
% Setup keys for squares macro.
% Used to specify:
% - Labels for arrows.
% - Styles for labels and arrows.
\def\labelstylecode@square#1{%
\pgfkeys@split@path%
\edef\label@key{/squares/label/\pgfkeyscurrentname}%
\edef\style@key{\pgfkeyscurrentkey/.@val}%
\def\temp@a{#1}%
\def\temp@b{\pgfkeysnovalue}%
\ifx\temp@a\temp@b
\pgfkeysgetvalue{\label@key}\temp@a
\ifx\temp@a\temp@b\else
\pgfkeysalso{commutative diagrams/.cd, \style@key}%
\fi
\else
\pgfkeys{\style@key/.code = \pgfkeysalso{#1}}%
\fi}
\def\arrowstylecode@square#1{%
\edef\style@key{\pgfkeyscurrentkey/.@val}%
\def\temp@a{#1}%
\def\temp@b{\pgfkeysnovalue}%
\ifx\temp@a\temp@b
\pgfkeysalso{commutative diagrams/.cd, \style@key}%
\else
\pgfkeys{\style@key/.code = \pgfkeysalso{#1}}%
\fi}
% Don't change these defaults here. These can be changed locally in the
% key-value list provided in a call to the morphism of squaress macro.
\pgfkeys{
/squares/label/.cd,
0/.initial = {$\bullet$}, 1/.initial = {$\bullet$}, 2/.initial = {$\bullet$},
3/.initial = {$\bullet$},
01/.initial, 12/.initial, 23/.initial,
02/.initial, 03/.initial, 13/.initial,
012/.initial, 013/.initial, 023/.initial, 123/.initial,
0123/.initial,
/squares/labelstyle/.cd,
01/.@val/.initial=\pgfkeysalso{swap},
12/.@val/.initial=\pgfkeysalso{swap},
23/.@val/.initial=\pgfkeysalso{swap},
03/.@val/.initial,
02/.@val/.initial=\pgfkeysalso{description},
13/.@val/.initial=\pgfkeysalso{description},
012/.@val/.initial=\pgfkeysalso{above left = -1pt and -1pt},
013/.@val/.initial=\pgfkeysalso{swap, right},
023/.@val/.initial=\pgfkeysalso{left},
123/.@val/.initial=\pgfkeysalso{swap, above right = -1pt and -1pt},
0123/.@val/.initial,
01/.code=\labelstylecode@square{#1}, 02/.code=\labelstylecode@square{#1},
03/.code=\labelstylecode@square{#1}, 12/.code=\labelstylecode@square{#1},
13/.code=\labelstylecode@square{#1}, 23/.code=\labelstylecode@square{#1},
012/.code=\labelstylecode@square{#1}, 013/.code=\labelstylecode@square{#1},
023/.code=\labelstylecode@square{#1}, 123/.code=\labelstylecode@square{#1},
0123/.code=\labelstylecode@square{#1},
/squares/arrowstyle/.cd,
01/.@val/.initial, 12/.@val/.initial, 23/.@val/.initial,
02/.@val/.initial, 03/.@val/.initial, 13/.@val/.initial,
012/.@val/.initial=\pgfkeysalso{Rightarrow},
013/.@val/.initial=\pgfkeysalso{Rightarrow},
023/.@val/.initial=\pgfkeysalso{Rightarrow},
123/.@val/.initial=\pgfkeysalso{Rightarrow},
0123/.@val/.initial=\pgfkeysalso{Rightarrow},
01/.code=\arrowstylecode@square{#1}, 02/.code=\arrowstylecode@square{#1},
03/.code=\arrowstylecode@square{#1}, 12/.code=\arrowstylecode@square{#1},
13/.code=\arrowstylecode@square{#1}, 23/.code=\arrowstylecode@square{#1},
012/.code=\arrowstylecode@square{#1}, 013/.code=\arrowstylecode@square{#1},
023/.code=\arrowstylecode@square{#1}, 123/.code=\arrowstylecode@square{#1},
0123/.code=\arrowstylecode@square{#1}
}
% Macros to draw 2-cells.
\def\sqs@abc{%
\draw [/squares/arrowstyle/012] (235:0.25) --
node [/squares/labelstyle/012] {
\pgfkeysvalueof{/squares/label/012}} (235:0.6);
}
\def\sqs@bcd{%
\draw [/squares/arrowstyle/123] (-54:0.25) --
node [/squares/labelstyle/123] {
\pgfkeysvalueof{/squares/label/123}} (-54:0.6);
}
\def\sqs@acd{%
\draw [/squares/arrowstyle/023] (55:0.55) --
node [/squares/labelstyle/023] {
\pgfkeysvalueof{/squares/label/023}} (15:0.45);
}
\def\sqs@abd{%
\draw [/squares/arrowstyle/013] (125:0.55) --
node [/squares/labelstyle/013] {
\pgfkeysvalueof{/squares/label/013}} (165:0.45);
}
% Macro to draw a single squares node.
\def\sqs@#1#2{
\begin{scope}[shift=#2, commutative diagrams/every diagram]
\foreach \i in {0,1,2,3} {
\tikzmath{\a = 135 + (90 * \i);}
\node (n{#1}\i) at (\a:1) {
\pgfkeysvalueof{/squares/label/\i}};
}
\node (s#1) at (0,0) [circle, inner sep = 0pt,
fit = (n{#1}0.center)(n{#1}1.center)(n{#1}2.center)
(n{#1}3.center)] {};
\begin{scope}[commutative diagrams/.cd, every arrow, every label]
\ifcase #1
\def\list{0/1, 1/2, 2/3, 0/2, 0/3}\or
\def\list{0/1, 1/2, 2/3, 1/3, 0/3}\else
\def\list{}\fi
\foreach \s / \e in \list {
\draw [/squares/arrowstyle/\s\e] (n{#1}\s) --
node [/squares/labelstyle/\s\e] {
\pgfkeysvalueof{/squares/label/\s\e}} (n{#1}\e);
}
\ifcase #1
\sqs@abc\sqs@acd\or
\sqs@abd\sqs@bcd
\else\fi
\end{scope}
\end{scope}
}
% The 3-simplex macro itself.
%
% This is the only user callable macro provided here.
%
% Takes a single parameter consisting of a list of key value pairs. These are
% processed using the keys mechanism (pgfkeys) built into TikZ, so they follow
% a familiar format.
%
% /squares/label/XXX = .... Set code to typeset label of arrow XXX
% /squares/arrowstyle/XXX = ... Set TikZ format for typesetting of arrow XXX.
% Overrides default.
% /squares/labelstyle/XXX = ... Set TikZ format for typesetting of label on
% arrow XXX. Overrides default.
%
% Here XXX denotes a sequence of integers identifying a generating cell by
% listing the numbers of the vertices (in order) of the corresponding face of
% the 4-simplex.
%
% You may use the path setting mechanism of pgfkeys to avoid too much path noise
% in a key value list. For example:
%
% \squares{/squares/label/.cd,
% 0=$0$, 1=$1$, 2=$2$, 3=$3$,
% 01=$a$, 12=$b$, 23=$c$, 02=$f$, 03=$g$, 13=$h$,
% 012=$\alpha$, 023=$\beta$, 123=$\gamma$, 013=$\delta$,
% 0123=$\mathcal{F}$}
%
\def\squares#1{
\pgfkeys{#1}
\sqs@{0}{(180:1.8)}\sqs@{1}{(0:1.8)}
\begin{scope}[commutative diagrams/.cd, every arrow, every label]
\draw [shorten >=10pt, shorten <=10pt, /squares/arrowstyle/0123] (s0) --
node [/squares/labelstyle/0123] {%
\pgfkeysvalueof{/squares/label/0123}} (s1);
\end{scope}
}
\makeatother
和这个pent.tex
:
\makeatletter
% Setup keys for pentagon macro.
% Used to specify:
% - Labels for arrows.
% - Styles for labels and arrows.
\def\labelstylecode@pent#1{%
\pgfkeys@split@path%
\edef\label@key{/pentagon/label/\pgfkeyscurrentname}%
\edef\style@key{\pgfkeyscurrentkey/.@val}%
\def\temp@a{#1}%
\def\temp@b{\pgfkeysnovalue}%
\ifx\temp@a\temp@b
\pgfkeysgetvalue{\label@key}\temp@a
\ifx\temp@a\temp@b\else
\pgfkeysalso{commutative diagrams/.cd, \style@key}%
\fi
\else
\pgfkeys{\style@key/.code = \pgfkeysalso{#1}}%
\fi}
\def\arrowstylecode@pent#1{%
\edef\style@key{\pgfkeyscurrentkey/.@val}%
\def\temp@a{#1}%
\def\temp@b{\pgfkeysnovalue}%
\ifx\temp@a\temp@b
\pgfkeysalso{commutative diagrams/.cd, \style@key}%
\else
\pgfkeys{\style@key/.code = \pgfkeysalso{#1}}%
\fi}
% Don't change these defaults here. These can be changed locally in the
% key-value list provided in a call to the pentagon of pentagons macro.
\pgfkeys{
/pentagon/label/.cd,
0/.initial = {$\bullet$}, 1/.initial = {$\bullet$}, 2/.initial = {$\bullet$},
3/.initial = {$\bullet$}, 4/.initial = {$\bullet$},
01/.initial, 12/.initial, 23/.initial, 34/.initial, 04/.initial,
02/.initial, 03/.initial, 13/.initial, 14/.initial, 24/.initial,
012/.initial, 013/.initial, 014/.initial, 023/.initial, 024/.initial,
034/.initial, 123/.initial, 124/.initial, 134/.initial, 234/.initial,
0123/.initial, 0124/.initial, 0134/.initial, 0234/.initial, 1234/.initial,
01234/.initial,
/pentagon/labelstyle/.cd,
01/.@val/.initial, 12/.@val/.initial, 23/.@val/.initial, 34/.@val/.initial,
04/.@val/.initial=\pgfkeysalso{swap},
02/.@val/.initial=\pgfkeysalso{description},
03/.@val/.initial=\pgfkeysalso{description},
13/.@val/.initial=\pgfkeysalso{description},
14/.@val/.initial=\pgfkeysalso{description},
24/.@val/.initial=\pgfkeysalso{description},
012/.@val/.initial=\pgfkeysalso{swap, above},
013/.@val/.initial=\pgfkeysalso{below = 1pt},
014/.@val/.initial=\pgfkeysalso{below},
023/.@val/.initial=\pgfkeysalso{swap, above = 1pt},
024/.@val/.initial=\pgfkeysalso{below left = -1pt and -1pt},
034/.@val/.initial=\pgfkeysalso{swap, right},
123/.@val/.initial=\pgfkeysalso{below left = -1pt and -1pt},
124/.@val/.initial=\pgfkeysalso{swap, right},
134/.@val/.initial=\pgfkeysalso{left},
234/.@val/.initial=\pgfkeysalso{swap, below right = -1pt and -1pt},
0123/.@val/.initial,
0124/.@val/.initial=\pgfkeysalso{swap},
0134/.@val/.initial,
0234/.@val/.initial=\pgfkeysalso{swap},
1234/.@val/.initial,
01234/.@val/.initial,
01/.code=\labelstylecode@pent{#1}, 02/.code=\labelstylecode@pent{#1},
03/.code=\labelstylecode@pent{#1}, 04/.code=\labelstylecode@pent{#1},
12/.code=\labelstylecode@pent{#1}, 13/.code=\labelstylecode@pent{#1},
14/.code=\labelstylecode@pent{#1}, 23/.code=\labelstylecode@pent{#1},
24/.code=\labelstylecode@pent{#1}, 34/.code=\labelstylecode@pent{#1},
012/.code=\labelstylecode@pent{#1}, 013/.code=\labelstylecode@pent{#1},
014/.code=\labelstylecode@pent{#1}, 023/.code=\labelstylecode@pent{#1},
024/.code=\labelstylecode@pent{#1}, 034/.code=\labelstylecode@pent{#1},
123/.code=\labelstylecode@pent{#1}, 124/.code=\labelstylecode@pent{#1},
134/.code=\labelstylecode@pent{#1}, 234/.code=\labelstylecode@pent{#1},
0123/.code=\labelstylecode@pent{#1}, 0124/.code=\labelstylecode@pent{#1},
0134/.code=\labelstylecode@pent{#1}, 0234/.code=\labelstylecode@pent{#1},
1234/.code=\labelstylecode@pent{#1}, 01234/.code=\labelstylecode@pent{#1},
/pentagon/arrowstyle/.cd,
01/.@val/.initial, 12/.@val/.initial, 23/.@val/.initial, 34/.@val/.initial,
04/.@val/.initial, 02/.@val/.initial, 03/.@val/.initial, 13/.@val/.initial,
14/.@val/.initial, 24/.@val/.initial,
012/.@val/.initial=\pgfkeysalso{Rightarrow},
013/.@val/.initial=\pgfkeysalso{Rightarrow},
014/.@val/.initial=\pgfkeysalso{Rightarrow},
023/.@val/.initial=\pgfkeysalso{Rightarrow},
024/.@val/.initial=\pgfkeysalso{Rightarrow},
034/.@val/.initial=\pgfkeysalso{Rightarrow},
123/.@val/.initial=\pgfkeysalso{Rightarrow},
124/.@val/.initial=\pgfkeysalso{Rightarrow},
134/.@val/.initial=\pgfkeysalso{Rightarrow},
234/.@val/.initial=\pgfkeysalso{Rightarrow},
0123/.@val/.initial,
0124/.@val/.initial,
0134/.@val/.initial,
0234/.@val/.initial,
1234/.@val/.initial,
01234/.@val/.initial,
01/.code=\arrowstylecode@pent{#1}, 02/.code=\arrowstylecode@pent{#1},
03/.code=\arrowstylecode@pent{#1}, 04/.code=\arrowstylecode@pent{#1},
12/.code=\arrowstylecode@pent{#1}, 13/.code=\arrowstylecode@pent{#1},
14/.code=\arrowstylecode@pent{#1}, 23/.code=\arrowstylecode@pent{#1},
24/.code=\arrowstylecode@pent{#1}, 34/.code=\arrowstylecode@pent{#1},
012/.code=\arrowstylecode@pent{#1}, 013/.code=\arrowstylecode@pent{#1},
014/.code=\arrowstylecode@pent{#1}, 023/.code=\arrowstylecode@pent{#1},
024/.code=\arrowstylecode@pent{#1}, 034/.code=\arrowstylecode@pent{#1},
123/.code=\arrowstylecode@pent{#1}, 124/.code=\arrowstylecode@pent{#1},
134/.code=\arrowstylecode@pent{#1}, 234/.code=\arrowstylecode@pent{#1},
0123/.code=\arrowstylecode@pent{#1}, 0124/.code=\arrowstylecode@pent{#1},
0134/.code=\arrowstylecode@pent{#1}, 0234/.code=\arrowstylecode@pent{#1},
1234/.code=\arrowstylecode@pent{#1}, 01234/.code=\arrowstylecode@pent{#1}
}
% Macros to draw 2-cells.
\def\pent@abc{%
\draw [/pentagon/arrowstyle/012] (198:0.45) --
node [/pentagon/labelstyle/012] {
\pgfkeysvalueof{/pentagon/label/012}} (198:0.8);
}
\def\pent@bcd{%
\draw [/pentagon/arrowstyle/123] (126:0.45) --
node [/pentagon/labelstyle/123] {
\pgfkeysvalueof{/pentagon/label/123}} (126:0.8);
}
\def\pent@cde{%
\draw [/pentagon/arrowstyle/234] (54:0.45) --
node [/pentagon/labelstyle/234] {
\pgfkeysvalueof{/pentagon/label/234}} (54:0.8);
}
\def\pent@ade{%
\draw [/pentagon/arrowstyle/034] (-40:0.6) --
node [/pentagon/labelstyle/034] {
\pgfkeysvalueof{/pentagon/label/034}} (-5:0.5);
}
\def\pent@abe{%014
\draw [/pentagon/arrowstyle/014] (-70:0.55) --
node [/pentagon/labelstyle/014] {
\pgfkeysvalueof{/pentagon/label/014}} (-110:0.55);
}
\def\pent@acd{%
\draw [/pentagon/arrowstyle/023] (55:0.3) --
node [/pentagon/labelstyle/023] {
\pgfkeysvalueof{/pentagon/label/023}} (125:0.3);
}
\def\pent@bde{%
\draw [/pentagon/arrowstyle/134] (-5:0.4) --
node [/pentagon/labelstyle/134] {
\pgfkeysvalueof{/pentagon/label/134}} (35:0.5);
}
\def\pent@ace{%
\draw [/pentagon/arrowstyle/024] (-45:0.45) --
node [/pentagon/labelstyle/024] {
\pgfkeysvalueof{/pentagon/label/024}} (-45:0.1);
}
\def\pent@abd{%
\draw [/pentagon/arrowstyle/013] (-90:0.22) --
node [/pentagon/labelstyle/013] {
\pgfkeysvalueof{/pentagon/label/013}} (-150:0.46);
}
\def\pent@bce{%
\draw [/pentagon/arrowstyle/124] (188:0.4) --
node [/pentagon/labelstyle/124] {
\pgfkeysvalueof{/pentagon/label/124}} (150:0.55);
}
% Macro to draw a single pentagonal node.
\def\pent@#1#2{
\begin{scope}[shift=#2, commutative diagrams/every diagram]
\foreach \i in {0,1,2,3,4} {
\tikzmath{\a = 270 - (72 * \i);}
\node (n{#1}\i) at (\a:1) {
\pgfkeysvalueof{/pentagon/label/\i}};
}
\node (p#1) at (0,0) [circle, inner sep = 0pt,
fit = (n{#1}0.center)(n{#1}1.center)(n{#1}2.center)
(n{#1}3.center)(n{#1}4.center)] {};
\begin{scope}[commutative diagrams/.cd, every arrow, every label]
\ifcase #1
\def\list{0/1, 1/2, 2/3, 3/4, 0/4, 0/2, 0/3}\or
\def\list{0/1, 1/2, 2/3, 3/4, 0/4, 1/3, 1/4}\or
\def\list{0/1, 1/2, 2/3, 3/4, 0/4, 0/2, 2/4}\or
\def\list{0/1, 1/2, 2/3, 3/4, 0/4, 0/3, 1/3}\or
\def\list{0/1, 1/2, 2/3, 3/4, 0/4, 1/4, 2/4}\else
\def\list{}\fi
\foreach \s / \e in \list {
\draw [/pentagon/arrowstyle/\s\e] (n{#1}\s) --
node [/pentagon/labelstyle/\s\e] {
\pgfkeysvalueof{/pentagon/label/\s\e}} (n{#1}\e);
}
\ifcase #1
\pent@abc\pent@acd\pent@ade\or
\pent@bcd\pent@bde\pent@abe\or
\pent@cde\pent@ace\pent@abc\or
\pent@ade\pent@abd\pent@bcd\or
\pent@abe\pent@bce\pent@cde
\else\fi
\end{scope}
\end{scope}
}
% The pentagon of pentagons macro itself.
%
% This is the only user callable macro provided here.
%
% Takes a single parameter consisting of a list of key value pairs. These are
% processed using the keys mechanism (pgfkeys) built into TikZ, so they follow
% a familiar format.
%
% /pentagon/label/XXX = .... Set code to typeset label of arrow XXX
% /pentagon/arrowstyle/XXX = ... Set TikZ format for typesetting of arrow XXX.
% Overrides default.
% /pentagon/labelstyle/XXX = ... Set TikZ format for typesetting of label on
% arrow XXX. Overrides default.
%
% Here XXX denotes a sequence of integers identifying a generating cell by
% listing the numbers of the vertices (in order) of the corresponding face of
% the 4-simplex.
%
% You may use the path setting mechanism of pgfkeys to avoid too much path noise
% in a key value list. For example:
%
% \pentagon{/pentagon/label/.cd,
% 0=$0$, 1=$1$, 2=$2$, 3=$3$, 4=$4$,
% 01=$a$, 12=$b$, 23=$c$, 34=$d$, 04=$e$,
% 02=$f$, 03=$g$, 13=$h$, 14=$k$, 24=$l$,
% 012=$\alpha$, 034=$\beta$, 023=$\gamma$, 123=$\delta$, 134=$\epsilon$,
% 014=$\zeta$, 024=$\eta$, 234=$\theta$, 013=$\iota$, 124=$\kappa$,
% 0123=$\Theta$, 0124=$\Phi$, 0134=$\Psi$, 0234=$\Lambda$, 1234=$\Pi$,
% 01234=$\mathcal{F}$}
%
\def\pentagon#1{
\pgfkeys{#1}
\pent@{2}{(270:3)}\pent@{0}{(198:3)}\pent@{3}{(126:3)}
\pent@{1}{(54:3)}\pent@{4}{(342:3)}
\begin{scope}[commutative diagrams/.cd, every arrow, every label]
\draw [/pentagon/arrowstyle/0123] (p0) --
node [/pentagon/labelstyle/0123] {
\pgfkeysvalueof{/pentagon/label/0123}} (p3);
\draw [/pentagon/arrowstyle/0134] (p3) --
node [/pentagon/labelstyle/0134] {
\pgfkeysvalueof{/pentagon/label/0134}} (p1);
\draw [/pentagon/arrowstyle/1234] (p1) --
node [/pentagon/labelstyle/1234] {
\pgfkeysvalueof{/pentagon/label/1234}} (p4);
\draw [/pentagon/arrowstyle/0234] (p0) --
node [/pentagon/labelstyle/0234] {
\pgfkeysvalueof{/pentagon/label/0234}} (p2);
\draw [/pentagon/arrowstyle/0124] (p2) --
node [/pentagon/labelstyle/0124] {
\pgfkeysvalueof{/pentagon/label/0124}} (p4);
\draw [/pentagon/arrowstyle/01234] (270:0.75) --
node [/pentagon/labelstyle/01234] {
\pgfkeysvalueof{/pentagon/label/01234}} (90:0.75);
\end{scope}
}
\makeatother
现在正在编译你的文件
\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
%
\usetikzlibrary{cd}
\usetikzlibrary{math}
\usetikzlibrary{fit}
\usetikzlibrary{positioning}
%
\input{squares}
\input{pent}
\begin{document}
%
\noindent Symmetric square
\begin{center}
\begin{tikzpicture}
\squares{
/squares/label/.cd,
01=$f$, 12=$g$, 23=$h$, 03=$i$, 02=$j$, 13=$k$,
012=$\beta$, 023=$\alpha$, 123=$\delta$, 013=$\gamma$,
0123=$\Gamma$
}
\end{tikzpicture}
\end{center}
Pentagon
\begin{center}
\begin{tikzpicture}[scale=1.1]
\pentagon{
/pentagon/label/.cd,
01=$f$, 12=$g$, 23=$h$, 34=$i$, 04=$j$, 02=$k$, 03=$l$,
13=$m$, 14=$n$, 24=$o$,
012=$\alpha$, 023=$\beta$, 034=$\gamma$,
024=$\delta$, 234=$\epsilon$, 014=$\zeta$,
124=$\eta$, 123=$\theta$, 013=$\iota$,
134=$\lambda$,
0234=$A$, 0123=$C$, 0124=$B$,
0134=$D$, 1234=$E$, 01234=$\Theta$
}
\end{tikzpicture}
\end{center}
\end{document}
产量
请注意,对于这些代码的一些细节,可能不适合进行后续提问。我也不确定在这个网站上用这么多行来交换代码是否合适,但只要不让帖子超出限制,就可以了。