diff options
author | Karl Berry <karl@freefriends.org> | 2023-08-24 20:17:55 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2023-08-24 20:17:55 +0000 |
commit | 7c64690261606ded76e1e122d8387c1fe2f27f46 (patch) | |
tree | d5faccf3aafe5f46b82676e295a27ad48312de04 /Master/texmf-dist/doc | |
parent | 8991b6b1f01a41d76e5f1fabd21bf5a77b310ff5 (diff) |
commutative-diagrams (24aug23)
git-svn-id: svn://tug.org/texlive/trunk@68044 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc')
-rw-r--r-- | Master/texmf-dist/doc/generic/commutative-diagrams/commutative-diagrams-doc.pdf | bin | 538748 -> 609418 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/generic/commutative-diagrams/commutative-diagrams-doc.tex | 145 |
2 files changed, 115 insertions, 30 deletions
diff --git a/Master/texmf-dist/doc/generic/commutative-diagrams/commutative-diagrams-doc.pdf b/Master/texmf-dist/doc/generic/commutative-diagrams/commutative-diagrams-doc.pdf Binary files differindex f9dd77a8a28..d8f3c74dcd8 100644 --- a/Master/texmf-dist/doc/generic/commutative-diagrams/commutative-diagrams-doc.pdf +++ b/Master/texmf-dist/doc/generic/commutative-diagrams/commutative-diagrams-doc.pdf diff --git a/Master/texmf-dist/doc/generic/commutative-diagrams/commutative-diagrams-doc.tex b/Master/texmf-dist/doc/generic/commutative-diagrams/commutative-diagrams-doc.tex index bb431eb2763..e76b8b987b5 100644 --- a/Master/texmf-dist/doc/generic/commutative-diagrams/commutative-diagrams-doc.tex +++ b/Master/texmf-dist/doc/generic/commutative-diagrams/commutative-diagrams-doc.tex @@ -1,9 +1,9 @@ % % CoDi: Commutative Diagrams for TeX -% Copyright (c) 2015-2020 Paolo Brasolin <paolo.brasolin@gmail.com> +% Copyright (c) 2015-2023 Paolo Brasolin <paolo.brasolin@gmail.com> % SPDX-License-Identifier: MIT % -% This file is part of CoDi 1.0.1, released on 2020/06/11 under MIT license. +% This file is part of CoDi 1.1.0, released on 2023/08/23 under MIT license. % %==[ document class ]=========================================================== @@ -180,6 +180,10 @@ \usepackage{listings} +% Use straight quotes in code listings. https://tex.stackexchange.com/a/145417/82186 +\usepackage{textcomp} +\lstset{upquote=true} + % http://tex.stackexchange.com/a/336331/82186 \makeatletter \lst@Key{lastline}\relax{\ifnumcomp{#1}{<}{0}{% @@ -247,7 +251,7 @@ \startcodi,\stopcodi, \lay,\obj,\mor, \bye, - \draw,\foreach, + \draw,\foreach,\pgfqkeys, \ar, \psset,\everypsbox,\ncline,\ncarc, \xymatrix, @@ -258,13 +262,15 @@ frame=none, % extendedchars=false, inputencoding=utf8, +} + +\lstdefinestyle{metacode}{ escapeinside={(@}{@)}, moredelim=**[is][\color{orange!80!black}]{@opt@}{@/opt@}, moredelim=**[is][\color{blue!80!black}]{@nws@}{@/nws@}, % moredelim=**[is][\color\underbar]{@rep@}{@/rep@}, moredelim=**[s][\itshape]{<}{>}, - % NOTE: × and ı are needed just for the associahedron example - literate={~}{{\textvisiblespace}}1 {XOR}{{$\vert$}}1 {:}{{\textbf{:}}}1 {:=}{{$\equiv$}}1 {×}{{\texttimes}}1 {ı}{{\i}}1, + literate={XOR}{{$\vert$}}1 {:}{{\textbf{:}}}1 {:=}{{$\equiv$}}1, } \lstset{style=TeX} @@ -386,6 +392,11 @@ \def\NiceURL#1#2{\href{#2}{\color{blue}\ul{#1}}} +%==[ Import tikz-cd arrow styles ]=============================================? + +\usepackage{tikz-cd} +\pgfqkeys{/codi}{every arrow/.append style={/ektropi/add=/tikz/commutative diagrams}} + %==[ microtype ]================================================================ \usepackage{microtype} @@ -401,7 +412,7 @@ \resizebox{\linewidth}{!}{\scshape enchiridion}\par \vfill \marginpar{ - \resizebox{\linewidth}{!}{\scshape 1.0.1}\\[0.62em] + \resizebox{\linewidth}{!}{\scshape 1.1.0}\\[0.62em] \resizebox{\linewidth}{!}{\scshape \today} } @@ -778,7 +789,7 @@ Finally, \textbf{\CoDi}. The first of the two macros that \CoDi\ offers is \lstinline|\obj|. It is polymorphic and can draw both single objects and layouts. -\begin{lstlisting} +\begin{lstlisting}[style=metacode] \obj@opt@ <object options> @/opt@{<math>};(@ \marginpar{\scriptsize {\color{orange!80!black}Orange fragments} are optional.}@) \obj@opt@ <layout options> @/opt@{<layout>}; @@ -786,7 +797,7 @@ It is polymorphic and can draw both single objects and layouts. Layouts are described using the customary \TeX\ tabular syntax. -\begin{lstlisting} +\begin{lstlisting}[style=metacode] <layout> := (@\itshape\underbar{<row> <row separator>}@)(@ \marginpar{\scriptsize \underbar{Underlined fragments} can repeat one or more times.}@) <row> := <cell> (@\itshape\color{orange!80!black}\underbar{<cell separator> <cell>}@) @@ -798,7 +809,7 @@ Layouts are described using the customary \TeX\ tabular syntax. The discretionary options syntax is analogous to standard \TikZ\ nodes and matrices, respectively. -\begin{lstlisting} +\begin{lstlisting}[style=metacode] <object options> := (@\itshape\color{orange!80!black}\underbar{[object keylist]}@) @opt@(<name>) at (<coordinate>)@/opt@ <layout options> := (@\itshape\color{orange!80!black}\underbar{[layout keylist]}@) @opt@(<name>) at (<coordinate>)@/opt@ \end{lstlisting} @@ -854,7 +865,7 @@ by their row/column index pairs. The second and last macro that \CoDi\ offers is \lstinline|\mor|. It can draw single or chained morphisms. -\begin{lstlisting} +\begin{lstlisting}[style=metacode] \mor@opt@ <chain options> @/opt@<object>(@ \itshape\underbar{\textvisiblespace<morphism>\textvisiblespace<object>}@);(@ \marginpar{\scriptsize Whitespace marked as \textvisiblespace\ is mandatory.}@) @@ -862,14 +873,14 @@ It can draw single or chained morphisms. Source and target objects are referred to by their name. -\begin{lstlisting} +\begin{lstlisting}[style=metacode] <object> := @nws@(<name>)@/nws@ (@ \marginpar{\scriptsize {\color{blue!80!black}Blue fragments} can be either enclosed in the shown delimiters, or a \TeX\ group (not idiomatic), or simply devoid of whitespace.}@) \end{lstlisting} Morphisms consist of one or more optional labels and an arrow. -\begin{lstlisting} +\begin{lstlisting}[style=metacode] <morphism> := @opt@<labels> : @/opt@<arrow> <labels> := @nws@"<math>"@/nws@ XOR (@\underbar{[{\itshape "<math>", <label keylist>}]}@) (@ \marginpar{\scriptsize Alternatives are separated by $\vert$s.}@) @@ -879,7 +890,7 @@ Morphisms consist of one or more optional labels and an arrow. Global options can be given to both labels and arrows. -\begin{lstlisting} +\begin{lstlisting}[style=metacode] <chain options> := [<label keylist>] @opt@: [<arrow keylist>]@/opt@ \end{lstlisting} @@ -926,6 +937,16 @@ and keep the code terse and readable. \newpage \section{Names} As you'll have guessed by now, objects name themselves. +This also applies to the nodes labeling the morphisms. + +\begin{tcblisting}{snippet} +\begin{codi} + \obj{ A & B \\ }; + \mor A f:-> B; + \draw [red] (A) circle (1em); + \draw [blue] (f) circle (1em); +\end{codi} +\end{tcblisting} The process happens in three steps: \begin{itemize}[nosep] @@ -1040,7 +1061,7 @@ Chain gluing can be obtained using {\ttfamily +}. The expansion behaviour of the naming routine can be configured inside any \CoDi\ scope using the \lstinline!expand! key. -\begin{lstlisting} +\begin{lstlisting}[style=metacode] /codi/expand = none | once | full \end{lstlisting} @@ -1083,9 +1104,7 @@ yields unpractical results when parametrizing macros. \begin{codi} \foreach [count=\c] \m in {\lim,\prod} \obj [expand=full] at (4em*\c,0) {\m F}; -\mor (protect mathop {relax kern z@ mathgroup - symoperators lim}nmlimits@ F) - -> (DOTSI prodop slimits@ F); +\mor (lim F) -> (DOTSI prodop slimits@ F); \end{codi} \end{tcblisting} @@ -1103,7 +1122,7 @@ This explains why a setting to force a single expansion exists. The character replacement behaviour of the naming routine can be configured inside any \CoDi\ scope using various keys. -\begin{lstlisting} +\begin{lstlisting}[style=metacode] /codi/replace character = <character> with <character> /codi/replace charcode = <charcode> with <character> /codi/remove characters = <characters> @@ -1168,7 +1187,7 @@ The wise solution is writing better code. The name overwriting behaviour of the naming routine can be configured inside any \CoDi\ scope using the \lstinline!overwrite! key. -\begin{lstlisting} +\begin{lstlisting}[style=metacode] /codi/overwrite = false | alias | true \end{lstlisting} @@ -1212,6 +1231,17 @@ semantic alias. The hard overwriting behaviour ignores any label except generated ones; it exists for completeness and debugging purposes. + +All of the above applies to morphisms too. +The only difference is that the name of the node labelling the arrow is changed using the standard \lstinline|/tikz/name| key: + +\begin{tcblisting}{snippet} +\begin{codi} + \obj{ A & B \\ }; + \mor A [name=foo, "f"]:-> B; + \draw [red] (foo) circle (1em); +\end{codi} +\end{tcblisting} \newpage \section{Styles: scopes} \CoDi\ structures diagrams into five layers implemented with \TikZ. @@ -1233,7 +1263,7 @@ ones; it exists for completeness and debugging purposes. Each layer can be styled using \TikZ\ keys. Each layer possesses a default style: -\begin{lstlisting} +\begin{lstlisting}[style=metacode] /codi/every diagram /codi/every layout /codi/every object @@ -1247,7 +1277,7 @@ You can customize them using \TikZ\ key handlers, \eg \end{lstlisting} Each layer possesses a library of commonplace styles: -\begin{lstlisting} +\begin{lstlisting}[style=metacode] /codi/diagrams/ /codi/layouts/ /codi/objects/ @@ -1403,12 +1433,12 @@ search algorithm. Here's some meta code demonstrating this: Diagrams can be laid over regular grids: -\begin{lstlisting} +\begin{lstlisting}[style=metacode] /codi/diagrams/tetragonal=base <length> height <length> (@\hfill@) (default: base 4.5em height 2.8em) \end{lstlisting} -\begin{lstlisting} +\begin{lstlisting}[style=metacode] /codi/diagrams/hexagonal=<direction> side <length> angle <angle> (@\hfill@) (default: horizontal side 4.5em angle 60) \end{lstlisting} @@ -1444,12 +1474,12 @@ with red zones displaying the default radii around the origins. \section{Styles: layouts} Layouts can be laid over regular grids: -\begin{lstlisting} +\begin{lstlisting}[style=metacode] /codi/layouts/tetragonal=base <length> height <length> (@\hfill@) (default: base 4.5em height 2.8em) \end{lstlisting} -\begin{lstlisting} +\begin{lstlisting}[style=metacode] /codi/layouts/hexagonal=<direction> side <length> angle <angle> (@\hfill@) (default: horizontal side 4.5em angle 60) \end{lstlisting} @@ -1480,12 +1510,14 @@ spaced and offset in order to reproduce the grids given by diagram styles. Note that \emph{each row must have the same number of cells}% \footnote{this is different from the behaviour of, say, tables} or the spacing will be incorrect. + +Note that these keys will be recognized by \lstinline|\obj| only if you're using the tabular syntax. \newpage \section{Styles: objects} No styles are available at the moment. \newpage \section{Styles: arrows} -\begin{lstlisting} +\begin{lstlisting}[style=metacode] /codi/arrows/crossing over /codi/arrows/crossing over/clearance=<length> (@\hfill@) (default: 0.5ex) /codi/arrows/crossing over/color=<color> (@\hfill@) (default: white) @@ -1504,7 +1536,7 @@ over a \emph{previously drawn} one. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\begin{lstlisting} +\begin{lstlisting}[style=metacode] /codi/arrows/slide=<length> \end{lstlisting} @@ -1521,7 +1553,7 @@ This key slides an arrow backward (negative) and forward (positive) along its di %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -\begin{lstlisting} +\begin{lstlisting}[style=metacode] /codi/arrows/shove=<length> \end{lstlisting} @@ -1535,9 +1567,39 @@ This key shoves an arrow to the left (negative) and to the right (positive) with \mor :[shove=+.3em, blue] A -> B; \end{codi} \end{tcblisting} + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\hfill$\therefore$\hfill\null + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +\CoDi\ is currently missing a base arrow style library. + +You can define your own styles adding them to \lstinline|/codi/arrows/|. + +If you're familiar with {\ttfamily\small tikz-cd}, you can import its arrow styles to use them with \CoDi\ as follows in you preamble: +\begin{lstlisting} +\usepackage{tikz-cd} +\pgfqkeys{/codi}{ + every arrow/.append style={ + /ektropi/add=/tikz/commutative diagrams + } +} +\end{lstlisting} + +Then, you can use them seamlessly: + +\begin{tcblisting}{snippet, trim={2 and -1}} +\begin{codi} +\obj{ X & Y \\ & Z \\ }; +\mor X f:->,hook Y g:-> Z; +\mor X f:dashrightarrow Z; +\end{codi} +\end{tcblisting} \newpage \section{Styles: labels} -\begin{lstlisting} +\begin{lstlisting}[style=metacode] /codi/labels/mid \end{lstlisting} @@ -1559,6 +1621,29 @@ The remainder of the text is just commented examples. \clearpage +\subsection{2-cells} + +\begin{tcblisting}{gallery} +% From the LaTeX preamble: +% \usepackage{tikz-cd} + +% We use tikz-cd keys to quickly whip up an arrow style for a 2-morphism. +\pgfqkeys{/codi/arrows}{ + -2>/.style={ + /tikz/commutative diagrams/Rightarrow, + /tikz/commutative diagrams/shorten=2pt, + } +} + +\begin{codi} + \obj{ X & Y & Z \\ }; + \mor[swap]:[bend right] X f:-> Y m:-> Z; + \mor :[bend left] X g:-> Y n:-> Z; + \mor f \alpha:-2> g; + \mor[swap] m \beta:-2> n; +\end{codi} +\end{tcblisting} + \subsection{Snake} \begin{tcblisting}{gallery} @@ -1587,7 +1672,7 @@ The remainder of the text is just commented examples. \subsection{The fourth associahedron} -\begin{tcblisting}{gallery} +\begin{tcblisting}{gallery,listing options={literate={×}{{\texttimes}}1 {ı}{{\i}}1}} \begin{codi} % From the LaTeX preamble: % \usepackage{newunicodechar} |