Skip to content

Instantly share code, notes, and snippets.

@tueda
Last active October 9, 2020 00:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tueda/5d8a7ff9181ef630160703606f449597 to your computer and use it in GitHub Desktop.
Save tueda/5d8a7ff9181ef630160703606f449597 to your computer and use it in GitHub Desktop.
A practical extension of axodraw2. #latex

axodraw2e

A practical extension of axodraw2.

Example

.dep/
*.ax1
*.ax2
*.aux
*.bbl
*.blg
*.dvi
*.fls
*.log
*.nav
*.out
*.pdf
*.ps
*.snm
*.tar.gz
*.toc
*.vrb
% latest-raw-url: https://gist.githubusercontent.com/tueda/5d8a7ff9181ef630160703606f449597/raw/axodraw2e.sty
%
% Copyright (c) 2017-2019 Takahiro Ueda
%
% This file may be distributed and/or modified under the conditions of
% the LaTeX Project Public License (LPPL), either version 1.3c of this
% license or (at your option) any later version. The latest version of
% this license is in:
%
% http://www.latex-project.org/lppl.txt
%
\ProvidesPackage{axodraw2e}[2019/09/06 v0.1.2]
\RequirePackage{axodraw2}[2016/06/02]
\RequirePackage[nomessages]{fp}
\SetWidth{.75}
\SetArrowScale{1.0}
% workaround for luatexja
% =======================
% luatexja overwrites \raise and it leads to a subtle difference for
% \raise 0pt\relax\hbox {}...
\long\gdef\putLen(#1,#2)#3{%
% Like LaTeX's \put, except that #1 and #2 are lengths instead of numbers
% giving lengths in units of \unitlength.
\AXO@killglue\raise#2%\relax
\hbox to 0pt{\kern#1\relax #3\hss}%
\ignorespaces
}
%{{{ globals
\newtoks\axoe@args
\def\axoe@addtoks#1#2{%
#1=\expandafter{\the#1#2}%
}
%}}}
%{{{ additional parameters
% axopicture
\def\AXO@CurrentBaseLine{}%
\define@key{axo}{baseline}{%
\def\AXO@CurrentBaseLine{#1}%
}
\def\AXO@CurrentMarginTop{0}%
\define@key{axo}{margin-top}{%
\def\AXO@CurrentMarginTop{#1}%
}
\def\AXO@CurrentMarginRight{0}%
\define@key{axo}{margin-right}{%
\def\AXO@CurrentMarginRight{#1}%
}
\def\AXO@CurrentMarginBottom{0}%
\define@key{axo}{margin-bottom}{%
\def\AXO@CurrentMarginBottom{#1}%
}
\def\AXO@CurrentMarginLeft{0}%
\define@key{axo}{margin-left}{%
\def\AXO@CurrentMarginLeft{#1}%
}
\define@key{axo}{margin}{%
\def\AXO@CurrentMarginTop{#1}%
\def\AXO@CurrentMarginRight{#1}%
\def\AXO@CurrentMarginBottom{#1}%
\def\AXO@CurrentMarginLeft{#1}%
}
% bend
\def\AXO@CurrentBendRight{0}%
\define@key{axo}{bend-right}[45]{%
\def\AXO@CurrentBendRight{#1}%
}
\define@key{axo}{bend-left}[45]{%
\FPeval\AXO@CurrentBendRight{(-1)*(#1)}%
}
% fillcolor
\def\AXO@CurrentFillColor{}%
\define@key{axo}{fillcolor}{%
\def\AXO@CurrentFillColor{#1}%
}
% wiggly
\newif\ifAXO@wiggly
\AXO@wigglyfalse
\define@key{axo}{wiggly}[true]{%
\AXO@boolkey{#1}{wiggly}%
}
\def\AXO@CurrentWigglyAmplitude{1.5}%
\define@key{axo}{wiggly-amplitude}{%
\def\AXO@CurrentWigglyAmplitude{#1}%
}
\def\AXO@CurrentWigglyLength{8}%
\define@key{axo}{wiggly-length}{%
\def\AXO@CurrentWigglyLength{#1}%
}
% curly
\newif\ifAXO@curly
\AXO@curlyfalse
\define@key{axo}{curly}[true]{%
\AXO@boolkey{#1}{curly}%
}
\def\AXO@CurrentCurlyAmplitude{2.5}%
\define@key{axo}{curly-amplitude}{%
\def\AXO@CurrentCurlyAmplitude{#1}%
}
\def\AXO@CurrentCurlyLength{6}%
\define@key{axo}{curly-length}{%
\def\AXO@CurrentCurlyLength{#1}%
}
% dot
\def\AXO@CurrentDotSize{1.5}%
\define@key{axo}{dot-size}{%
\def\AXO@CurrentDotSize{#1}%
}
% cross
\newif\ifAXO@cross
\AXO@crossfalse
\define@key{axo}{cross}[true]{%
\AXO@boolkey{#1}{cross}%
}
\def\AXO@CurrentCrossSize{3.5}%
\define@key{axo}{cross-size}{%
\def\AXO@CurrentCrossSize{#1}%
}
% otimes
\newif\ifAXO@otimes
\AXO@otimesfalse
\define@key{axo}{otimes}[true]{%
\AXO@boolkey{#1}{otimes}%
}
\def\AXO@CurrentOtimesSize{3.5}%
\define@key{axo}{otimes-size}{%
\def\AXO@CurrentOtimesSize{#1}%
}
% text
\def\AXO@CurrentTextAlign{}%
\define@key{axo}{l}[true]{%
\def\AXO@CurrentTextAlign{l}%
}
\define@key{axo}{lt}[true]{%
\def\AXO@CurrentTextAlign{lt}%
}
\define@key{axo}{tl}[true]{%
\def\AXO@CurrentTextAlign{tl}%
}
\define@key{axo}{lb}[true]{%
\def\AXO@CurrentTextAlign{lb}%
}
\define@key{axo}{bl}[true]{%
\def\AXO@CurrentTextAlign{bl}%
}
\define@key{axo}{r}[true]{%
\def\AXO@CurrentTextAlign{r}%
}
\define@key{axo}{rt}[true]{%
\def\AXO@CurrentTextAlign{rt}%
}
\define@key{axo}{tr}[true]{%
\def\AXO@CurrentTextAlign{tr}%
}
\define@key{axo}{rb}[true]{%
\def\AXO@CurrentTextAlign{rb}%
}
\define@key{axo}{br}[true]{%
\def\AXO@CurrentTextAlign{br}%
}
\define@key{axo}{t}[true]{%
\def\AXO@CurrentTextAlign{t}%
}
\define@key{axo}{b}[true]{%
\def\AXO@CurrentTextAlign{b}%
}
%}}}
%{{{ axopicture environment
% \begin{axopicture}[options](width,height)(offset-x,offset-y)
% \end{axopicture}
\newcounter{axoe@npics}
\setcounter{axoe@npics}{0}
\newsavebox{\axoe@picbox}
\newif\if@axoe@invalid
\@axoe@invalidfalse
\def\axoe@boundempty{1}
\def\axoe@boundtop{0}
\def\axoe@boundright{0}
\def\axoe@boundbottom{0}
\def\axoe@boundleft{0}
\let\old@axopicture\axopicture
\let\old@endaxopicture\endaxopicture
\def\axopicture{%
\stepcounter{axoe@npics}%
\gdef\axoe@boundempty{1}%
\gdef\axoe@boundtop{0}%
\gdef\axoe@boundright{0}%
\gdef\axoe@boundbottom{0}%
\gdef\axoe@boundleft{0}%
\let\scope\axoe@scope
\let\endscope\axoe@endscope
\@ifnextchar({%
\axoe@picture@
}{%
\edef\@tempa{\axoe@loadpicsize}%
\expandafter\axoe@picture@@\@tempa
}%
}
\def\axoe@picture@(#1,#2){%
\@ifnextchar({%
\axoe@picture@@(#1,#2)%
}{%
\axoe@picture@@(#1,#2)(0,0)%
}%
}
\def\axoe@picture@@(#1,#2)(#3,#4){%
\@ifnextchar[{%
\axoe@picture@@@(#1,#2)(#3,#4)%
}{%
\axoe@picture@@@(#1,#2)(#3,#4)[]%
}%
}
\def\axoe@picture@@@(#1,#2)(#3,#4)[#5]{%
% TODO: Options like [color=red] don't work.
\setkeys{axo}{#5}%
\begin{lrbox}{\axoe@picbox}%
\old@axopicture(#1,#2)(#3,#4)%
\scope
}
\def\endaxopicture{%
\endscope
\old@endaxopicture
\end{lrbox}%
\axoe@savepicinfo
\raisebox{\axoe@loadpicraise}{\usebox{\axoe@picbox}}%
\ignorespacesafterend
}
\def\axoe@loadpicsize{%
\@ifundefined{axoe@savedsize@\arabic{axoe@npics}}{%
(0,0)(0,0)%
}{%
\@nameuse{axoe@savedsize@\arabic{axoe@npics}}%
}%
}
\def\axoe@loadpicraise{%
\@ifundefined{axoe@savedraise@\arabic{axoe@npics}}{%
\z@
}{%
\@nameuse{axoe@savedraise@\arabic{axoe@npics}}%
}%
}
\def\axoe@savepicinfo{%
% XXX: assume the unit length = 1pt.
\FPeval\axoe@t{(\axoe@boundtop)+(\AXO@CurrentMarginTop)}%
\FPeval\axoe@r{(\axoe@boundright)+(\AXO@CurrentMarginRight)}%
\FPeval\axoe@b{(\axoe@boundbottom)-(\AXO@CurrentMarginBottom)}%
\FPeval\axoe@l{(\axoe@boundleft)-(\AXO@CurrentMarginLeft)}%
\FPeval\axoe@w{(\axoe@r)-(\axoe@l)}%
\FPeval\axoe@h{(\axoe@t)-(\axoe@b)}%
\edef\@tempa{(\axoe@w,\axoe@h)(\axoe@l,\axoe@b)}%
\edef\@tempb{\axoe@loadpicsize}%
\ifx\@tempa\@tempb
\else
\global\@axoe@invalidtrue
\fi
\immediate\write\@auxout{%
\string\global\string\@namedef{axoe@savedsize@\arabic{axoe@npics}}{\@tempa}%
}%
\ifx\AXO@CurrentBaseLine\empty
\else
\@tempdima=\AXO@CurrentBaseLine
\edef\@tempa{\strip@pt\@tempdima}%
\FPeval\axoe@b{(\axoe@b)-(\@tempa)}%
\edef\@tempa{\axoe@b\p@}%
\edef\@tempb{\axoe@loadpicraise}%
\ifx\@tempa\@tempb
\else
\global\@axoe@invalidtrue
\fi
\immediate\write\@auxout{%
\string\global\string\@namedef{axoe@savedraise@\arabic{axoe@npics}}%
{\@tempa}%
}%
\fi
}
\def\axoe@point(#1,#2){%
% TODO: linewidth, arrowwidth, etc.
\ifnum\axoe@boundempty=1%
\xdef\axoe@boundempty{0}%
\xdef\axoe@boundtop{#2}%
\xdef\axoe@boundright{#1}%
\xdef\axoe@boundbottom{#2}%
\xdef\axoe@boundleft{#1}%
\else
\axoe@point@(#1,#2)%
\fi
}
\def\axoe@point@(#1,#2){%
\FPifgt{#2}{\axoe@boundtop}%
\xdef\axoe@boundtop{#2}%
\fi
\FPifgt{#1}{\axoe@boundright}%
\xdef\axoe@boundright{#1}%
\fi
\FPiflt{#2}{\axoe@boundbottom}%
\xdef\axoe@boundbottom{#2}%
\fi
\FPiflt{#1}{\axoe@boundleft}%
\xdef\axoe@boundleft{#1}%
\fi
}
\AtEndDocument{%
\if@axoe@invalid
\if@filesw
\PackageWarningNoLine{axodraw2e}{Boundary box may have changed.
\MessageBreak Rerun to get it correct}%
\else
\PackageWarningNoLine{axodraw2e}{Boundary box may be wrong}%
\fi
\fi
}
%}}}
%{{{ scope environment
% \begin{scope}
% \end{scope}
\def\axoe@scope{%
\ifcase\axo@pdfoutput
\special{ps: gsave}%
\else
\special{pdf: q}%
\fi
\ignorespaces
}
\def\axoe@endscope{%
\ifcase\axo@pdfoutput
\special{ps: grestore}%
\else
\special{pdf: Q}%
\fi
\ignorespaces
}
%}}}
%{{{ \axo
% \axo[options] command...;
\newcommand{\axo}{}
\def\axo{%
\@ifnextchar[{%
\axo@%
}{%
\axo@[]%
}%
}
\def\axo@[#1]#2;{%
\begin{axopicture}[#1]%
#2%
\end{axopicture}%
\ignorespaces
}
%}}}
%{{{ \Line
% \Line[options](x1,y1)(x2,y2)...
\def\axoe@Line{%
\@ifnextchar[{%
\axoe@Line@%
}{%
\axoe@Line@[]%
}%
}
\def\axoe@Line@[#1](#2,#3)(#4,#5){%
\edef\axoe@opts{#1}%
\axoe@args={(#2,#3)(#4,#5)}%
\@ifnextchar({%
\axoe@Line@@
}{%
\axoe@Line@@@
}%
}
\def\axoe@Line@@(#1,#2){%
\axoe@addtoks\axoe@args{(#1,#2)}%
\@ifnextchar({%
\axoe@Line@@
}{%
\axoe@Line@@@
}%
}
\def\axoe@Line@@@{%
\bgroup
\edef\@tempa{{axo}{\axoe@opts}}%
\expandafter\setkeys\@tempa
\expandafter\axoe@Line@@@@\the\axoe@args
\egroup
}
\def\axoe@Line@@@@(#1,#2){%
\axoe@point(#1,#2)% TODO: width and amplitude
\edef\axoe@x{#1}%
\edef\axoe@y{#2}%
\@ifnextchar({%
\axoe@Line@@@@@
}{}%
}
\def\axoe@Line@@@@@(#1,#2){%
\ifdim\AXO@CurrentBendRight\p@=\z@
\axoe@Line@@@@@@(\axoe@x,\axoe@y)(#1,#2)%
\else
\axoe@Line@Bend(\axoe@x,\axoe@y)(#1,#2)(\AXO@CurrentBendRight)%
\fi
\edef\axoe@x{#1}%
\edef\axoe@y{#2}%
\@ifnextchar({%
\axoe@Line@@@@@
}{}%
}
\def\axoe@Line@@@@@@(#1,#2)(#3,#4){%
\axoe@point(#3,#4)% XXX: width and amplitude
% XXX: line-join is miserable.
\ifAXO@wiggly
\axoe@Line@length\@tempa(#1,#2)(#3,#4)%
\FPeval\axoe@n{\@tempa/\AXO@CurrentWigglyLength}%
\FPround\axoe@n{\axoe@n}{5}%
\FPclip\axoe@n{\axoe@n}%
\def\@tempa{\Photon}%
\edef\@tempb{[\axoe@opts](#1,#2)(#3,#4)%
{\AXO@CurrentWigglyAmplitude}{\axoe@n}}%
\else\ifAXO@curly
\axoe@Line@length\@tempa(#1,#2)(#3,#4)%
\FPeval\axoe@n{\@tempa/\AXO@CurrentCurlyLength}%
\FPround\axoe@n{\axoe@n}{5}%
\FPclip\axoe@n{\axoe@n}%
\def\@tempa{\Gluon}%
\edef\@tempb{[\axoe@opts](#1,#2)(#3,#4)%
{\AXO@CurrentCurlyAmplitude}{\axoe@n}}%
\else
\def\@tempa{\old@Line}%
\edef\@tempb{[\axoe@opts](#1,#2)(#3,#4)}%
\fi\fi
\expandafter\@tempa\@tempb%
}
\def\axoe@Line@Bend(#1,#2)(#3,#4)(#5){%
\FPeval\@temps{(-1)*cot((#5)*\FPdeg/2)}%
\FPeval\@tempss{(\@temps)*(\@temps)}%
\FPeval\@tempdx{(#3)-(#1)}%
\FPeval\@tempdy{(#4)-(#2)}%
\FPeval\@tempa{((#1)+(#3))/2 - (1-\@tempss) * \@tempdy / 4 / (\@temps)}%
\FPeval\@tempb{((#2)+(#4))/2 + (1-\@tempss) * \@tempdx / 4 / (\@temps)}%
\FPeval\@templ{(\@tempdx)*(\@tempdx)+(\@tempdy)*(\@tempdy)}%
\FProot\@templ\@templ{2}%
\FPeval\@tempr{(1+\@tempss) * \@templ / 4 / abs(\@temps)}%
\FPeval\@tempdx{(#1)-\@tempa}%
\FPeval\@tempdy{(#2)-\@tempb}%
\FPatantwo\@temptha\@tempdy\@tempdx
\FPdiv\@temptha\@temptha\FPdeg
\FPeval\@tempdx{(#3)-\@tempa}%
\FPeval\@tempdy{(#4)-\@tempb}%
\FPatantwo\@tempthb\@tempdy\@tempdx
\FPdiv\@tempthb\@tempthb\FPdeg
%
\FPifpos{#5}%
\AXO@clockfalse
% XXX: no way to set "anticlockwise"
\else
\AXO@clocktrue
\edef\axoe@opts{\axoe@opts,clock}%
\fi
%
\edef\@tempa{(\@tempa,\@tempb)(\@tempr,\@temptha,\@tempthb)}%
\expandafter\axoe@Arc@@@@@\@tempa
}
\let\old@Line=\Line
\let\Line=\axoe@Line
\def\axoe@Line@length#1(#2,#3)(#4,#5){%
\FPeval\@tempa{(#2-(#4))*(#2-(#4))+(#3-(#5))*(#3-(#5))}%
\FProot#1\@tempa{2}%
}
%}}}
%{{{ \Arc
% \Arc[options](center-x,center-y)(radius,theta1,theta2)...
\def\axoe@Arc{%
\@ifnextchar[{%
\axoe@Arc@%
}{%
\axoe@Arc@[]%
}%
}
\def\axoe@Arc@[#1](#2,#3)(#4,#5,#6){%
\edef\axoe@opts{#1}%
\edef\axoe@x{#2}%
\edef\axoe@y{#3}%
\axoe@args={(#4,#5,#6)}%
\@ifnextchar({%
\axoe@Arc@@
}{%
\axoe@Arc@@@
}%
}
\def\axoe@Arc@@(#1,#2,#3){%
\axoe@addtoks\axoe@args{(#1,#2,#3)}%
\@ifnextchar({%
\axoe@Arc@@
}{%
\axoe@Arc@@@
}%
}
\def\axoe@Arc@@@{%
\bgroup
\edef\@tempa{{axo}{\axoe@opts}}%
\expandafter\setkeys\@tempa
\expandafter\axoe@Arc@@@@\the\axoe@args
\egroup
}
\def\axoe@Arc@@@@(#1,#2,#3){%
\axoe@Arc@@@@@(\axoe@x,\axoe@y)(#1,#2,#3)%
\@ifnextchar({%
\axoe@Arc@@@@
}{}%
}
\def\axoe@Arc@@@@@(#1,#2)(#3,#4,#5){%
% This correction is needed for the linear interpolation along the arc.
\edef\@tempshift{}%
\FPsub\@tempa{#5}{#4}%
\ifAXO@clock
\FPneg\@tempa\@tempa
\fi
\FPifneg\@tempa
% XXX: 360 could be not enough.
\edef\@tempshift{360}%
\fi
\edef\@tempa{#4}%
\ifx\@tempshift\empty
\else
\ifAXO@clock
\FPadd\@tempa\@tempa\@tempshift
\else
\FPsub\@tempa\@tempa\@tempshift
\fi
\fi
%
\edef\@tempa{(#1,#2)(#3,\@tempa,#5)}%
\expandafter\axoe@Arc@@@@@@\@tempa
}
\def\axoe@Arc@@@@@@(#1,#2)(#3,#4,#5){%
% TODO: width and amplitude
\FPeval\@tempa{(#4) * \FPdeg}%
\FPsincos\@tempb\@tempa\@tempa
\FPeval\@tempa{(#1) + \@tempa * (#3)}%
\FPeval\@tempb{(#2) + \@tempb * (#3)}%
\axoe@point(\@tempa,\@tempb)%
%
\FPeval\@tempa{(3 * (#4) + (#5)) / 4 * \FPdeg}%
\FPsincos\@tempb\@tempa\@tempa
\FPeval\@tempa{(#1) + \@tempa * (#3)}%
\FPeval\@tempb{(#2) + \@tempb * (#3)}%
\axoe@point(\@tempa,\@tempb)%
%
\FPeval\@tempa{(#4 + (#5)) / 2 * \FPdeg}%
\FPsincos\@tempb\@tempa\@tempa
\FPeval\@tempa{(#1) + \@tempa * (#3)}%
\FPeval\@tempb{(#2) + \@tempb * (#3)}%
\axoe@point(\@tempa,\@tempb)%
%
\FPeval\@tempa{(#4 + 3 * (#5)) / 4 * \FPdeg}%
\FPsincos\@tempb\@tempa\@tempa
\FPeval\@tempa{(#1) + \@tempa * (#3)}%
\FPeval\@tempb{(#2) + \@tempb * (#3)}%
\axoe@point(\@tempa,\@tempb)%
%
\FPeval\@tempa{(#5) * \FPdeg}%
\FPsincos\@tempb\@tempa\@tempa
\FPeval\@tempa{(#1) + \@tempa * (#3)}%
\FPeval\@tempb{(#2) + \@tempb * (#3)}%
\axoe@point(\@tempa,\@tempb)%
%
\ifAXO@wiggly
\axoe@Arc@length\@tempa(#3,#4,#5)%
\FPeval\axoe@n{\@tempa / \AXO@CurrentWigglyLength}%
\FPround\axoe@n{\axoe@n}{5}%
\FPclip\axoe@n{\axoe@n}%
\def\@tempa{\PhotonArc}%
\edef\@tempb{[\axoe@opts](#1,#2)(#3,#4,#5)%
{\AXO@CurrentWigglyAmplitude}{\axoe@n}}%
\else\ifAXO@curly
\axoe@Arc@length\@tempa(#3,#4,#5)%
\FPeval\axoe@n{\@tempa / \AXO@CurrentCurlyLength}%
\FPround\axoe@n{\axoe@n}{5}%
\FPclip\axoe@n{\axoe@n}%
\def\@tempa{\GluonArc}%
\edef\@tempb{[\axoe@opts](#1,#2)(#3,#4,#5)%
{\AXO@CurrentCurlyAmplitude}{\axoe@n}}%
\else
\def\@tempa{\old@Arc}%
\edef\@tempb{[\axoe@opts](#1,#2)(#3,#4,#5)}%
\fi\fi
\expandafter\@tempa\@tempb%
}
\let\old@Arc=\Arc
\let\Arc=\axoe@Arc
\def\axoe@Arc@length#1(#2,#3,#4){%
\FPsub\@tempa{#4}{#3}%
\ifAXO@clock
\FPneg\@tempa\@tempa
\fi
\FPifneg\@tempa
% XXX: 360 could be not enough.
\FPadd\@tempa\@tempa{360}%
\fi
\FPeval#1{\@tempa * \FPdeg * abs(#2)}%
}
%}}}
%{{{ \Vertex
% \Vertex[options](x1,y1)...{size}
\def\axoe@Vertex{%
\@ifnextchar[{%
\axoe@Vertex@%
}{%
\axoe@Vertex@[]%
}%
}
\def\axoe@Vertex@[#1](#2,#3){%
\edef\axoe@opts{#1}%
\axoe@args={(#2,#3)}%
\@ifnextchar({%
\axoe@Vertex@@
}{%
\axoe@Vertex@@@
}%
}
\def\axoe@Vertex@@(#1,#2){%
\axoe@addtoks\axoe@args{(#1,#2)}%
\@ifnextchar({%
\axoe@Vertex@@
}{%
\axoe@Vertex@@@
}%
}
\def\axoe@Vertex@@@{%
% NOTE: the braces is mandatory for the size parameter.
\@ifnextchar\bgroup{%
\axoe@Vertex@@@@
}{%
\axoe@Vertex@@@@{}%
}%
}
\def\axoe@Vertex@@@@#1{%
\bgroup
\edef\axoe@size{#1}%
\edef\@tempa{{axo}{\axoe@opts}}%
\expandafter\setkeys\@tempa
\AXO@useopts
\expandafter\axoe@Vertex@@@@@\the\axoe@args
\egroup
\ignorespaces
}
\def\axoe@Vertex@@@@@(#1,#2){%
\axoe@point(#1,#2)% TODO: vertex size
\ifAXO@cross
\ifx\axoe@size\empty
\axoe@Vertex@cross(#1,#2){\AXO@CurrentCrossSize}%
\else
\axoe@Vertex@cross(#1,#2){\axoe@size}%
\fi
\else\ifAXO@otimes
\ifx\axoe@size\empty
\axoe@Vertex@otimes(#1,#2){\AXO@CurrentOtimesSize}%
\else
\axoe@Vertex@otimes(#1,#2){\axoe@size}%
\fi
\else
\ifx\axoe@size\empty
\old@Vertex(#1,#2){\AXO@CurrentDotSize}%
\else
\old@Vertex(#1,#2){\axoe@size}%
\fi
\fi\fi
\@ifnextchar({%
\axoe@Vertex@@@@@
}{}%
}
\let\old@Vertex=\Vertex
\let\Vertex=\axoe@Vertex
\def\axoe@Vertex@cross(#1,#2)#3{%
\put(#1,#2){%
{%
\FProot\@tempa{2}{2}%
\FPdiv\@tempa{#3}\@tempa
{%
\edef\@tempa{(-\@tempa,-\@tempa)(\@tempa,\@tempa)}%
\expandafter\old@Line\@tempa
}%
{%
\edef\@tempa{(\@tempa,-\@tempa)(-\@tempa,\@tempa)}%
\expandafter\old@Line\@tempa
}%
}%
}%
}
\def\axoe@Vertex@otimes(#1,#2)#3{%
\ifx\AXO@CurrentFillColor\empty\else
{%
\SetColor{\AXO@CurrentFillColor}%
\old@Vertex(#1,#2){#3}%
}%
\fi
\axoe@Vertex@cross(#1,#2){#3}%
\put(#1,#2){\ECirc(0,0){#3}}%
}
%}}}
%{{{ \Text
% \Text[options](x1,y1)...[options-compat]{text}
% TODO: the rotation parameter.
\def\axoe@Text{%
\@ifnextchar[{%
\axoe@Text@%
}{%
\axoe@Text@[]%
}%
}
\def\axoe@Text@[#1](#2,#3){%
\edef\axoe@opts{#1}%
\axoe@args={(#2,#3)}%
\@ifnextchar({%
\axoe@Text@@
}{%
\axoe@Text@@@
}%
}
\def\axoe@Text@@(#1,#2){%
\axoe@addtoks\axoe@args{(#1,#2)}%
\@ifnextchar({%
\axoe@Text@@
}{%
\axoe@Text@@@
}%
}
\def\axoe@Text@@@{%
\@ifnextchar[{%
\axoe@Text@@@@
}{%
\axoe@Text@@@@[]%
}%
}
\def\axoe@Text@@@@[#1]#2{%
\bgroup
\edef\axoe@opts{\axoe@opts,#1}%
\def\axoe@text{#2}%
\edef\@tempa{{axo}{\axoe@opts}}%
\expandafter\setkeys\@tempa
\AXO@useopts
\expandafter\axoe@Text@@@@@\the\axoe@args
\egroup
\ignorespaces
}
\def\axoe@Text@@@@@(#1,#2){%
\axoe@point(#1,#2)% TODO: text box size
\edef\@tempa{(#1,#2)[\AXO@CurrentTextAlign]}%
\expandafter\old@Text\@tempa{\axoe@text}%
\@ifnextchar({%
\axoe@Text@@@@@
}{}%
}
\let\old@Text=\Text
\let\Text=\axoe@Text
%}}}
%{{{ \SetClip
% \SetClip(x1,y1)(x2,y2),(x3,y3)...
\newcommand{\SetClip}{%
\axoe@SetClipPolygon
}
\def\axoe@SetClipPolygon(#1,#2){%
\ifcase\axo@pdfoutput
\axoe@args={ newpath #1 #2 moveto}%
\else
\axoe@args={ #1 #2 m}%
\fi
\@ifnextchar({%
\axoe@SetClipPolygon@
}{%
\axoe@SetClipPolygon@@
}%
}
\def\axoe@SetClipPolygon@(#1,#2){%
\ifcase\axo@pdfoutput
\axoe@addtoks\axoe@args{ #1 #2 lineto}%
\else
\axoe@addtoks\axoe@args{ #1 #2 l}%
\fi
\@ifnextchar({%
\axoe@SetClipPolygon@
}{%
\axoe@SetClipPolygon@@
}%
}
\def\axoe@SetClipPolygon@@{%
\edef\@tempa{\the\axoe@args}%
\ifcase\axo@pdfoutput
\edef\axoe@clip{\@tempa \space closepath clip}%
\else
\special{pdf: \@tempa \space h W n}%
\fi
\ignorespaces
}
\def\AXOspecial#1{%
\special{ps:: SDict begin savecolor end }%
\special{" \axoe@clip \space restorecolor #1 }%
}
\def\axoe@clip{}
%}}}
%{{{ \FPdeg
% \FPdeg := pi / 180
\newcommand{\FPdeg}{}
\FPdiv\FPdeg\FPpi{180}
%}}}
%{{{ \FPatantwo
% \FPatantwo{dest}{y}{x}
% -pi < atan2(y,x) <= pi
\newcommand{\FPatantwo}[3]{%
% NOTE: \FPifXXX doesn't work in nested constructs with "else".
\edef\atan@tempa{}%
\FPifneg{#2}%
\edef\atan@tempa{\atan@tempa a}%
\fi
\FPifzero{#2}%
\edef\atan@tempa{\atan@tempa b}%
\fi
\FPifneg{#3}%
\edef\atan@tempa{\atan@tempa c}%
\fi
\FPifzero{#3}%
\edef\atan@tempa{\atan@tempa d}%
\fi
\@nameuse{FPatantwo@\atan@tempa}#1{#2}{#3}%
}
\newcommand{\FPatantwo@}[3]{%
% x > 0
\FPdiv\atan@tempa{#2}{#3}%
\FParctan#1\atan@tempa
}
\let\FPatantwo@a\FPatantwo@
\let\FPatantwo@b\FPatantwo@
\newcommand{\FPatantwo@c}[3]{%
% y > 0
\FPdiv\atan@tempa{#3}{#2}%
\FParctan\atan@tempa\atan@tempa
\FPneg\atan@tempa\atan@tempa
\FPdiv\atan@tempb\FPpi{2}%
\FPadd#1\atan@tempa\atan@tempb
}
\let\FPatantwo@d\FPatantwo@c
\newcommand{\FPatantwo@ac}[3]{%
% y < 0
\FPdiv\atan@tempa{#3}{#2}%
\FParctan\atan@tempa\atan@tempa
\FPdiv\atan@tempb\FPpi{2}%
\FPadd\atan@tempa\atan@tempa\atan@tempb
\FPneg#1\atan@tempa
}
\let\FPatantwo@ad\FPatantwo@ac
\newcommand{\FPatantwo@bc}[3]{%
% x < 0, y = 0
\FPset#1\FPpi
}
\newcommand{\FPatantwo@bd}[3]{%
% x = y = 0
\FPset#1{0}% undefined
}
%}}}
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
\documentclass{ltxdoc}
\title{The \pkg{axodraw2e} package}
\author{}
\date{}
%{{{ Setup
\usepackage{axodraw2e}
\usepackage{fancyvrb}
\newcounter{ExampleCount}
\newenvironment{example}{%
\VerbatimEnvironment
\stepcounter{ExampleCount}%
\edef\examplefilename{\jobname.\arabic{ExampleCount}.vrb}
\begin{VerbatimOut}[gobble=2]{\examplefilename}%
}{%
\end{VerbatimOut}%
\smallskip
\noindent
\begin{list}{}{}\item
\begin{minipage}[t]{0.95\linewidth}%
\VerbatimInput{\examplefilename}%
\end{minipage} \\[20pt]
\begin{minipage}[t]{0.95\linewidth}%
\input{\examplefilename}%
\end{minipage}%
\end{list}%
\smallskip
\noindent
}
% decl from ltxguide[2001/05/28]
\newenvironment{decl}[1][]%
{\par\small\addvspace{4.5ex plus 1ex}%
\vskip -\parskip
\ifx\relax#1\relax
\def\@decl@date{}%
\else
\def\@decl@date{\NEWfeature{#1}}%
\fi
\noindent\hspace{-\leftmargini}%
\begin{tabular}{|l|}\hline\ignorespaces}%
{\\\hline\end{tabular}\nobreak\@decl@date\par\nobreak
\vspace{2.3ex}\vskip -\parskip}
\providecommand\env[1]{\texttt{#1}}
\providecommand\pkg[1]{\textsf{#1}}
\makeatletter
\newcommand{\nameuse}[1]{%
\edef\@tempa{\@nameuse{#1}}%
\ifx\@tempa\empty
\meta{empty}%
\else
\@tempa
\fi
}
\makeatother
%}}} Setup
\begin{document}
\maketitle
\section{axopicture}
\begin{decl}
|\begin{axopicture}|\oarg{options} \\
\meta{commands} \\
|\end{axopicture}| \\
\\
|\begin{axopicture}|\oarg{options}(\meta{width},\meta{height}) \\
\meta{commands} \\
|\end{axopicture}| \\
\\
|\begin{axopicture}|\oarg{options}(\meta{width},\meta{height})%
(\meta{offset-x},\meta{offset-y}) \\
\meta{commands} \\
|\end{axopicture}| \\
\\
|\axo|\oarg{option} \meta{commands} ;
\end{decl}
\begin{tabular}{llc}
\hline
option & type & default value \\
\hline
|baseline| & length & \nameuse{AXO@CurrentBaseLine} \\
|margin-top| & number & \nameuse{AXO@CurrentMarginTop} \\
|margin-right| & number & \nameuse{AXO@CurrentMarginRight} \\
|margin-bottom| & number & \nameuse{AXO@CurrentMarginBottom} \\
|margin-left| & number & \nameuse{AXO@CurrentMarginLeft} \\
\hline
\end{tabular}
\begin{example}
Here are examples:
\axo \Line[arrow](0,-10)(20,10);
\axo[baseline=0pt] \Line[arrow](0,-10)(20,10);
\axo[baseline=10pt] \Line[arrow](0,-10)(20,10);
\end{example}
\section{Line}
\begin{decl}
|\Line|\oarg{options}(\meta{x1},\meta{y1})(\meta{x2},\meta{y2})\ldots
\end{decl}
\begin{tabular}{llc}
\hline
option & type & default value \\
\hline
|bend-right| & number & 0 (=45) \\
|bend-left| & number & 0 (=45) \\
|wiggly| & & \\
|wiggly-amplitude| & number & \nameuse{AXO@CurrentWigglyAmplitude} \\
|wiggly-length| & number & \nameuse{AXO@CurrentWigglyLength} \\
|curly| & & \\
|curly-amplitude| & number & \nameuse{AXO@CurrentCurlyAmplitude} \\
|curly-length| & number & \nameuse{AXO@CurrentCurlyLength} \\
\hline
\end{tabular}
\begin{example}
\begin{axopicture}
\Line(0,0)(100,0)
\Line[arrow](0,-20)(100,-20)
\Line[dash](0,-40)(100,-40)
\Line[wiggly](0,-60)(100,-60)
\Line[curly](0,-80)(100,-80)
\end{axopicture}
\end{example}
\begin{example}
\begin{axopicture}
\Line[arrow](0,0)(100,50)
\Line[arrow,bend-right,color=red](0,0)(100,50)
\Line[arrow,bend-left=45,color=green](0,0)(100,50)
\Line[arrow,bend-left=90,color=blue](0,0)(100,50)
\end{axopicture}
\end{example}
\section{Arc}
\begin{decl}
|\Arc|\oarg{options}(\meta{center-x},\meta{center-y})%
(\meta{radius},\meta{theta1},\meta{theta2})\ldots
\end{decl}
\begin{example}
\begin{axopicture}
\Arc(0,0)(50,0,90)
\Arc[arrow](40,0)(50,0,90)
\Arc[dash](80,0)(50,0,90)
\Arc[wiggly](120,0)(50,0,90)
\Arc[curly](160,0)(50,0,90)
\end{axopicture}
\end{example}
\section{Vertex}
\begin{decl}
|\Vertex|\oarg{options}(\meta{x1},\meta{y1})\dots \\
|\Vertex|\oarg{options}(\meta{x1},\meta{y1})\dots \marg{size}
\end{decl}
\begin{tabular}{llc}
\hline
option & type & default value \\
\hline
|color| & color & \meta{empty} \\
|dot-size| & number & \nameuse{AXO@CurrentDotSize} \\
|cross| & & \\
|cross-size| & number & \nameuse{AXO@CurrentCrossSize} \\
|otimes| & & \\
|otimes-size| & number & \nameuse{AXO@CurrentOtimesSize} \\
|fillcolor| & color & \meta{empty} \\
\hline
\end{tabular}
\begin{example}
\begin{axopicture}
\Vertex(0,0)
\Vertex(50,0){5}
\Vertex[cross](100,0)
\Vertex[otimes](150,0)
\end{axopicture}
\end{example}
\section{Text}
\begin{decl}
|\Text|\oarg{options}(\meta{x},\meta{y})\marg{text}
\end{decl}
\begin{tabular}{llc}
\hline
option & type & default value \\
\hline
|color| & color & \meta{empty} \\
\hline
\end{tabular}
\begin{example}
\begin{axopicture}
\Text[rt](-30,-30){rt}
\Text[t](0,-30){t}
\Text[lt](30,-30){lt}
\Text[r](-30,0){r}
\Text(0,0){c}
\Text[l](30,0){l}
\Text[rb](-30,30){rb}
\Text[b](0,30){b}
\Text[lb](30,30){lb}
\Vertex(-30, 30)(0, 30)(30, 30)
(-30, 0)(0, 0)(30, 0)
(-30,-30)(0,-30)(30,-30)
\end{axopicture}
\end{example}
\section{SetClip}
\begin{decl}
|\SetClip|(\meta{x1},\meta{y1})(\meta{x2},\meta{y2})%
(\meta{x3},\meta{y3})\ldots
\end{decl}
\begin{example}
\begin{axopicture}
\Line[curly](30,50)(0,-30)
\begin{scope}
\SetClip(0,0)(50,0)(50,20)(0,20)
\Line[curly](40,50)(10,-30)
\end{scope}
\Line(0,0)(50,0)(50,20)(0,20)(0,0)
\Line[curly](50,50)(20,-30)
\end{axopicture}
\end{example}
\end{document}
# @file Makefile
#
# Makefile for typesetting LaTeX documents. Requires GNU Make 3.81 on Linux.
#
# Usage:
# make # *.tex --(pdflatex)--> *.pdf (by default)
# make foo.dvi # foo.tex --(latex)-----> foo.dvi
# make foo.pdf # foo.tex --(pdflatex)--> foo.pdf
# make foo.ps # foo.tex --(latex)-----> foo.dvi
# --(dvips)-----> foo.ps
# make foo.eps # foo.tex --(latex)-----> foo.dvi
# --(dvips,gs)--> foo.eps
# make foo.tar.gz # foo.tex --(pdflatex)--> foo.fls
# --(tar)-------> foo.tar.gz (for arXiv)
# make dvi # Create .dvi files.
# make ps # Create .ps files.
# make eps # Create .eps files.
# make pdf # Create .pdf files.
# make dist # Create .tar.gz files.
# make clean # Remove all generated files.
# make mostlyclean # Remove all intermediate files.
# make watch # Continuously update .pdf (by default) files.
#
# The following programs are called when needed in LaTeX typesetting:
# bibtex, sortref, makeindex, makeglossaries and axohelp
#
# The default typeset type: dvi (latex) or pdf (pdflatex).
default_typeset = pdf
# The default target is making this type of files from all *.tex.
default_target = $(default_typeset)
# Specify if use colors for the output: always, none or auto (default).
make_colors = $(MAKE_COLORS)
# Files not to be included in a distribution.
NODISTFILES =
# Extra files to be included in a distribution.
EXTRADISTFILES =
# Files to be copied in "anc" directory in a distribution.
ANCILLARYFILES =
# Additional files to mostly-clean.
MOSTLYCLEANFILES =
# Additional files to clean.
CLEANFILES =
# Prerequisite make targets in subdirectories.
PREREQUISITE_SUBDIRS =
# Test scripts.
TESTS =
# The following variables will be guessed if empty.
TARGET =
SUBDIRS =
LATEX =
PDFLATEX =
DVIPS =
DVIPDF =
GS =
BIBTEX =
SORTREF =
MAKEINDEX =
MAKEGLOSSARIES =
KPSEWHICH =
AXOHELP =
PDFCROP =
EBB =
EXTRACTBB =
SOFFICE =
# Command options.
LATEX_OPT = -interaction=nonstopmode -halt-on-error
PDFLATEX_OPT = -interaction=nonstopmode -halt-on-error
DVIPS_OPT = -Ppdf -z
DVIPDF_OPT =
GS_OPT =
BIBTEX_OPT =
SORTREF_OPT =
MAKEINDEX_OPT =
MAKEGLOSSARIES_OPT =
KPSEWHICH_OPT =
AXOHELP_OPT =
PDFCROP_OPT =
EBB_OPT =
EXTRACTBB_OPT =
SOFFICE_OPT =
# The following lines enable use of platex.
#LATEX = platex
#PDFLATEX = ptex2pdf
#BIBTEX = pbibtex
#MAKEINDEX = mendex
#PDFLATEX_OPT = -l -ot '-interaction=nonstopmode -halt-on-error -recorder'
# The following lines enable use of uplatex.
#LATEX = uplatex
#PDFLATEX = ptex2pdf
#BIBTEX = upbibtex
#MAKEINDEX = upmendex
#PDFLATEX_OPT = -u -l -ot '-interaction=nonstopmode -halt-on-error -recorder'
# The following lines enable use of lualatex.
#LATEX = lualatex
#PDFLATEX = lualatex
#BIBTEX = upbibtex
#MAKEINDEX = upmendex
# ANSI escape code for colorization.
CL_NORMAL = [0m
CL_NOTICE = [32m
CL_WARN = [35m
CL_ERROR = [31m
.SUFFIXES:
.SUFFIXES: .log .pdf .odt .eps .ps .jpg .dvi .tex .cls .sty .fmt .ltx .dtx
DEPDIR = .dep
# $(call cache,VARIABLE) expands $(VARIABLE) with caching.
# See https://www.cmcrossroads.com/article/makefile-optimization-eval-and-macro-caching
cache = $(if $(is_cached-$1),,$(eval is_cached-$1 := 1)$(eval cached_val-$1 := $($1)))$(cached_val-$1)
# $(call type,EXEC-FILE) gives the path to the executable if found,
# otherwise empty.
type = $(if $(strip $1),$(strip \
$(eval type_retval := $(shell which '$(strip $1)' 2>/dev/null)) \
$(if $(filter-out $(firstword $(type_retval)),$(type_retval)), \
$(eval type_retval := '$(type_retval)') \
) \
$(type_retval) \
))
# $(call pathsearch,PROG-NAME,NOERROR-IF-NOT-FOUND,NAME1,...) tries to find
# the given executable.
pathsearch = $(strip \
$(eval retval := ) \
$(call pathsearch_impl,$3,$4,$5,$6,$7,$8,$9) \
$(if $2$(retval),,$(eval retval := \
$(call error_message,$1 not found); \
exit 1; :)) \
$(retval) \
)
pathsearch_impl = \
$(if $(retval),,$(eval retval := $(call type,$1))) \
$(if $(retval),,$(if $(strip $2 $3 $4 $5 $6 $7 $8 $9),$(call pathsearch_impl,$2,$3,$4,$5,$6,$7,$8,$9)))
# $(target)
target = $(call cache,target_impl)
target_impl = $(strip \
$(target_impl_from_ltx) \
$(target_impl_from_tex) \
)
target_impl_from_ltx = $(srcltxfiles:.ltx=.fmt)
target_impl_from_tex = $(strip \
$(eval retval := ) \
$(if $(retval),,$(eval retval := $(TARGET))) \
$(if $(retval),,$(eval retval := $(srctexfiles:.tex=.$(default_target)))) \
$(retval) \
)
# $(target_basename)
target_basename = $(call cache,target_basename_impl)
target_basename_impl = $(basename $(target))
# $(srctexfiles)
srctexfiles = $(call cache,srctexfiles_impl)
srctexfiles_impl = $(strip $(sort \
$(shell grep documentclass -l *.tex 2>/dev/null) \
$(shell awk 'FNR==1{if ($$0~"%&") print FILENAME;}' *.tex 2>/dev/null) \
))
# $(srcltxfiles)
srcltxfiles = $(call cache,srcltxfiles_impl)
srcltxfiles_impl = $(wildcard *.ltx)
# $(srcdtxfiles)
srcdtxfiles = $(call cache,srcdtxfiles_impl)
srcdtxfiles_impl = $(wildcard *.dtx)
# $(subdirs)
subdirs = $(call cache,subdirs_impl)
subdirs_impl = $(strip \
$(eval retval := ) \
$(if $(retval),,$(eval retval := $(SUBDIRS))) \
$(if $(retval),,$(eval retval := $(dir $(wildcard */Makefile)))) \
$(retval) \
)
# $(latex)
latex = $(call cache,latex_impl)
latex_impl = $(strip \
$(latex_noopt) $(LATEX_OPT) \
$(if $(findstring -recorder,$(LATEX_OPT)),,-recorder) \
)
latex_noopt = $(call cache,latex_noopt_impl)
latex_noopt_impl = $(call pathsearch,latex,,$(LATEX),latex)
# $(pdflatex)
pdflatex = $(call cache,pdflatex_impl)
pdflatex_impl = $(strip \
$(pdflatex_noopt) $(PDFLATEX_OPT) \
$(if $(findstring -recorder,$(PDFLATEX_OPT)),,-recorder) \
)
pdflatex_noopt = $(call cache,pdflatex_noopt_impl)
pdflatex_noopt_impl = $(call pathsearch,pdflatex,,$(PDFLATEX),pdflatex)
# $(dvips)
dvips = $(call cache,dvips_impl) $(DVIPS_OPT)
dvips_impl = $(call pathsearch,dvips,,$(DVIPS),dvips,dvipsk)
# $(dvipdf)
dvipdf = $(call cache,dvipdf_impl) $(DVIPDF_OPT)
dvipdf_impl = $(call pathsearch,dvipdf,,$(DVIPDF),dvipdfm,dvipdfmx,dvipdf)
# $(gs)
gs = $(call cache,gs_impl) $(GS_OPT)
gs_impl = $(call pathsearch,gs,,$(GS),gs,gswin32,gswin64,gsos2)
# $(bibtex)
bibtex = $(call cache,bibtex_impl) $(BIBTEX_OPT)
bibtex_impl = $(call pathsearch,bibtex,,$(BIBTEX),bibtex)
# $(sortref)
sortref = $(call cache,sortref_impl) $(SORTREF_OPT)
sortref_impl = $(call pathsearch,sortref,,$(SORTREF),sortref)
# $(makeindex)
makeindex = $(call cache,makeindex_impl) $(MAKEINDEX_OPT)
makeindex_impl = $(call pathsearch,makeindex,,$(MAKEINDEX),makeindex)
# $(makeglossaries)
makeglossaries = $(call cache,makeglossaries_impl) $(MAKEGLOSSARIES_OPT)
makeglossaries_impl = $(call pathsearch,makeglossaries,,$(MAKEGLOSSARIES),makeglossaries)
# $(kpsewhich)
kpsewhich = $(call cache,kpsewhich_impl) $(KPSEWHICH_OPT)
kpsewhich_impl = $(call pathsearch,kpsewhich,,$(KPSEWHICH),kpsewhich)
# $(axohelp)
axohelp = $(call cache,axohelp_impl) $(AXOHELP_OPT)
axohelp_impl = $(call pathsearch,axohelp,,$(AXOHELP),axohelp)
# $(pdfcrop)
pdfcrop = $(call cache,pdfcrop_impl) $(PDFCROP_OPT)
pdfcrop_impl = $(call pathsearch,pdfcrop,,$(PDFCROP),pdfcrop)
# $(ebb)
ebb = $(call cache,ebb_impl) $(EBB_OPT)
ebb_impl = $(call pathsearch,ebb,,$(EBB),ebb)
# $(extractbb)
extractbb = $(call cache,extractbb_impl) $(EXTRACTBB_OPT)
extractbb_impl = $(call pathsearch,extractbb,,$(EXTRACTBB),extractbb)
# $(soffice)
soffice = $(call cache,soffice_impl) $(SOFFICE_OPT)
soffice_impl = $(call pathsearch,soffice,, \
$(SOFFICE), \
soffice, \
/cygdrive/c/Program Files/LibreOffice 5/program/soffice, \
/cygdrive/c/Program Files (x86)/LibreOffice 5/program/soffice, \
/cygdrive/c/Program Files/LibreOffice 4/program/soffice, \
/cygdrive/c/Program Files (x86)/LibreOffice 4/program/soffice \
)
# $(mostlycleanfiles)
mostlycleanfiles = $(call cache,mostlycleanfiles_impl)
mostlycleanfiles_impl = $(wildcard $(strip \
$(srctexfiles:.tex=Notes.bib) \
$(srctexfiles:.tex=.aux) \
$(srctexfiles:.tex=.ax1) \
$(srctexfiles:.tex=.ax2) \
$(srctexfiles:.tex=.blg) \
$(srctexfiles:.tex=.end) \
$(srctexfiles:.tex=.fls) \
$(srctexfiles:.tex=.glg) \
$(srctexfiles:.tex=.glo) \
$(srctexfiles:.tex=.idx) \
$(srctexfiles:.tex=.ilg) \
$(srctexfiles:.tex=.ist) \
$(srctexfiles:.tex=.log) \
$(srctexfiles:.tex=.lof) \
$(srctexfiles:.tex=.lot) \
$(srctexfiles:.tex=.nav) \
$(srctexfiles:.tex=.out) \
$(srctexfiles:.tex=.snm) \
$(srctexfiles:.tex=.spl) \
$(srctexfiles:.tex=.toc) \
$(srctexfiles:.tex=.*.vrb) \
$(srctexfiles:.tex=.xdy) \
$(srcltxfiles:.ltx=.log) \
$(MOSTLYCLEANFILES) \
))
# $(cleanfiles)
cleanfiles = $(call cache,cleanfiles_impl)
cleanfiles_impl = $(wildcard $(strip \
$(srctexfiles:.tex=.tar.gz) \
$(srctexfiles:.tex=.pdf) \
$(srctexfiles:.tex=.ps) \
$(srctexfiles:.tex=.eps) \
$(srctexfiles:.tex=.dvi) \
$(srctexfiles:.tex=.bbl) \
$(srctexfiles:.tex=_ref.tex) \
$(srctexfiles:.tex=.ind) \
$(srctexfiles:.tex=.gls) \
$(srcltxfiles:.ltx=.fmt) \
$(srcdtxfiles:.dtx=.cls) \
$(srcdtxfiles:.dtx=.sty) \
$(CLEANFILES) \
$(mostlycleanfiles) \
*.bmc \
*.pbm \
*-eps-converted-to.pdf \
))
# $(call colorize,COMMAND-WITH-COLOR,COMMAND-WITHOUT-COLOR)
colorize = \
if [ "$(make_colors)" = "always" ]; then \
$1; \
elif [ "$(make_colors)" = "none" ]; then \
$2; \
else \
if [ -t 1 ]; then \
$1; \
else \
$2; \
fi; \
fi
# $(call error_message,MESSAGE)
error_message = \
$(call colorize, \
printf "\033$(CL_ERROR)Error: $1\033$(CL_NORMAL)\n" >&2 \
, \
echo "Error: $1" >&2 \
)
# $(call exec,COMMAND)
# $(call exec,COMMAND,false)
exec = \
$(if $(and $(findstring not found,$1),$(findstring exit 1,$1)), \
$1 \
, \
failed=false; \
$(call colorize, \
printf "\033$(CL_NOTICE)$1\033$(CL_NORMAL)\n"; \
exec 3>&1; \
pipe_status=`{ { $1 3>&- 4>&-; echo $$? 1>&4; } | \
$(colorize_output) >&3; } 4>&1`; \
exec 3>&-; \
[ "$$pipe_status" = 0 ] || failed=: \
, \
echo "$1"; \
$1 || failed=: \
) \
$(if $2,,; $(check_failed)) \
)
# $(check_failed)
check_failed = $$failed && { [ -n "$dont_delete_on_failure" ] || rm -f $@; exit 1; }; :
# $(colorize_output)
colorize_output = \
sed 's/^\(!.*\)/\$\$\x1b$(CL_ERROR)\1\$\$\x1b$(CL_NORMAL)/; \
s/^\(LaTeX[^W]*Warning.*\|Package[^W]*Warning.*\|Class[^W]*Warning.*\|No pages of output.*\|Underfull.*\|Overfull.*\|Warning--.*\)/\$\$\x1b$(CL_WARN)\1\$\$\x1b$(CL_NORMAL)/'
# $(call cmpver,VER1,OP,VER2)
cmpver = { \
cmpver_ver1_="$1"; \
cmpver_ver2_="$3"; \
$(call cmpver_fmt_,cmpver_ver1_); \
$(call cmpver_fmt_,cmpver_ver2_); \
$(if $(filter -eq,$2), \
[ $$cmpver_ver1_ = $$cmpver_ver2_ ]; \
, \
$(if $(filter -ne,$2), \
[ $$cmpver_ver1_ != $$cmpver_ver2_ ]; \
, \
cmpver_small_=`{ echo $$cmpver_ver1_; echo $$cmpver_ver2_; } | sort | head -1`; \
$(if $(filter -le,$2),[ $$cmpver_small_ = $$cmpver_ver1_ ];) \
$(if $(filter -lt,$2),[ $$cmpver_small_ = $$cmpver_ver1_ ] && [ $$cmpver_ver1_ != $$cmpver_ver2_ ];) \
$(if $(filter -ge,$2),[ $$cmpver_small_ = $$cmpver_ver2_ ];) \
$(if $(filter -gt,$2),[ $$cmpver_small_ = $$cmpver_ver2_ ] && [ $$cmpver_ver1_ != $$cmpver_ver2_ ];) \
) \
) \
}
# $(call cmpver_fmt_,VAR)
cmpver_fmt_ = \
$1=`expr "$$$1" : '[^0-9]*\([0-9][0-9]*\(\.[0-9][0-9]*\)*\)' | sed 's/\./ /g'`; \
$1=`printf '%05d' $$$1`
##
all: $(target)
dvi: $(target_basename:=.dvi)
ps: $(target_basename:=.ps)
eps: $(target_basename:=.eps)
pdf: $(target_basename:=.pdf)
dist: $(target_basename:=.tar.gz)
ifneq ($(subdirs),)
$(target_basename:=.dvi) \
$(target_basename:=.ps) \
$(target_basename:=.eps) \
$(target_basename:=.pdf): | prerequisite
prerequisite:
@for dir in $(subdirs); do \
$(MAKE) -C $$dir $(PREREQUISITE_SUBDIRS); \
done; :
endif
mostlyclean:
@for dir in $(subdirs); do \
$(MAKE) -C $$dir mostlyclean; \
done; :
@$(call exec,rm -f $(mostlycleanfiles))
clean:
@for dir in $(subdirs); do \
$(MAKE) -C $$dir clean; \
done; :
@$(call exec,rm -f $(cleanfiles))
@$(call exec,rm -rf $(DEPDIR))
check:
@for dir in $(subdirs); do \
$(MAKE) -C $$dir check; \
done
@for test in $(TESTS); do \
if [ -f "$$test" ]; then \
$(call exec,./$$test); \
else \
$(call exec,$$test); \
fi; \
done
# The "watch" mode. Try .log instead of .pdf/.dvi files, otherwise make would
# continuously try to typeset for sources previously failed.
watch:
@echo "Watching for $(srctexfiles:.tex=.$(default_target)). Press Ctrl+C to quit"
@while :; do \
$(MAKE) --silent $(srctexfiles:.tex=.log); \
sleep 1; \
done
.PHONY : all dvi ps eps pdf dist prerequisite mostlyclean clean check watch
# $(call typeset,LATEX-COMMAND)
# $(call typeset,LATEX-COMMAND,false)
typeset = \
rmfile=$@; \
$(if $2,rmfile=;dont_delete_on_failure=1;) \
oldfile=$*.tmp$$$$.$$RANDOM$$RANDOM; \
trap 'rm -f $$rmfile $$oldfile*' 0 1 2 3 15; \
failed=false; \
if [ -f '$@' ]; then \
need_latex=$(if $(filter-out %.ref %.bib %.bst %.idx %.glo,$?),:,false); \
need_bibtex=$(if $(filter %.bib %.bst,$?),:,false); \
need_sortref=$(if $(filter %.ref,$?),:,false); \
need_makeindex=$(if $(filter %.idx,$?),:,false); \
need_makeglossaries=$(if $(filter %.glo,$?),:,false); \
need_axohelp=$(if $(filter %.ax2,$?),:,false); \
if $$need_sortref || $$need_bibtex; then \
[ ! -f '$*.aux' ] && need_latex=:; \
fi; \
else \
need_latex=:; \
need_bibtex=false; \
need_sortref=false; \
need_makeindex=false; \
need_makeglossaries=false; \
need_axohelp=false; \
fi; \
$(call do_latex,$1,false); \
if $$failed && $(check_noreffile); then \
need_sortref=:; \
failed=false; \
else \
$(check_failed); \
fi; \
for i in 1 2 3 4 5; do \
$(do_bibtex); \
$(do_sortref); \
$(do_makeindex); \
$(do_makeglossaries); \
$(do_axohelp); \
$(call do_latex,$1); \
done; \
touch $@; \
rmfile=; \
$(call flsdep,$@,$*.fls); \
$(call blgdep,$@,$*.blg); \
$(check_reffile) && $(call refdep,$@,$(<:.tex=.ref)); \
:
# $(call do-backup,FILE,INDEX)
do_backup = \
if [ -f '$1' ]; then \
cp '$1' "$$oldfile"$2; \
else \
rm -f "$$oldfile"$2; \
touch "$$oldfile"$2; \
fi
# $(call check_modified,FILE,INDEX)
check_modified = \
if diff -q "$$oldfile"$2 '$1' >/dev/null 2>&1; then false; else :; fi
# $(call do-latex,LATEX-COMMAND)
# $(call do-latex,LATEX-COMMAND,false)
do_latex = \
if $$need_latex; then \
need_latex=false; \
$(call do_backup,$*.aux); \
$(call do_backup,$*.idx,2); \
$(call do_backup,$*.glo,3); \
$(call do_backup,$*.ax1,4); \
$(call exec,$1 $<,$2); \
if $(call check_modified,$*.aux); then \
$(check_bblfile) && need_bibtex=:; \
$(check_reffile) && need_sortref=:; \
$(check_glsfile) && need_makeglossaries=:; \
fi; \
if $(call check_modified,$*.idx,2); then \
$(check_indfile) && need_makeindex=:; \
fi; \
if $(call check_modified,$*.glo,3); then \
$(check_glsfile) && need_makeglossaries=:; \
fi; \
if $(call check_modified,$*.ax1,4); then \
$(check_ax2file) && need_axohelp=:; \
fi; \
$(check_rerun) && need_latex=:; \
fi
# $(do_bibtex)
do_bibtex = \
if $$need_bibtex; then \
need_bibtex=false; \
$(call do_backup,$*.bbl); \
$(call exec,$(bibtex) $(<:.tex=)); \
$(call check_modified,$*.bbl) && need_latex=:; \
fi
# $(do_sortref)
do_sortref = \
if $$need_sortref; then \
need_sortref=false; \
$(call do_backup,$*_ref.tex); \
$(call exec,$(sortref) $< $(<:.tex=.ref)); \
$(call check_modified,$*_ref.tex) && need_latex=:; \
fi
# $(do_makeindex)
do_makeindex = \
if $$need_makeindex; then \
need_makeindex=false; \
$(call do_backup,$*.ind); \
$(call exec,$(makeindex) $(<:.tex=)); \
$(call check_modified,$*.ind) && need_latex=:; \
fi
# $(do_makeglossaries)
do_makeglossaries = \
if $$need_makeglossaries; then \
need_makeglossaries=false; \
$(call do_backup,$*.gls); \
$(call exec,$(makeglossaries) $(<:.tex=)); \
$(call check_modified,$*.gls) && need_latex=:; \
fi
# $(do_axohelp)
do_axohelp = \
if $$need_axohelp; then \
need_axohelp=false; \
$(call do_backup,$*.ax2); \
$(call exec,$(axohelp) $(<:.tex=)); \
$(call check_modified,$*.ax2) && need_latex=:; \
fi
# $(call do_kpsewhich,FULLPATH-DEST-VAR,FILE)
do_kpsewhich = \
fullpath_kpsewhich_impl=`$(kpsewhich) "$2"`; \
if [ -z "$$fullpath_kpsewhich_impl" ]; then \
$(call error_message,$2 not found); \
exit 1; \
fi; \
$1=$$fullpath_kpsewhich_impl
# $(call flsdep,TARGET,FLS-FILE)
flsdep = \
if [ -f '$2' ]; then \
mkdir -p $(DEPDIR); \
{ \
for f in `grep INPUT '$2' | sed 's/INPUT *\(\.\/\)\?//' | sort | uniq`; do \
case $$f in \
*:*|/*) ;; \
*) [ -f "$$f" ] && echo "$1 : \$$(wildcard $$f)";; \
esac; \
done; \
} >$(DEPDIR)/$1.fls.d; \
fi
# $(call blgdep,TARGET,BLG-FILE)
blgdep = \
if [ -f '$2' ]; then \
mkdir -p $(DEPDIR); \
{ \
for f in `{ grep 'Database file [^:]*:' '$2'; grep 'The style file:' '$2'; } | sed 's/[^:]*://'`; do \
[ -f "$$f" ] && echo "$1 : \$$(wildcard $$f)"; \
done; \
} >$(DEPDIR)/$1.blg.d; \
fi
# $(call refdep,TARGET,REF-FILE)
refdep = \
if [ -f '$2' ]; then \
mkdir -p $(DEPDIR); \
echo '$1: $2' >$(DEPDIR)/$1.ref.d; \
fi
check_noreffile = grep "File \`$*_ref.tex' not found" $*.log >/dev/null 2>&1
check_bblfile = grep '$*.bbl' $*.log >/dev/null 2>&1
check_reffile = grep '$*_ref.tex' $*.log >/dev/null 2>&1
check_indfile = grep '$*.ind' $*.log >/dev/null 2>&1
check_glsfile = grep '$*.gls' $*.log >/dev/null 2>&1
# axodraw2.sty uses primitive control sequences for reading .ax2 file, instead
# of \input, without writing any jobname.ax2 in the log file. So we look for
# jobname.ax1; if it is found in the log file, it means axodraw2.sty tries to
# read jobname.ax2.
check_ax2file = grep '$*.ax1' $*.log >/dev/null 2>&1
check_rerun = grep 'Rerun' $*.log | grep -v 'Package: rerunfilecheck' >/dev/null 2>&1
.tex.dvi:
@$(call typeset,$(latex))
.tex.pdf:
@$(call typeset,$(pdflatex))
.tex.log:
@$(call typeset,$(if $(filter $(default_target),dvi),$(latex),$(pdflatex)),false)
.dvi.ps:
@$(call exec,$(dvips) $<)
#.dvi.pdf:
# @$(call exec,$(dvipdf) $<)
.dvi.eps:
@trap 'rm -f $*.tmp.ps $*.tmp.pdf' 0 1 2 3 15; \
$(call exec,$(dvips) -o $*.tmp.ps $<); \
$(call exec,$(gs) -sDEVICE=pdfwrite -dPDFSETTINGS=/prepress -dEPSCrop -o $*.tmp.pdf $*.tmp.ps); \
if $(call cmpver,`$(gs) --version`,-lt,9.15); then \
$(call exec,$(gs) -sDEVICE=epswrite -o $@ $*.tmp.pdf); \
else \
$(call exec,$(gs) -sDEVICE=eps2write -o $@ $*.tmp.pdf); \
fi
# Experimental: only for pdflatex
.ltx.fmt:
@$(call exec,$(pdflatex_noopt) -ini -jobname='$*' '&$(notdir $(basename $(pdflatex_noopt))) $<\dump')
@$(call exec,rm -f $*.pdf)
.dtx.cls:
@$(call exec,$(latex_noopt) $(basename $<).ins)
.dtx.sty:
@$(call exec,$(latex_noopt) $(basename $<).ins)
.odt.pdf:
@$(call exec,$(soffice) --headless --nologo --nofirststartwizard --convert-to pdf $<)
# A distribution (for arXiv) needs to include
# 1. The main tex file.
# 2. Files that the main tex file depends on, except
# - files with absolute paths, which are considered as system files,
# - files created by LaTeX during typesetting, e.g., *.aux files,
# - *.ax2 file unless "\pdfoutput=1" is explicitly used.
# This default behaviour may be overwritten by EXTRADISTFILES and
# NODISTFILES.
# 3. 00README.XXX file if exists, and
# - Files listed in 00README.XXX with "ignore".
# See https://arxiv.org/help/00README
# 4. Files listed in ANCILLARYFILES are included under a subdirectory "anc".
# See https://arxiv.org/help/ancillary_files
%.tar.gz: %.$(default_target)
@tmpdir=tmp$$$$_$$RANDOM$$RANDOM; \
mkdir $$tmpdir || exit 1; \
trap 'rm -rf $$tmpdir' 0 1 2 3 15; \
pdfoutput=false; \
if head -5 "$*.tex" | sed 's/%.*//' | grep -q '\pdfoutput=1'; then \
pdfoutput=:; \
fi; \
if [ ! -f '$*.fls' ]; then \
$(call error_message,$*.fls not found. Delete $*.$(default_target) and then retry); \
exit 1; \
fi; \
dep_files=; \
for f in `grep INPUT '$*.fls' | sed 's/INPUT *\(\.\/\)\?//' | sed '/^kpsewhich/d' | sort | uniq`; do \
case $$f in \
*:*|/*|*.aux|*.lof|*.lot|*.nav|*.out|*.spl|*.toc|*.vrb|*-eps-converted-to.pdf) ;; \
*) \
case $$f in \
*.ax2) \
$$pdfoutput || continue; \
;; \
esac; \
ok=:; \
for ff in $(NODISTFILES); do \
if [ "x$$f" = "x$$ff" ]; then \
ok=false; \
break; \
fi; \
done; \
if $$ok; then \
d=`dirname "$$f"`; \
mkdir -p "$$tmpdir/$$d"; \
cp "$$f" "$$tmpdir/$$d" || exit 1; \
dep_files="$$dep_files $$f"; \
fi;; \
esac; \
done; \
for ff in $(EXTRADISTFILES); do \
$(call do_kpsewhich,f,$$ff); \
cp "$$f" "$$tmpdir/" || exit 1; \
dep_files="$$dep_files $$f"; \
done; \
if [ -f 00README.XXX ]; then \
cp "00README.XXX" "$$tmpdir/" || exit 1; \
dep_files="$$dep_files 00README.XXX"; \
for f in `grep ignore 00README.XXX | sed 's/ *ignore *$$//'`; do \
cp --parents "$$f" "$$tmpdir/" || rsync -R "$$f" "$$tmpdir" || exit 1; \
dep_files="$$dep_files $$f"; \
done; \
fi; \
for f in $(ANCILLARYFILES); do \
[ -d "$$tmpdir/anc" ] || mkdir "$$tmpdir/anc"; \
cp "$$f" "$$tmpdir/anc/" || exit 1; \
dep_files="$$dep_files $$f"; \
done; \
mkdir -p $(DEPDIR); \
{ \
for f in $$dep_files; do \
echo "$@ : \$$(wildcard $$f)"; \
done; \
} >$(DEPDIR)/$@.d; \
cd $$tmpdir || exit 1; \
$(call exec,tar cfv - * | gzip -9 -n >$@,false); \
cd .. || exit 1; \
$(check_failed); \
mv $$tmpdir/$@ $@
-include $(DEPDIR)/*.d
@tueda
Copy link
Author

tueda commented Sep 6, 2019

As a submodule:

git submodule add https://gist.github.com/5d8a7ff9181ef630160703606f449597.git extern/axodraw2e
ln -s extern/axodraw2e/axodraw2e.sty
git add axodraw2e.sty

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment