diff options
author | Karl Berry <karl@freefriends.org> | 2018-12-10 22:57:17 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2018-12-10 22:57:17 +0000 |
commit | c871eb0744646b3fa09135cc962cdc2d15cd83a0 (patch) | |
tree | dc5750349c91dbd4aeb9e2ec6ffd7cf840909280 /Master/texmf-dist/tex | |
parent | b5a51fa6a8498c3a5ce9f196b981259813415818 (diff) |
adigraph (10dec18)
git-svn-id: svn://tug.org/texlive/trunk@49374 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/latex/adigraph/adigraph.sty | 179 |
1 files changed, 133 insertions, 46 deletions
diff --git a/Master/texmf-dist/tex/latex/adigraph/adigraph.sty b/Master/texmf-dist/tex/latex/adigraph/adigraph.sty index 5d203a68dcf..52f9e8de77d 100644 --- a/Master/texmf-dist/tex/latex/adigraph/adigraph.sty +++ b/Master/texmf-dist/tex/latex/adigraph/adigraph.sty @@ -7,7 +7,7 @@ % % THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. % -\def\AdigraphVersionNumber{v1.6.1} +\def\AdigraphVersionNumber{v1.7.0} \NeedsTeXFormat{LaTeX2e}[1994/06/01] \ProvidesPackage{adigraph} @@ -20,8 +20,15 @@ \RequirePackage{tikz} \usetikzlibrary{calc} +\def\AdigraphZero{0} +\def\AdigraphTextualZero{zero} +\def\AdigraphDefaultColor{black} +\def\AdigraphDefaultWidth{0.4} +\def\AdigraphRed{red!90} +\def\AdigraphCyan{cyan!90} + \makeatletter -\newcommand*{\AdigraphRom}[1]{\expandafter\@slowromancap\romannumeral #1@} +\newcommand{\AdigraphRom}[1]{\expandafter\@slowromancap\romannumeral #1@} \makeatother \newcounter{AdigraphTotalNodeCounter} @@ -30,8 +37,6 @@ \newcounter{AdigraphCurrentPathNumber} \newcounter{AdigraphAdjacentNodes} -\def\AdigraphZero{0} - \NewDocumentCommand{\AdigraphDrawNode}{m}{% % % #1 is node normalized id @@ -42,7 +47,7 @@ \letcs{\nodeColor}{adigraphNode#1Color} \letcs{\nodeWidth}{adigraphNode#1Width} % - \node[vertex,\nodeColor,line width=\nodeWidth pt] (#1) at (\nodeX,\nodeY) {\nodeLabel}; + \node[vertex,color=\nodeColor,line width=\nodeWidth pt] (#1) at (\nodeX,\nodeY) {\nodeLabel}; } \NewDocumentCommand{\sumOfOrientations}{m}{} @@ -91,9 +96,9 @@ % The twin edge won't be drawn % This edge will be a straight line \ifbool{adigraphEdge#1v#2HasEmptyLabel}{ - \draw[edge,\edgeColor,line width=\edgeWidth pt] (#1) to (#2); + \draw[edge,color=\edgeColor,line width=\edgeWidth pt] (#1) to (#2); }{ - \draw[edge,\edgeColor,line width=\edgeWidth pt] (#1) to node[\edgeLabelPosition, fill=white] {\edgeLabel}(#2); + \draw[edge,color=\edgeColor,line width=\edgeWidth pt] (#1) to node[\edgeLabelPosition, fill=white] {\edgeLabel}(#2); } }{% \IfEq{#1}{#2}{ @@ -142,16 +147,16 @@ \pgfmathsetmacro{\leftAngle}{\centralAngle-35} \pgfmathsetmacro{\rightAngle}{\centralAngle+35} \ifbool{adigraphEdge#1v#2HasEmptyLabel}{ - \draw[edge,\edgeColor,line width=\edgeWidth pt] (#1) to [out=\leftAngle,in=\rightAngle,looseness=8](#1); + \draw[edge,color=\edgeColor,line width=\edgeWidth pt] (#1) to [out=\leftAngle,in=\rightAngle,looseness=8](#1); }{ - \draw[edge,\edgeColor,line width=\edgeWidth pt] (#1) to [out=\leftAngle,in=\rightAngle,looseness=8] node[\edgeLabelPosition, fill=white] {\edgeLabel}(#1); + \draw[edge,color=\edgeColor,line width=\edgeWidth pt] (#1) to [out=\leftAngle,in=\rightAngle,looseness=8] node[\edgeLabelPosition, fill=white] {\edgeLabel}(#1); } }{ % Both edges have to be drawn, they will be curly \ifbool{adigraphEdge#1v#2HasEmptyLabel}{ - \draw[edge,\edgeColor,line width=\edgeWidth pt] (#1) to [bend right=20] (#2); + \draw[edge,color=\edgeColor,line width=\edgeWidth pt] (#1) to [bend right=20] (#2); }{ - \draw[edge,\edgeColor,line width=\edgeWidth pt] (#1) to [bend right=20] node[\edgeLabelPosition, fill=white] {\edgeLabel}(#2); + \draw[edge,color=\edgeColor,line width=\edgeWidth pt] (#1) to [bend right=20] node[\edgeLabelPosition, fill=white] {\edgeLabel}(#2); } } }% @@ -159,7 +164,7 @@ } } -\NewDocumentCommand{\AdigraphGenerateNodeName}{m G{black} G{0.4}}{} +\NewDocumentCommand{\AdigraphGenerateNodeName}{m G{\AdigraphDefaultColor} G{\AdigraphDefaultWidth}}{} \NewDocumentCommand{\AdigraphMemorizeNode}{m G{}}{} \NewDocumentCommand{\AdigraphBuildNode}{> { \SplitArgument{ 2 } {,} } m > { \SplitArgument{ 1 } {,} } m m}{% @@ -168,16 +173,33 @@ % #2 -> list of coordinates % #3 -> optional label % - \RenewDocumentCommand{\AdigraphGenerateNodeName}{m G{black} G{0.4}}{% + \RenewDocumentCommand{\AdigraphGenerateNodeName}{m G{\AdigraphDefaultColor} G{\AdigraphDefaultWidth}}{% + % + % ##1 -> node name, not normalized + % ##2 -> color + % ##3 -> width + % \IfInteger{##1}{% - \def\AdigraphNodeName{\AdigraphRom{##1}}% - \listxadd{\AdigraphNodeList}{\AdigraphRom{##1}} + \IfEq{##1}{\AdigraphZero}{ + \def\AdigraphNodeName{\AdigraphTextualZero}% + }{ + \def\AdigraphNodeName{\AdigraphRom{##1}}% + } }{% \def\AdigraphNodeName{##1}% - \listxadd{\AdigraphNodeList}{##1} }% - \csdef{adigraphNode\AdigraphNodeName Color}{##2}% - \csdef{adigraphNode\AdigraphNodeName Width}{##3}% + \listxadd{\AdigraphNodeList}{\AdigraphNodeName} + \ifblank{##2}{ + \csdef{adigraphNode\AdigraphNodeName Color}{\AdigraphDefaultColor}% + }{ + \csdef{adigraphNode\AdigraphNodeName Color}{##2}% + } + \ifblank{##3}{ + \csdef{adigraphNode\AdigraphNodeName Width}{\AdigraphDefaultWidth}% + }{ + \csdef{adigraphNode\AdigraphNodeName Width}{##3}% + } + \ifblank{#3}{ \csdef{adigraphNode\AdigraphNodeName Label}{##1}% }{ @@ -212,7 +234,7 @@ \AdigraphMemorizeNode#2 } -\NewDocumentCommand{\AdigraphMemorizeEdge}{m m G{black} G{0.4}}{} +\NewDocumentCommand{\AdigraphMemorizeEdge}{m m G{\AdigraphDefaultColor} G{\AdigraphDefaultWidth}}{} \NewDocumentCommand{\AdigraphBuildEdge}{> {\SplitArgument{3}{,}} m m m m}{% % @@ -221,14 +243,28 @@ % #3 -> Label, defaults to weight % #4 -> Label position, defaults to midway % - \RenewDocumentCommand{\AdigraphMemorizeEdge}{m m G{black} G{0.4}}{% + \RenewDocumentCommand{\AdigraphMemorizeEdge}{m m G{\AdigraphDefaultColor} G{\AdigraphDefaultWidth}}{% + % + % ##1 -> first edge + % ##2 -> second edge + % ##3 -> color + % ##4 -> width + % \IfInteger{##1}{% - \csedef{AdigraphFirstNode}{\AdigraphRom{##1}}% + \IfEq{##1}{\AdigraphZero}{ + \csedef{AdigraphFirstNode}{\AdigraphTextualZero}% + }{ + \csedef{AdigraphFirstNode}{\AdigraphRom{##1}}% + } }{% \csedef{AdigraphFirstNode}{##1}% }% \IfInteger{##2}{% - \csedef{AdigraphSecondNode}{\AdigraphRom{##2}}% + \IfEq{##2}{\AdigraphZero}{ + \csedef{AdigraphSecondNode}{\AdigraphTextualZero}% + }{ + \csedef{AdigraphSecondNode}{\AdigraphRom{##2}}% + } }{% \csedef{AdigraphSecondNode}{##2}% }% @@ -258,8 +294,16 @@ \csdef{adigraphEdge\AdigraphEdgeName Weight}{#2}% }% \csdef{adigraphEdge\AdigraphEdgeName Label}{#3}% - \csdef{adigraphEdge\AdigraphEdgeName Color}{##3}% - \csdef{adigraphEdge\AdigraphEdgeName Width}{##4}% + \ifblank{##3}{ + \csdef{adigraphEdge\AdigraphEdgeName Color}{\AdigraphDefaultColor}% + }{ + \csdef{adigraphEdge\AdigraphEdgeName Color}{##3}% + } + \ifblank{##4}{ + \csdef{adigraphEdge\AdigraphEdgeName Width}{\AdigraphDefaultWidth}% + }{ + \csdef{adigraphEdge\AdigraphEdgeName Width}{##4}% + } \csdef{adigraphEdge\AdigraphEdgeName LabelPosition}{#4}% }{ \PackageError{adigraph}{% @@ -294,7 +338,7 @@ } } -\NewDocumentCommand{\AdigraphElaboratePath}{m m G{black}}{} +\NewDocumentCommand{\AdigraphElaboratePath}{m m G{\AdigraphDefaultColor}}{} \NewDocumentCommand{\AdigraphSimpleSum}{m m m}{% % @@ -352,11 +396,26 @@ \listgadd{\AdigraphEdgeList}{#2,#1} } - \cslet{adigraphEdge#1v#2Color}{#4}% - \cslet{adigraphEdge#2v#1Color}{#5}% - - \cslet{adigraphEdge#1v#2Width}{#6}% - \cslet{adigraphEdge#2v#1Width}{#7}% + \ifblank{#4}{ + \cslet{adigraphEdge#1v#2Color}{\AdigraphDefaultColor}% + }{ + \cslet{adigraphEdge#1v#2Color}{#4}% + } + \ifblank{#5}{ + \cslet{adigraphEdge#2v#1Color}{\AdigraphDefaultColor}% + }{ + \cslet{adigraphEdge#2v#1Color}{#5}% + } + \ifblank{#6}{ + \cslet{adigraphEdge#1v#2Width}{\AdigraphDefaultWidth}% + }{ + \cslet{adigraphEdge#1v#2Width}{#6}% + } + \ifblank{#7}{ + \cslet{adigraphEdge#2v#1Width}{\AdigraphDefaultWidth}% + }{ + \cslet{adigraphEdge#2v#1Width}{#7}% + } \expandafter\AdigraphSimpleSum\expandafter{\AdigraphWeightA}{-#3}{\resultA} \expandafter\AdigraphSimpleSum\expandafter{\AdigraphWeightB}{#3}{\resultB} @@ -364,8 +423,8 @@ \cslet{adigraphEdge#2v#1Weight}{\resultB}% } -\NewDocumentCommand{\AdigraphElaboratePathColors}{G{} G{black}}{} -\NewDocumentCommand{\AdigraphElaboratePathWidth}{G{0.4} G{}}{} +\NewDocumentCommand{\AdigraphElaboratePathColors}{G{} G{\AdigraphDefaultColor}}{} +\NewDocumentCommand{\AdigraphElaboratePathWidth}{G{\AdigraphDefaultWidth} G{}}{} \NewDocumentCommand{\AdigraphBuildPath}{> { \SplitList{,} } m G{} > { \SplitArgument{ 1 } {,} } G{} G{}}{% % @@ -380,33 +439,49 @@ \FPset{\units}{#2} } - \RenewDocumentCommand{\AdigraphElaboratePathColors}{G{} G{black}}{% + \RenewDocumentCommand{\AdigraphElaboratePathColors}{G{} G{\AdigraphDefaultColor}}{% \ifblank{##1}{ \ifnum\value{AdigraphNumberOfPaths}=\value{AdigraphCurrentPathNumber} - \def\AdigraphForwardPathColor{red} - \def\AdigraphBackwardPathColor{blue} + \def\AdigraphForwardPathColor{\AdigraphRed} + \def\AdigraphBackwardPathColor{\AdigraphCyan} \else - \def\AdigraphForwardPathColor{black} - \def\AdigraphBackwardPathColor{black} + \def\AdigraphForwardPathColor{\AdigraphDefaultColor} + \def\AdigraphBackwardPathColor{\AdigraphDefaultColor} \fi }{ \def\AdigraphForwardPathColor{##1} - \def\AdigraphBackwardPathColor{##2} + \ifblank{##2}{ + \def\AdigraphBackwardPathColor{\AdigraphDefaultColor} + }{ + \def\AdigraphBackwardPathColor{##2} + } } } \AdigraphElaboratePathColors#3 - \RenewDocumentCommand{\AdigraphElaboratePathWidth}{G{0.4} G{##1}}{% - \def\AdigraphForwardPathWidth{##1} - \def\AdigraphBackwardPathWidth{##2} + \RenewDocumentCommand{\AdigraphElaboratePathWidth}{G{\AdigraphDefaultWidth} G{##1}}{% + \ifblank{##1}{ + \def\AdigraphForwardPathWidth{\AdigraphDefaultWidth} + }{ + \def\AdigraphForwardPathWidth{##1} + } + \ifblank{##2}{ + \def\AdigraphBackwardPathWidth{\AdigraphDefaultWidth} + }{ + \def\AdigraphBackwardPathWidth{##2} + } } \AdigraphElaboratePathWidth#4 \RenewDocumentCommand{\AdigraphElaboratePath}{m}{% \IfInteger{##1}{% - \def\AdigraphCurrentNode{\AdigraphRom{##1}}% + \IfEq{##1}{\AdigraphZero}{ + \def\AdigraphCurrentNode{\AdigraphTextualZero}% + }{ + \def\AdigraphCurrentNode{\AdigraphRom{##1}}% + } }{% \def\AdigraphCurrentNode{##1}% }% @@ -416,7 +491,11 @@ % This is the first iteration } \IfInteger{##1}{% - \def\AdigraphLastParsedNode{\AdigraphRom{##1}}% + \IfEq{##1}{\AdigraphZero}{ + \def\AdigraphLastParsedNode{\AdigraphTextualZero}% + }{ + \def\AdigraphLastParsedNode{\AdigraphRom{##1}}% + } }{% \def\AdigraphLastParsedNode{##1}% }% @@ -589,17 +668,25 @@ } } -\NewDocumentCommand{\AdigraphExecuteCutBuilder}{m m G{black}}{% +\NewDocumentCommand{\AdigraphExecuteCutBuilder}{m m G{\AdigraphDefaultColor}}{% \ifblank{#1}{% % Reached end of list }{% \IfInteger{#1}{% - \def\AdigraphFirstNode{\AdigraphRom{#1}}% + \IfEq{#1}{\AdigraphZero}{ + \def\AdigraphFirstNode{\AdigraphTextualZero}% + }{ + \def\AdigraphFirstNode{\AdigraphRom{#1}}% + } }{% \def\AdigraphFirstNode{#1}% }% \IfInteger{#2}{% - \def\AdigraphSecondNode{\AdigraphRom{#2}}% + \IfEq{#2}{\AdigraphZero}{ + \def\AdigraphSecondNode{\AdigraphTextualZero}% + }{ + \def\AdigraphSecondNode{\AdigraphRom{#2}}% + } }{% \def\AdigraphSecondNode{#2}% }% |