From 64416f686ef411d51bba094b9c9bc778b8833d6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler=20=28via=20gitlab=20runner=29?= Date: Wed, 27 Oct 2021 20:26:45 +0200 Subject: [PATCH] add pushout and pullback symbols --- src/math/mathfig.pysty | 22 ++++++++++++++++++++++ tests/math/mathfig/test.tex | 13 ++++++++++--- 2 files changed, 32 insertions(+), 3 deletions(-) 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}