| 1 |
% !TeX spellcheck = en_US |
| 2 |
% !TeX root = tikz-ext-manual.tex |
| 3 |
% Copyright 2022 by Qrrbrbirlbel |
| 4 |
% |
| 5 |
% This file may be distributed and/or modified |
| 6 |
% |
| 7 |
% 1. under the LaTeX Project Public License and/or |
| 8 |
% 2. under the GNU Free Documentation License. |
| 9 |
% |
| 10 |
|
| 11 |
\section{Shape: Uncentered Rectangle} |
| 12 |
\begin{purepgflibrary}{ext.shapes.uncenteredrectangle} |
| 13 |
A rectangle that has a variable horizontal center with three node parts. |
| 14 |
\inspiration{UncRectCD-Q,UncRectForest-Q}{UncRectCD-A,UncRectForest-A} |
| 15 |
\end{purepgflibrary} |
| 16 |
\begin{ext_shape}{uncentered rectangle} |
| 17 |
|
| 18 |
For some alignment problems, this shape could be useful. |
| 19 |
|
| 20 |
It has three node parts: the standard |text| part, |
| 21 |
the |left| part that is to the left of |text| |
| 22 |
and the |right| part that is to the right of |text|. |
| 23 |
|
| 24 |
When edges are to be connected with this shape, the |
| 25 |
following key changes to which inner center this shape will |
| 26 |
calculate the appropriate point on the border. |
| 27 |
\begin{key}{/\pgfext/uncentered rectangle center=\meta{left}\textrm{ or }\meta{text}\textrm{ or }\meta{right}\textrm{ or }\meta{real} (initially text)}\keycompat{pgf} |
| 28 |
Sets the center that is to be used for connecting edges. |
| 29 |
|
| 30 |
This will also move the anchors |north|, |mid|, |base| and |south| along. |
| 31 |
In the picture below, this are marked red. |
| 32 |
\end{key} |
| 33 |
|
| 34 |
\begin{key}{/\pgfext/uncentered rectangle use saved center=\meta{true}\textrm{ or }\meta{false} (default true)}\keycompat{pgf} |
| 35 |
When this is set to true, the border anchors will use the horizontal center that was used when |
| 36 |
the node was created. |
| 37 |
\end{key} |
| 38 |
|
| 39 |
For support of the \referenceLibraryandIndexO{cd} library of the |tikz-cd| package, |
| 40 |
this shape also supports a dynamic $y$ value for its anchors |center|, |west| and |east|. |
| 41 |
\begin{key}{/\pgfext/uncentered rectangle center yshift=\meta{dimension} (initially \{\})}\keycompat{pgf} |
| 42 |
This determines the distance between the baseline and the |center| anchors. |
| 43 |
|
| 44 |
If \meta{dimension} is empty, the real vertical center will be used. |
| 45 |
|
| 46 |
For use with |cd|, set this to |axis_height|. |
| 47 |
\end{key} |
| 48 |
%\pagebreak |
| 49 |
\begin{codeexample}[preamble=\usepgflibrary{ext.shapes.uncenteredrectangle}] |
| 50 |
\begin{tikzpicture}[style north/.style=red, style south/.style=red, style center/.style=red, style base/.style=red, style mid/.style=red] |
| 51 |
\Huge |
| 52 |
\node[shape example, name=n, ext_uncentered rectangle] |
| 53 |
{centered \nodepart{left} Un \nodepart{right} \space Rectangle\vrule width 1pt height 2cm} |
| 54 |
foreach \anchor/\pos in { |
| 55 |
north west/above left, north/below, north east/above right, real north/above, left north/above, right north/above, text north/above, |
| 56 |
west/left, center/above, east/right, real center/above, left center/above,right center/above,text center/below, |
| 57 |
mid west/left, mid/left, mid east/right, real mid/above, left mid/above, right mid/above, text mid/above, |
| 58 |
base west/left, base/right, base east/right, real base/below, left base/below, right base/below, text base/below, |
| 59 |
south west/below left, south/above, south east/below right, real south/below, left south/below, right south/below, text south/below, |
| 60 |
10/right, 130/below, left/left, right/right, text/right}{ |
| 61 |
plot[mark=x, only marks] coordinates {(n.\anchor)} |
| 62 |
node[inner sep=.1em, style \anchor/.try, style/.expand once=\pos] {\tiny\ttfamily\anchor}}; |
| 63 |
\end{tikzpicture} |
| 64 |
\end{codeexample} |
| 65 |
\end{ext_shape} |
| 66 |
|
| 67 |
\begin{tikzlibrary}{ext.shapes.uncenteredrectangle} |
| 68 |
This library extends the \referenceLibraryandIndexO{cd} library (from the |tikz-cd| package) |
| 69 |
so that it can be used with the |uncentered rectangle| shape. |
| 70 |
|
| 71 |
\inspirationQ{UncRectCD2-Q} |
| 72 |
\end{tikzlibrary} |
| 73 |
|
| 74 |
This library provides only one key. |
| 75 |
\begin{stylekey}{/\tikzext/tikz-cd fix}\keycompat{tikz-ext} |
| 76 |
This key installs various \enquote{fixes} to the \referenceKeyandIndexO[/tikz/commutative diagrams/]{every diagram} style: |
| 77 |
|
| 78 |
\begin{itemize} |
| 79 |
\item Firstly, is defines a \referenceKeyandIndexO{matrix of math nodes} key (only for the \referenceEnvironmentandIndexO{tikzcd} environment) |
| 80 |
which allows to toggle the \referenceKeyandIndexO[/tikz/commutative diagrams/]{math mode} for each node.% |
| 81 |
\footnote{Due to a bug with \referenceKeyandIndexO{execute at end node}, the \enquote{automatic} math mode in matrices can't be used |
| 82 |
with multipart nodes.} |
| 83 |
\item The helpful macro |\uncrec| will be installed. |
| 84 |
\begin{command}{\uncrec\marg{left}\marg{center}\marg{right}} |
| 85 |
When used as the content of a |ext_uncentered rectangle| shape, |
| 86 |
the node parts will be setup so that \meta{left} is in the left part of the node part etc. |
| 87 |
\end{command} |
| 88 |
\item Since math mode will be disabled with the |ext_uncentered rectangle|, it is automatically enabled for each node part with |\uncrec| but it can be disabled with the following key. |
| 89 |
\begin{key}{/tikz/uncrec math mode=\meta{true}\textrm{ or }\meta{false} (default true)} |
| 90 |
When enabled the contents of |\uncrec| will be set in math mode. |
| 91 |
\end{key} |
| 92 |
\item For easy access to the |uncentered rectangle| shape, the following keys are available inside a Commutative Diagram. |
| 93 |
\begin{stylekey}{/tikz/uncrec=\meta{left}\textrm{ or }\meta{text}\textrm{ or }\meta{right}\textrm{ or }\meta{real} (initially text)} |
| 94 |
This key sets the shape to |ext_uncentered rectangle| and \referenceKeyandIndex[/\pgfext/]{uncentered rectangle center} to its argument. |
| 95 |
\end{stylekey} |
| 96 |
\begin{stylekey}{/tikz/commutative diagrams/install uncentered rectangle in column=\meta{column}} |
| 97 |
All nodes in column \meta{column} will be set to the |ext_uncentered rectangle| shape. |
| 98 |
\end{stylekey} |
| 99 |
\end{itemize} |
| 100 |
\end{stylekey} |
| 101 |
|
| 102 |
\begingroup |
| 103 |
\tikzexternaldisable |
| 104 |
%\catcode`\|=12 |
| 105 |
\begin{codeexample}[leave comments, width=8cm, preamble=\usetikzlibrary{cd, ext.shapes.uncenteredrectangle}] |
| 106 |
\tikzextset{tikz-cd fix} |
| 107 |
\newcommand*\C[1]{C_{\%_{#1}}} |
| 108 |
\begin{tikzcd}[ |
| 109 |
sep=tiny, |
| 110 |
arrows={-, gray}, |
| 111 |
cells={font=\strut, inner xsep=.2ex, inner ysep=.1ex}, |
| 112 |
install uncentered rectangle in column=3 |
| 113 |
] |
| 114 |
\C{1} \drar & & \uncrec{}{m_{r_1}}{{} = \C{2}-C_\%} \dlar\\ |
| 115 |
& C_\% \\ |
| 116 |
\C{2} \urar & & \uncrec{}{m_{r_2}}{{} = \C{1}-C_\%} \ular |
| 117 |
\end{tikzcd} |
| 118 |
\end{codeexample} |
| 119 |
\begin{codeexample}[leave comments, width=8cm, preamble=\usetikzlibrary{cd, ext.shapes.uncenteredrectangle}] |
| 120 |
\tikzextset{tikz-cd fix} |
| 121 |
\begin{tikzcd}[install uncentered rectangle in column/.list={1,2}] |
| 122 |
\uncrec{S \supset {}}{U_\tau}{} \arrow[r, "\varphi_0"] |
| 123 |
\arrow[d, "\tau", "\sim"'] |
| 124 |
& \uncrec{}{U_\pi}{{} \subset T} \arrow[d, "\pi", "\sim"'] |
| 125 |
\\ |
| 126 |
\uncrec{\operatorname{Bl}_{(0,0)}(\mathbb{A}^2) \supset{}}{V_\tau}{} \arrow[r, "\epsilon"] |
| 127 |
& \uncrec{}{V_\pi}{{} \subset \mathbb{A}^2} |
| 128 |
\end{tikzcd} |
| 129 |
\end{codeexample} |
| 130 |
\endgroup |
| 131 |
\endinput |