Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor manual improvements #872

Merged
merged 9 commits into from
Jun 15, 2020
22 changes: 22 additions & 0 deletions doc/generic/pgf/text-en/pgfmanual-en-library-decorations.tex
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,28 @@ \subsection{Overview and Common Options}
\end{key}


\subsection{Handling ``Dimension too large'' errors}

In case you should run into a ``Dimension too large error'' when using the
|decorations| libraries, there is a pretty high chance that you can resolve
this by using the |fpu| library in combination with
|/pgf/fpu/install only={reciprocal}|. Please note that this key should only be
applied locally to avoid other errors (see also at the definition of this key
on page~\pageref{fpu-install-only}).
%
\begin{codeexample}[preamble={\usetikzlibrary{decorations.markings,fpu}}]
\begin{tikzpicture}
\begin{scope}[/pgf/fpu/install only={reciprocal}]
\draw[postaction=decorate,decoration={
markings,mark=at position 0.52 with {
\draw circle[radius=2pt];
}},
] plot[smooth,variable=\x,domain=-1:1] (\x*\x*\x,\x*\x);
\end{scope}
\end{tikzpicture}
\end{codeexample}


\subsection{Path Morphing Decorations}

\begin{pgflibrary}{decorations.pathmorphing}
Expand Down
33 changes: 19 additions & 14 deletions doc/generic/pgf/text-en/pgfmanual-en-library-fpu.tex
Original file line number Diff line number Diff line change
Expand Up @@ -148,25 +148,30 @@ \subsection{Usage}
\end{command}

\begin{key}{/pgf/fpu/install only=\marg{list of names}}
\label{fpu-install-only}
Unfortunately, the FPU is currently incompatible with drawing operations.
However, it can still be useful to replace single definitions with FPU
counterparts to avoid errors of the kind |Dimension too large| which tend to
happen when transformation matrices are inverted.
counterparts to avoid errors of the kind |Dimension too large| which tend
to happen when transformation matrices are inverted.

This key allows to specify a list of definitions to be pulled into the current
scope. \emph{Note that there is no reverse operation to uninstall these
definitions at the moment}, so it is advisable to do this in a group.
Conveniently, \tikzname\ paths form an implicit group, so you can use this key
on a path as well.
This key allows to specify a list of definitions to be pulled into the
current scope. \emph{Note that there is no reverse operation to uninstall
these definitions at the moment}, so it is advisable to do this in a group.
Conveniently, \tikzname{} paths form an implicit group, so you can use this
key on a path as well.

You have to be aware of the limitations that the FPU imposes. It will not
magically give TeX better precision, but it will avoid overflow or underflow
situation for large or small operands by rescaling them. In the following
example, in the first case the FPU variant performs much better than the
normal variant, however, in the second case where a rescaling would not in
fact be needed the rescaling introduces a small round-off error.
%
\begin{codeexample}[preamble={\usepgflibrary{fpu}},pre={\pgfkeys{/pgf/fpu=false}}]
magically give \TeX{} better precision, but it will avoid overflow or
underflow situations for large or small operands by rescaling them. In the
following example, in the first case the FPU variant performs much better
than the normal variant, however, in the second case where a rescaling
would not in fact be needed the rescaling introduces a small round-off
error.
%
\begin{codeexample}[
preamble={\usepgflibrary{fpu}},
pre={\pgfkeys{/pgf/fpu=false}},
]
\begingroup
\pgfkeys{/pgf/fpu/install only={divide}}
\pgfmathparse{12.34/0.001234}\pgfmathresult (good)
Expand Down
3 changes: 2 additions & 1 deletion doc/generic/pgf/text-en/pgfmanual-en-library-matrices.tex
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ \section{Matrix Library}

\begin{tikzlibrary}{matrix}
This library package defines additional styles and options for creating
matrices.
matrices. The basic matrix styles and options can be found in
Section~\ref{section-matrices}.
\end{tikzlibrary}


Expand Down
35 changes: 17 additions & 18 deletions doc/generic/pgf/text-en/pgfmanual-en-tikz-matrices.tex
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ \subsubsection{Cell Styles and Options}
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}.
\end{stylekey}
Expand Down Expand Up @@ -485,7 +485,7 @@ \subsubsection{Cell Styles and Options}
\begin{codeexample}[preamble={\usetikzlibrary{matrix,shapes.misc}}]
\begin{tikzpicture}
[mycol/.style={column #1/.append style={
every even row/.style={nodes={fill=gray!10}}}
every even row/.style={nodes={fill=gray!20}}}
}]

\matrix [matrix of nodes, nodes in empty cells,
Expand All @@ -494,11 +494,11 @@ \subsubsection{Cell Styles and Options}
mycol/.list={1,...,5}, % add mycol style to all cols
column 1/.style={
row 1 column 1/.style={nodes={fill=none, draw=none}},
nodes={fill=yellow, chamfered rectangle, inner sep=0,
nodes={fill=yellow!75!black, chamfered rectangle, inner sep=0,
chamfered rectangle corners={north west, south east}},
},
row 1/.style={nodes={text depth=0.2ex, text width=2cm, text=white}},
column 2/.append style={row 1/.append style={nodes={fill=green}}},
column 2/.append style={row 1/.append style={nodes={fill=green!75!black}}},
column 3/.append style={every even row/.style={nodes={fill=red!10}},
row 1 column 3/.append style={nodes={fill=red}}
},
Expand All @@ -521,7 +521,6 @@ \subsubsection{Cell Styles and Options}
\end{tikzpicture}
\end{codeexample}


The order in which these styles are applied is configurable. You can also
install your own styles. The following styles (in fact, internally they are
|/.code| keys) wrap the styles introduced in the previous paragraph passing the
Expand All @@ -543,14 +542,14 @@ \subsubsection{Cell Styles and Options}
\begin{stylekey}{/tikz/matrix/inner style/even odd row}
Wraps |/tikz/every even row| and |/tikz/every odd row|.
\end{stylekey}
\begin{stylekey}{/tikz/matrix/inner style/this cell}
\begin{stylekey}{/tikz/matrix/inner style/cell}
Wraps |/tikz/row |\meta{number}| column |\meta{number}.
\end{stylekey}

\begin{stylekey}{/tikz/matrix/inner style order}
The order in which these styles are applied to the matrix cells is specified
by this key. By default it is
%
The order in which these styles are applied to the matrix cells is
specified by this key. By default it is
%
\begin{codeexample}[code only]
\tikzset{
matrix/inner style order={
Expand All @@ -559,16 +558,16 @@ \subsubsection{Cell Styles and Options}
even odd column,
row,
even odd row,
this cell
cell
}
}
\end{codeexample}
%
You can use this to install your own styles here, but only \emph{names} of
styles are permitted here. The style specification has to be placed
outside of |matrix/inner style order| and unless it is installed inside
|/tikz/matrix/inner style/|, it has to be fully qualified.
%
%
You can use this to install your own styles here, but only \emph{names} of
styles are permitted here. The style specification has to be placed
outside of |matrix/inner style order| and unless it is installed inside
|/tikz/matrix/inner style/|, it has to be fully qualified.
%
\begin{codeexample}[code only]
\tikzset{
my style/.code={%
Expand All @@ -582,12 +581,12 @@ \subsubsection{Cell Styles and Options}
even odd row,
column,
row,
this cell,
cell,
/tikz/my style
}
}
\end{codeexample}
%
%
\end{stylekey}

In many matrices all cell pictures have nearly the same code. For example,
Expand Down
4 changes: 2 additions & 2 deletions doc/generic/pgf/text-en/pgfmanual-en-tikz-shapes.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1708,11 +1708,11 @@ \subsubsection{Advanced Placement Options}
\end{key}


\subsubsection{Advanced Arrangements of Nodes}
\subsubsection{Advanced Arrangements of Nodes}

The simple |above| and |right| options may not always suffice for arranging a
large number of nodes. For such situations \tikzname\ offers libraries that
make positioning easier: The |graphdrawing| library and the |matrix| library.
make positioning easier: The |matrix| library and the |graphdrawing| library.
These libraries for positioning nodes are described in two separate
Sections~\ref{section-matrices} and~\ref{section-intro-gd}.

Expand Down
12 changes: 8 additions & 4 deletions tex/generic/pgf/frontendlayer/tikz/tikz.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -4023,7 +4023,7 @@
\tikzset{every even row/.try}%
\fi
},
matrix/inner style/this cell/.code={%
matrix/inner style/cell/.code={%
\tikzset{row \the\pgfmatrixcurrentrow\space column \the\pgfmatrixcurrentcolumn/.try}%
},
matrix/inner style order/.store in=\tikz@common@matrix@code@styleorder,
Expand All @@ -4033,7 +4033,7 @@
even odd column,
row,
even odd row,
this cell
cell
},
}%

Expand Down Expand Up @@ -4089,8 +4089,12 @@
\let\tikz@options=\pgfutil@empty%
\let\tikz@mode=\pgfutil@empty%
\pgfutil@for\pgf@temp:=\tikz@common@matrix@code@styleorder\do{%
\expandafter\def\expandafter\pgf@temp\expandafter{\romannumeral-`0\expandafter\pgfutil@trimspaces\expandafter{\pgf@temp}}%
\pgfutil@ifempty\pgf@temp{}{\expandafter\tikzset\expandafter{matrix/inner style/.cd,\pgf@temp/.try}}%
\toks0=\expandafter{\romannumeral-`0\expandafter\pgfutil@trimspaces\expandafter{\pgf@temp}}%
\def\pgf@marshal{}%
\pgfutil@ifempty\pgf@temp{}{%
\edef\pgf@marshal{\noexpand\tikzset{matrix/inner style/.cd,\the\toks0}}%
}%
\pgf@marshal
}%
\tikz@options%
}%
Expand Down