-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbetter-equals.tex
73 lines (66 loc) · 3.57 KB
/
better-equals.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
% -*- root: main.tex -*-
% hood chatham: https://tex.stackexchange.com/questions/408832/replacing-tikz-cd-equal-arrow-by-custom-macro-to-work-around-grey-lines-issu/408894#408894
\makeatletter
\def\tikzcdequalsignoffset{0.1em}
% This helper macro finds the start and endpoints of a line between the source and target nodes and stores them in \sourcecoordinate and \targetcoordinate.
% #1 -- source node
% #2 -- target node
\def\findedgesourcetarget#1#2{
\let\sourcecoordinate\pgfutil@empty
\ifx\tikzcd@startanchor\pgfutil@empty % Check that the source doesn't have a specified anchor
\def\tempa{\pgfpointanchor{#1}{center}}% if so, start by taking the center of that coordinate
\else
\edef\tempa{\noexpand\pgfpointanchor{#1}{\expandafter\@gobble\tikzcd@startanchor}} % If it has an anchor, use that
\let\sourcecoordinate\tempa
\fi
\ifx\tikzcd@endanchor\pgfutil@empty % check that the target doesn't have a specified anchor
\def\tempb{\pgfpointshapeborder{#2}{\tempa}}% if so, our end point is the point on the boundary of node b that is in the direction of our initial start coordinate
\else
\edef\tempb{\noexpand\pgfpointanchor{#2}{\expandafter\@gobble\tikzcd@endanchor}}% If it has a specified anchor, use that
\fi
\let\targetcoordinate\tempb
\ifx\sourcecoordinate\pgfutil@empty%
\def\sourcecoordinate{\pgfpointshapeborder{#1}{\tempb}}%
\fi
}
\tikzset{commutative diagrams/equal/.style = {
-,
to path={\pgfextra{
\findedgesourcetarget{\tikzcd@ar@start}{\tikzcd@ar@target} % find endpoints
% Rotate coordinate system so that line goes in x direction
\ifx\tikzcd@startanchor\pgfutil@empty
\def\tikzcd@startanchor{.center}
\fi
\ifx\tikzcd@endanchor\pgfutil@empty
\def\tikzcd@endanchor{.center}
\fi
\pgfmathanglebetweenpoints{\pgfpointanchor{\tikzcd@ar@start}{\expandafter\@gobble\tikzcd@startanchor}}{\pgfpointanchor{\tikzcd@ar@target}{\expandafter\@gobble\tikzcd@endanchor}}
\pgftransformrotate{\pgfmathresult}
% Draw the two lines
\pgfpathmoveto{\pgfpointadd{\sourcecoordinate}{\pgfpoint{0}{\tikzcdequalsignoffset}}}
\pgfpathlineto{\pgfpointadd{\targetcoordinate}{\pgfpoint{0}{\tikzcdequalsignoffset}}}
\pgfpathmoveto{\pgfpointadd{\sourcecoordinate}{\pgfpoint{0}{-\tikzcdequalsignoffset}}}
\pgfpathlineto{\pgfpointadd{\targetcoordinate}{\pgfpoint{0}{-\tikzcdequalsignoffset}}}
\pgfusepath{draw}
}}}}
\tikzset{commutative diagrams/equals/.style = {
-,
to path={\pgfextra{
\findedgesourcetarget{\tikzcd@ar@start}{\tikzcd@ar@target} % find endpoints
% Rotate coordinate system so that line goes in x direction
\ifx\tikzcd@startanchor\pgfutil@empty
\def\tikzcd@startanchor{.center}
\fi
\ifx\tikzcd@endanchor\pgfutil@empty
\def\tikzcd@endanchor{.center}
\fi
\pgfmathanglebetweenpoints{\pgfpointanchor{\tikzcd@ar@start}{\expandafter\@gobble\tikzcd@startanchor}}{\pgfpointanchor{\tikzcd@ar@target}{\expandafter\@gobble\tikzcd@endanchor}}
\pgftransformrotate{\pgfmathresult}
% Draw the two lines
\pgfpathmoveto{\pgfpointadd{\sourcecoordinate}{\pgfpoint{0}{\tikzcdequalsignoffset}}}
\pgfpathlineto{\pgfpointadd{\targetcoordinate}{\pgfpoint{0}{\tikzcdequalsignoffset}}}
\pgfpathmoveto{\pgfpointadd{\sourcecoordinate}{\pgfpoint{0}{-\tikzcdequalsignoffset}}}
\pgfpathlineto{\pgfpointadd{\targetcoordinate}{\pgfpoint{0}{-\tikzcdequalsignoffset}}}
\pgfusepath{draw}
}}}}
\makeatother