diff options
Diffstat (limited to 'Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-matrices.tex')
-rw-r--r-- | Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-matrices.tex | 473 |
1 files changed, 233 insertions, 240 deletions
diff --git a/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-matrices.tex b/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-matrices.tex index 051ede9e9c6..e8c5a77dc9a 100644 --- a/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-matrices.tex +++ b/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-matrices.tex @@ -7,53 +7,49 @@ % % See the file doc/generic/pgf/licenses/LICENSE for more details. -\section{Matrices and Alignment} +\section{Matrices and Alignment} \label{section-matrices} \subsection{Overview} -When creating pictures, one often faces the problem of correctly -aligning parts of the picture. For example, you might wish that the -|baseline|s of certain nodes should be on the same line and some -further nodes should be below these nodes with, say, their centers on -a vertical lines. There are different ways of solving such -problems. For example, by making clever use of anchors, nearly all -such alignment problems can be solved. However, this often leads to -complicated code. An often simpler way is to use \emph{matrices}, -the use of which is explained in the current section. - -A \tikzname\ matrix is similar to \LaTeX's |{tabular}| or -|{array}| environment, only instead of text each cell contains a -little picture or a node. The sizes of the cells are automatically -adjusted such that they are large enough to contain all the cell -contents. +When creating pictures, one often faces the problem of correctly aligning parts +of the picture. For example, you might wish that the |baseline|s of certain +nodes should be on the same line and some further nodes should be below these +nodes with, say, their centers on a vertical lines. There are different ways of +solving such problems. For example, by making clever use of anchors, nearly all +such alignment problems can be solved. However, this often leads to complicated +code. An often simpler way is to use \emph{matrices}, the use of which is +explained in the current section. -Matrices are a powerful tool and they need to be handled with some care. -For impatient readers who skip the rest of this section: you -\emph{must} end \emph{every} row with |\\|. In particular, the last -row \emph{must} be ended with |\\|. +A \tikzname\ matrix is similar to \LaTeX's |{tabular}| or |{array}| +environment, only instead of text each cell contains a little picture or a +node. The sizes of the cells are automatically adjusted such that they are +large enough to contain all the cell contents. -Many of the ideas implemented in \tikzname's matrix support are due to -Mark Wibrow -- many thanks to Mark at this point! +Matrices are a powerful tool and they need to be handled with some care. For +impatient readers who skip the rest of this section: you \emph{must} end +\emph{every} row with |\\|. In particular, the last row \emph{must} be ended +with |\\|. +Many of the ideas implemented in \tikzname's matrix support are due to Mark +Wibrow -- many thanks to Mark at this point! \subsection{Matrices are Nodes} -Matrices are special in many ways, but for most purposes matrices are -treated like nodes. This means, that you use the |node| path command -to create a matrix and you only use a special option, namely the -|matrix| option, to signal that the node will contain a -matrix. Instead of the usual \TeX-box that makes up the |text| part of -the node's shape, the matrix is used. Thus, in particular, a matrix -can have a shape, this shape can be drawn or filled, it can be used in -a tree, and so on. Also, you can refer to the different anchors of a -matrix. +Matrices are special in many ways, but for most purposes matrices are treated +like nodes. This means, that you use the |node| path command to create a matrix +and you only use a special option, namely the |matrix| option, to signal that +the node will contain a matrix. Instead of the usual \TeX-box that makes up the +|text| part of the node's shape, the matrix is used. Thus, in particular, a +matrix can have a shape, this shape can be drawn or filled, it can be used in a +tree, and so on. Also, you can refer to the different anchors of a matrix. \begin{key}{/tikz/matrix=\meta{true or false} (default true)} - This option can be passed to a |node| path command. It signals that - the node will contain a matrix. + This option can be passed to a |node| path command. It signals that the + node will contain a matrix. + % \begin{codeexample}[] \begin{tikzpicture} \draw[help lines] (0,0) grid (4,2); @@ -66,67 +62,65 @@ matrix. \draw [very thick,->] (0,0) |- (my matrix.west); \end{tikzpicture} \end{codeexample} - The exact syntax of the matrix is explained in the course of this - section. - \begin{stylekey}{/tikz/every matrix (initially \normalfont empty)} - This style is used in every matrix. - \end{stylekey} + % + The exact syntax of the matrix is explained in the course of this section. + % + \begin{stylekey}{/tikz/every matrix (initially \normalfont empty)} + This style is used in every matrix. + \end{stylekey} \end{key} -Even more so than nodes, matrices will often be the only object on a -path. Because of this, there is a special abbreviation for creating matrices: +Even more so than nodes, matrices will often be the only object on a path. +Because of this, there is a special abbreviation for creating matrices: \begin{command}{\matrix} - Inside |{tikzpicture}| this is an abbreviation for |\path node[matrix]|. + Inside |{tikzpicture}| this is an abbreviation for |\path node[matrix]|. \end{command} -Even though matrices are nodes, some options do not have the same -effect as for normal nodes: +Even though matrices are nodes, some options do not have the same effect as for +normal nodes: +% \begin{enumerate} -\item Rotations and scaling have no effect on a matrix as a whole - (however, you can still transform the contents of the cells - normally). Before the matrix is typeset, the rotational and scaling - part of the transformation matrix is reset. -\item For multi-part shapes you can only set the |text| part of the - node. -\item All options starting with |text| such as |text width| have no - effect. + \item Rotations and scaling have no effect on a matrix as a whole (however, + you can still transform the contents of the cells normally). Before the + matrix is typeset, the rotational and scaling part of the + transformation matrix is reset. + \item For multi-part shapes you can only set the |text| part of the node. + \item All options starting with |text| such as |text width| have no effect. \end{enumerate} - \subsection{Cell Pictures} \label{section-tikz-cell-pictures} -A matrix consists of rows of \emph{cells}. Each row (including the -last one!) is ended by the command |\\|. The character |&| is used -to separate cells. Inside each cell, you must place commands for -drawing a picture, called the \emph{cell picture} in the -following. (However, cell pictures are not enclosed in a complete -|{pgfpicture}| environment, they are a bit more light-weight. The main -difference is that cell pictures cannot have layers.) It is not -necessary to specify beforehand how many rows or columns there are -going to be and if a row contains less cell pictures than another -line, empty cells are automatically added as needed. +A matrix consists of rows of \emph{cells}. Each row (including the last one!) +is ended by the command |\\|. The character |&| is used to separate cells. +Inside each cell, you must place commands for drawing a picture, called the +\emph{cell picture} in the following. (However, cell pictures are not enclosed +in a complete |{pgfpicture}| environment, they are a bit more light-weight. The +main difference is that cell pictures cannot have layers.) It is not necessary +to specify beforehand how many rows or columns there are going to be and if a +row contains less cell pictures than another line, empty cells are +automatically added as needed. -\subsubsection{Alignment of Cell Pictures} -For each cell picture a bounding box is computed. These bounding boxes -and the origins of the cell pictures determine how the cells are -aligned. Let us start with the rows: Consider the cell pictures on the first -row. Each has a bounding box and somewhere inside this bounding box -the origin of the cell picture can be found (the origin might even lie -outside the bounding box, but let us ignore this problem for the -moment). The cell pictures are then shifted around such that all -origins lie on the same horizontal line. This may make it necessary to -shift some cell pictures upwards and others downwards, but it can be -done and this yields the vertical alignment of the cell pictures this -row. The top of the row is then given by the top of the ``highest'' -cell picture in the row, the bottom of the row is given by the bottom -of the lowest cell picture. (To be more precise, the height of the row -is the maximum $y$-value of any of the bounding boxes and the depth of -the row is the negated minimum $y$-value of the bounding boxes). +\subsubsection{Alignment of Cell Pictures} +For each cell picture a bounding box is computed. These bounding boxes and the +origins of the cell pictures determine how the cells are aligned. Let us start +with the rows: Consider the cell pictures on the first row. Each has a bounding +box and somewhere inside this bounding box the origin of the cell picture can +be found (the origin might even lie outside the bounding box, but let us ignore +this problem for the moment). The cell pictures are then shifted around such +that all origins lie on the same horizontal line. This may make it necessary to +shift some cell pictures upwards and others downwards, but it can be done and +this yields the vertical alignment of the cell pictures this row. The top of +the row is then given by the top of the ``highest'' cell picture in the row, +the bottom of the row is given by the bottom of the lowest cell picture. (To be +more precise, the height of the row is the maximum $y$-value of any of the +bounding boxes and the depth of the row is the negated minimum $y$-value of the +bounding boxes). +% \begin{codeexample}[] \begin{tikzpicture} [every node/.style={draw=black,anchor=base,font=\huge}] @@ -147,7 +141,7 @@ bottom of the first row touches the top of the second row (unless a |row sep| is used to add a bit of space). Then the bottom of the second row touches the top of the third row, and so on. Typically, each row will have an individual height and depth. - +% \begin{codeexample}[] \begin{tikzpicture} [every node/.style={draw=black,anchor=base}] @@ -166,22 +160,20 @@ each row will have an individual height and depth. \end{tikzpicture} \end{codeexample} -Let us now have a look at the columns. The rules for how the pictures -on any given column are aligned are very similar to the row -alignment: Consider all cell pictures in the first column. Each is -shifted horizontally such that the origins lie on the same vertical -line. Then, the left end of the column is at the left end of the -bounding box that protrudes furthest to the left. The right end of the -column is at the right end of the bounding box that protrudes furthest -to the right. This fixes the horizontal alignment of the cell pictures -in the first column and the same happens the cell pictures in the -other columns. Then, the right end of the first column touches the -left end of the second column (unless |column sep| is used). The right -end of the second column touches the left end of the third column, and -so on. (Internally, two columns are actually used to achieve the -desired horizontal alignment, but that is only an implementation -detail.) - +Let us now have a look at the columns. The rules for how the pictures on any +given column are aligned are very similar to the row alignment: Consider all +cell pictures in the first column. Each is shifted horizontally such that the +origins lie on the same vertical line. Then, the left end of the column is at +the left end of the bounding box that protrudes furthest to the left. The right +end of the column is at the right end of the bounding box that protrudes +furthest to the right. This fixes the horizontal alignment of the cell pictures +in the first column and the same happens the cell pictures in the other +columns. Then, the right end of the first column touches the left end of the +second column (unless |column sep| is used). The right end of the second column +touches the left end of the third column, and so on. (Internally, two columns +are actually used to achieve the desired horizontal alignment, but that is only +an implementation detail.) +% \begin{codeexample}[] \begin{tikzpicture}[every node/.style={draw}] \matrix [draw=red] @@ -205,23 +197,21 @@ detail.) \end{codeexample} - \subsubsection{Setting and Adjusting Column and Row Spacing} -There are different ways of setting and adjusting the spacing between -columns and rows. First, you can use the options |column sep| and -|row sep| to set a default spacing for all rows and all -columns. Second, you can add options to the |&| character and the |\\| -command to adjust the spacing between two specific columns or -rows. Additionally, you can specify whether the space between two -columns or rows should be considered between the origins of cells in -the column or row or between their borders. +There are different ways of setting and adjusting the spacing between columns +and rows. First, you can use the options |column sep| and |row sep| to set a +default spacing for all rows and all columns. Second, you can add options to +the |&| character and the |\\| command to adjust the spacing between two +specific columns or rows. Additionally, you can specify whether the space +between two columns or rows should be considered between the origins of cells +in the column or row or between their borders. \begin{key}{/tikz/column sep=\meta{spacing list}} - This option sets a default space that is added between every two - columns. This space can be positive or negative and is zero by - default. The \meta{spacing list} normally contains a single - dimension like |2pt|. + This option sets a default space that is added between every two columns. + This space can be positive or negative and is zero by default. The + \meta{spacing list} normally contains a single dimension like |2pt|. + % \begin{codeexample}[] \begin{tikzpicture} \matrix [draw,column sep=1cm,nodes=draw] @@ -236,25 +226,25 @@ the column or row or between their borders. node [above,midway] {1cm}; \end{tikzpicture} \end{codeexample} - More generally, the \meta{spacing list} may contain a whole list of - numbers, separated by commas, and occurrences of the two key words - |between origins| and |between borders|. The effect of specifying - such a list is the following: First, all numbers occurring in the - list are simply added to compute the final spacing. Second, - concerning the two keywords, the last occurrence of one of the keywords is - important. If the last occurrence is |between borders| or if neither - occurs, then the space is inserted between the two columns - normally. However, if the last occurs is |between origins|, then the - following happens: The distance between the columns is adjusted such - that the difference between the origins of all the cells in the - first column (remember that they all lie on straight line) and the - origins of all the cells in the second column is exactly the given - distance. - - \emph{The }|between origins|\emph{ option can only be used for columns - mentioned in the first row, that is, you cannot specify this - option for columns introduced only in later rows.} - + % + More generally, the \meta{spacing list} may contain a whole list of + numbers, separated by commas, and occurrences of the two key words + |between origins| and |between borders|. The effect of specifying such a + list is the following: First, all numbers occurring in the list are simply + added to compute the final spacing. Second, concerning the two keywords, + the last occurrence of one of the keywords is important. If the last + occurrence is |between borders| or if neither occurs, then the space is + inserted between the two columns normally. However, if the last occurs is + |between origins|, then the following happens: The distance between the + columns is adjusted such that the difference between the origins of all the + cells in the first column (remember that they all lie on straight line) and + the origins of all the cells in the second column is exactly the given + distance. + + \emph{The }|between origins|\emph{ option can only be used for columns + mentioned in the first row, that is, you cannot specify this option for + columns introduced only in later rows.} + % \begin{codeexample}[] \begin{tikzpicture} \matrix [draw,column sep={1cm,between origins},nodes=draw] @@ -266,13 +256,15 @@ the column or row or between their borders. \draw [<->,red,thick] (a.center) -- (b.center) node [above,midway] {1cm}; \end{tikzpicture} \end{codeexample} + % \end{key} \begin{key}{/tikz/row sep=\meta{spacing list}} - This option works like |column sep|, only for rows. Here, too, you - can specify whether the space is added between the lower end of the - first row and the upper end of the second row, or whether the space - is computed between the origins of the two rows. + This option works like |column sep|, only for rows. Here, too, you can + specify whether the space is added between the lower end of the first row + and the upper end of the second row, or whether the space is computed + between the origins of the two rows. + % \begin{codeexample}[] \begin{tikzpicture} \matrix [draw,row sep=1cm,nodes=draw] @@ -284,6 +276,7 @@ the column or row or between their borders. \draw [<->,red,thick] (a.south) -- (b.north) node [right,midway] {1cm}; \end{tikzpicture} \end{codeexample} + % \begin{codeexample}[] \begin{tikzpicture} \matrix [draw,row sep={1cm,between origins},nodes=draw] @@ -295,15 +288,16 @@ the column or row or between their borders. \draw [<->,red,thick] (a.center) -- (b.center) node [right,midway] {1cm}; \end{tikzpicture} \end{codeexample} + % \end{key} -The row-end command |\\| allows you to provide an optional -argument, which must be a dimension. This dimension will be added to -the list in |row sep|. This means that, firstly, any numbers you list -in this argument will be added as an extra row separation between the -line being ended and the next line and, secondly, you can use the -keywords |between origins| and |between borders| to locally overrule -the standard setting for this line pair. +The row-end command |\\| allows you to provide an optional argument, which must +be a dimension. This dimension will be added to the list in |row sep|. This +means that, firstly, any numbers you list in this argument will be added as an +extra row separation between the line being ended and the next line and, +secondly, you can use the keywords |between origins| and |between borders| to +locally overrule the standard setting for this line pair. +% \begin{codeexample}[] \begin{tikzpicture} \matrix [row sep=1mm] @@ -319,14 +313,14 @@ the standard setting for this line pair. \end{tikzpicture} \end{codeexample} -The cell separation character |&| also takes an optional -argument, which must also be a spacing list. This spacing list is -added to the |column sep| having a similar effect as the option for -the |\\| command for rows. +The cell separation character |&| also takes an optional argument, which must +also be a spacing list. This spacing list is added to the |column sep| having a +similar effect as the option for the |\\| command for rows. -This optional spacing list can only be given the first time -a new column is started (usually in the first row), subsequent usages -of this option in later rows have no effect. +This optional spacing list can only be given the first time a new column is +started (usually in the first row), subsequent usages of this option in later +rows have no effect. +% \begin{codeexample}[] \begin{tikzpicture} \matrix [draw,nodes=draw,column sep=1mm] @@ -337,6 +331,7 @@ of this option in later rows have no effect. }; \end{tikzpicture} \end{codeexample} +% \begin{codeexample}[] \begin{tikzpicture} \matrix [draw,nodes=draw,column sep=1mm] @@ -348,6 +343,7 @@ of this option in later rows have no effect. \draw [<->,red,thick] (a.center) -- (b.center) node [above,midway] {11mm}; \end{tikzpicture} \end{codeexample} +% \begin{codeexample}[] \begin{tikzpicture} \matrix [draw,nodes=draw,column sep={1cm,between origins}] @@ -362,39 +358,34 @@ of this option in later rows have no effect. \end{codeexample} - - \subsubsection{Cell Styles and Options} -The following styles and options are useful for changing the appearance -of all cell pictures: +The following styles and options are useful for changing the appearance of all +cell pictures: \begin{stylekey}{/tikz/every cell=\marg{row}\marg{column} (initially \normalfont empty)} - This style is installed at the beginning of each cell picture with - the two parameters being the current \meta{row} and \meta{column} of - the cell. Note that setting this style to |draw| will \emph{not} - cause all nodes to be drawn since the |draw| option has to be passed - to each node individually. - - Inside this style (and inside all cells), the current \meta{row} and - \meta{column} number are also accessible via the counters - |\pgfmatrixcurrentrow| and |\pgfmatrixcurrentcolumn|. + This style is installed at the beginning of each cell picture with the two + parameters being the current \meta{row} and \meta{column} of the cell. Note + that setting this style to |draw| will \emph{not} cause all nodes to be + drawn since the |draw| option has to be passed to each node individually. + + Inside this style (and inside all cells), the current \meta{row} and + \meta{column} number are also accessible via the counters + |\pgfmatrixcurrentrow| and |\pgfmatrixcurrentcolumn|. \end{stylekey} \begin{key}{/tikz/cells=\meta{options}} - This key adds the \meta{options} to the style |every cell|. It is mainly - just a shorthand for the code - |every cell/.append style=|\meta{options}. + This key adds the \meta{options} to the style |every cell|. It is mainly + just a shorthand for the code |every cell/.append style=|\meta{options}. \end{key} \begin{key}{/tikz/nodes=\meta{options}} - This key adds the \meta{options} to the style |every node|. It is mainly - just a shorthand for the code |every node/.append style=|\meta{options}. - - The main use of this option is the install some options for the - nodes \emph{inside} the matrix that should not apply to the matrix - \emph{itself}. + This key adds the \meta{options} to the style |every node|. It is mainly + just a shorthand for the code |every node/.append style=|\meta{options}. + The main use of this option is the install some options for the nodes + \emph{inside} the matrix that should not apply to the matrix \emph{itself}. + % \begin{codeexample}[] \begin{tikzpicture} \matrix [nodes={fill=blue!20,minimum size=5mm}] @@ -405,42 +396,43 @@ of all cell pictures: }; \end{tikzpicture} \end{codeexample} + % \end{key} -The next set of styles can be used to change the appearance of certain -rows, columns, or cells. If more than one of these styles is defined, -they are executed in the below order (the |every cell| style is -executed before all of the below). +The next set of styles can be used to change the appearance of certain rows, +columns, or cells. If more than one of these styles is defined, they are +executed in the below order (the |every cell| style is executed before all of +the below). + % \begin{stylekey}{/tikz/column \meta{number}} - This style is used for every cell in column \meta{number}. + This style is used for every cell in column \meta{number}. \end{stylekey} \begin{stylekey}{/tikz/every odd column} - This style is used for every cell in an odd column. + This style is used for every cell in an odd column. \end{stylekey} \begin{stylekey}{/tikz/every even column} - This style is used for every cell in an even column. + This style is used for every cell in an even column. \end{stylekey} \begin{stylekey}{/tikz/row \meta{number}} - This style is used for every cell in row \meta{number}. + This style is used for every cell in row \meta{number}. \end{stylekey} \begin{stylekey}{/tikz/every odd row} - This style is used for every cell in an odd row. + This style is used for every cell in an odd row. \end{stylekey} \begin{stylekey}{/tikz/every even row} - This style is used for every cell in an even row. + This style is used for every cell in an even row. \end{stylekey} \begin{stylekey}{/tikz/row \meta{row number} column \meta{column number}} - This style is used for the cell in row \meta{row number} and column - \meta{column number}. + This style is used for the cell in row \meta{row number} and column + \meta{column number}. \end{stylekey} - - +% \begin{codeexample}[] \begin{tikzpicture} [row 1/.style={red}, @@ -456,9 +448,9 @@ executed before all of the below). \end{tikzpicture} \end{codeexample} -You can use the |column |\meta{number} option to change the alignment -for different columns. - +You can use the |column |\meta{number} option to change the alignment for +different columns. +% \begin{codeexample}[] \begin{tikzpicture} [column 1/.style={anchor=base west}, @@ -473,21 +465,22 @@ for different columns. \end{tikzpicture} \end{codeexample} - -In many matrices all cell pictures have nearly the same code. For -example, cells typically start with |\node{| and end |};|. The -following options allow you to execute such code in all cells: +In many matrices all cell pictures have nearly the same code. For example, +cells typically start with |\node{| and end |};|. The following options allow +you to execute such code in all cells: \begin{key}{/tikz/execute at begin cell=\meta{code}} - The code will be executed at the beginning of each nonempty cell. + The code will be executed at the beginning of each nonempty cell. \end{key} +% \begin{key}{/tikz/execute at end cell=\meta{code}} - The code will be executed at the end of each nonempty cell. + The code will be executed at the end of each nonempty cell. \end{key} +% \begin{key}{/tikz/execute at empty cell=\meta{code}} - The code will be executed inside each empty cell. + The code will be executed inside each empty cell. \end{key} - +% \begin{codeexample}[] \begin{tikzpicture} [matrix of nodes/.style={ @@ -502,6 +495,7 @@ following options allow you to execute such code in all cells: }; \end{tikzpicture} \end{codeexample} +% \begin{codeexample}[] \begin{tikzpicture} [matrix of nodes/.style={ @@ -518,27 +512,24 @@ following options allow you to execute such code in all cells: \end{tikzpicture} \end{codeexample} -The |matrix| library defines a number of styles that make use of the -above options. - - +The |matrix| library defines a number of styles that make use of the above +options. \subsection{Anchoring a Matrix} -Since matrices are nodes, they can be anchored in the usual fashion -using the |anchor| option. However, there are two ways to influence -this placement further. First, the following option is often useful: +Since matrices are nodes, they can be anchored in the usual fashion using the +|anchor| option. However, there are two ways to influence this placement +further. First, the following option is often useful: \begin{key}{/tikz/matrix anchor=\meta{anchor}} - This option has the same effect as |anchor|, but the option applies - only to the matrix itself, not to the cells inside. If you just say - |anchor=north| as an option to the matrix node, all nodes inside - matrix will also have this anchor, unless it is explicitly set - differently for each node. By comparison, |matrix anchor| sets the - anchor for the matrix, but for the nodes inside the value of - |anchor| remain unchanged. - + This option has the same effect as |anchor|, but the option applies only to + the matrix itself, not to the cells inside. If you just say |anchor=north| + as an option to the matrix node, all nodes inside matrix will also have + this anchor, unless it is explicitly set differently for each node. By + comparison, |matrix anchor| sets the anchor for the matrix, but for the + nodes inside the value of |anchor| remain unchanged. + % \begin{codeexample}[] \begin{tikzpicture} \matrix [matrix anchor=west] at (0,0) @@ -555,22 +546,22 @@ this placement further. First, the following option is often useful: }; \end{tikzpicture} \end{codeexample} + % \end{key} -The second way to anchor a matrix is to use \emph{an anchor of a node - inside the matrix}. For this, the |anchor| option has a special -effect when given as an argument to a matrix: +The second way to anchor a matrix is to use \emph{an anchor of a node inside +the matrix}. For this, the |anchor| option has a special effect when given as +an argument to a matrix: \begin{key}{/tikz/anchor=\meta{anchor or node.anchor}} - Normally, the argument of this option refers to anchor of the matrix - node, which is the node that includes all of the stuff of the - matrix. However, you can also provide an argument of the form - \meta{node}|.|\meta{anchor} where \meta{node} must be node defined - inside the matrix and \meta{anchor} is an anchor of this node. In - this case, the whole matrix is shifted around in such a way that - this particular anchor of this particular node lies at the |at| - position of the matrix. The same is true for |matrix anchor|. - + Normally, the argument of this option refers to anchor of the matrix node, + which is the node that includes all of the stuff of the matrix. However, + you can also provide an argument of the form \meta{node}|.|\meta{anchor} + where \meta{node} must be node defined inside the matrix and \meta{anchor} + is an anchor of this node. In this case, the whole matrix is shifted around + in such a way that this particular anchor of this particular node lies at + the |at| position of the matrix. The same is true for |matrix anchor|. + % \begin{codeexample}[] \begin{tikzpicture} \draw[help lines] (0,0) grid (3,2); @@ -583,6 +574,7 @@ effect when given as an argument to a matrix: \draw (inner node.south) circle (1pt); \end{tikzpicture} \end{codeexample} + % \end{key} @@ -590,21 +582,20 @@ effect when given as an argument to a matrix: Even though \tikzname\ seems to use |&| to separate cells, \pgfname\ actually uses a different command to separate cells, namely the command -|\pgfmatrixnextcell| and using a normal |&| character will normally -fail. What happens is that, \tikzname\ makes |&| an active character -and then defines this character to be equal to -|\pgfmatrixnextcell|. In most situations this will work -nicely, but sometimes |&| cannot be made active; for -instance because the matrix is used in an argument of some macro or -the matrix contains nodes that contain normal |{tabular}| -environments. In this case you can use the following option to avoid -having to type |\pgfmatrixnextcell| each time: +|\pgfmatrixnextcell| and using a normal |&| character will normally fail. What +happens is that, \tikzname\ makes |&| an active character and then defines this +character to be equal to |\pgfmatrixnextcell|. In most situations this will +work nicely, but sometimes |&| cannot be made active; for instance because the +matrix is used in an argument of some macro or the matrix contains nodes that +contain normal |{tabular}| environments. In this case you can use the following +option to avoid having to type |\pgfmatrixnextcell| each time: \begin{key}{/tikz/ampersand replacement=\meta{macro name or empty}} - If a macro name is provided, this macro will be defined to be equal - to |\pgfmatrixnextcell| inside matrices and |&| will not be made - active. For instance, you could say |ampersand replacement=\&| and - then use |\&| to separate columns as in the following example: + If a macro name is provided, this macro will be defined to be equal to + |\pgfmatrixnextcell| inside matrices and |&| will not be made active. For + instance, you could say |ampersand replacement=\&| and then use |\&| to + separate columns as in the following example: + % \begin{codeexample}[] \tikz \matrix [ampersand replacement=\&] @@ -613,14 +604,15 @@ having to type |\pgfmatrixnextcell| each time: \draw (0.2,0) circle (2mm); \& \fill[red] (0,0) circle (3mm); \\ }; \end{codeexample} + % \end{key} \subsection{Examples} -The following examples are adapted from code by Mark Wibrow. The first -two redraw pictures from Timothy van Zandt's PStricks documentation: - +The following examples are adapted from code by Mark Wibrow. The first two +redraw pictures from Timothy van Zandt's PStricks documentation: +% {\catcode`\|=12 \begin{codeexample}[] \begin{tikzpicture} @@ -691,11 +683,11 @@ two redraw pictures from Timothy van Zandt's PStricks documentation: \end{tikzpicture} \end{codeexample} -The following example is adapted from code written by Kjell Magne -Fauske, which is based on the following paper: K.~Bossley, M.~Brown, -and C.~Harris, Neurofuzzy identification of an autonomous underwater -vehicle, \emph{International Journal of Systems Science}, 1999, 30, 901--913. - +The following example is adapted from code written by Kjell Magne Fauske, which +is based on the following paper: K.~Bossley, M.~Brown, and C.~Harris, +Neurofuzzy identification of an autonomous underwater vehicle, +\emph{International Journal of Systems Science}, 1999, 30, 901--913. +% \begin{codeexample}[] \begin{tikzpicture} [auto, @@ -740,6 +732,7 @@ vehicle, \emph{International Journal of Systems Science}, 1999, 30, 901--913. \end{codeexample} } + %%% Local Variables: %%% mode: latex %%% TeX-master: "pgfmanual" |