diff --git a/src/math/mathfig.pysty b/src/math/mathfig.pysty index 849f129..ab8974d 100644 --- a/src/math/mathfig.pysty +++ b/src/math/mathfig.pysty @@ -11,6 +11,7 @@ __HEADER__(Math figures with TikZ / pgfplots / xy) \usetikzlibrary{calc, intersections, through, quotes, angles, babel, positioning, snakes} \RequirePackage{tikz-cd} %Commutative diagrams +\RequirePackage{xparse} %%for small diagrams, similar to tikz-cd @@ -20,3 +21,24 @@ __HEADER__(Math figures with TikZ / pgfplots / xy) % \xyoption{all} % here, but this messes with the catcode of the @ sign (which no package should do!) % so that further parts in this package would get broken + + +\newcommand\pushoutsymbol{\tikz[baseline=0.5,scale=0.2]{ + \draw[-] (0,0) --(0,1) -- (1,1); + \draw (1,0) circle (1.5pt);} +} + +\newcommand\pullbacksymbol{\tikz[baseline=0.5,scale=0.2]{ + \draw[-] (0,0) --(1,0) -- (1,1); + \draw (0,1) circle (1.5pt);} +} + +% This is used in a tikzcd +\NewDocumentCommand\pushout{ O{dr} }{ + \arrow[phantom, pos=0.45]{#1}{\pushoutsymbol} +} + +% This is used in a tikzcd +\NewDocumentCommand\pullback{ O{dr} }{ + \arrow[phantom, pos=0.45]{#1}{\pullbacksymbol} +} diff --git a/tests/math/mathfig/test.tex b/tests/math/mathfig/test.tex index 09326fb..c0eac2f 100644 --- a/tests/math/mathfig/test.tex +++ b/tests/math/mathfig/test.tex @@ -10,7 +10,14 @@ \end{tikzcd} \] test2: - \begin{tikzpicture} - \draw (0,0) rectangle (10,10); - \end{tikzpicture} + + \begin{tikzcd} + A \pushout & B \\ + C & D + \end{tikzcd} + + \begin{tikzcd} + A \pullback & B \\ + C & D + \end{tikzcd} \end{document}