diff options
Diffstat (limited to 'Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-actions.tex')
-rw-r--r-- | Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-actions.tex | 473 |
1 files changed, 302 insertions, 171 deletions
diff --git a/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-actions.tex b/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-actions.tex index 50aa70a3af2..c80846dcd85 100644 --- a/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-actions.tex +++ b/Master/texmf-dist/doc/generic/pgf/text-en/pgfmanual-en-tikz-actions.tex @@ -45,7 +45,7 @@ expands to the first line of the above example. Similarly, |\fill| is an abbreviation for |\path[fill]| and |\filldraw| is an abbreviation for the command |\path[fill,draw]|. Since options accumulate, the following commands -all have the same effect: +all have the same effect: \begin{codeexample}[code only] \path [draw,fill] (0,0) circle (1cm); \path [draw] [fill] (0,0) circle (1cm); @@ -106,7 +106,7 @@ The most unspecific option for setting colors is the following: The \meta{color name} is the name of a previously defined color. For \LaTeX\ users, this is just a normal ``\LaTeX-color'' and the - |xcolor| extensions are allows. Here is an example: + |xcolor| extensions are allowed. Here is an example: \begin{codeexample}[] \tikz \fill[color=red!20] (0,0) circle (1ex); @@ -128,7 +128,7 @@ The most unspecific option for setting colors is the following: to do the following: \begin{itemize} \item Specify a new color using |\definecolor|. Only the two color - models |gray| and |rgb| are supported. + models |gray| and |rgb| are supported\footnote{Con\TeX t users should be aware that \texttt{\textbackslash definecolor} has a different meaning in Con\TeX t. There is a low-level equivalent named \texttt{\textbackslash pgfutil@definecolor} which can be used instead.}.% \example |\definecolor{orange}{rgb}{1,0.5,0}| \item Use |\colorlet| to define a new color based on an old one. Here, the |!| mechanism is supported, though only ``once'' @@ -169,7 +169,7 @@ You can draw a path using the following option: If the special color name |none| is given, this option causes drawing to be ``switched off.'' This is useful if a style has previously switched on drawing and you locally wish to undo this - effect. + effect. Although this option is normally used on paths to indicate that the path should be drawn, it also makes sense to use the option with a @@ -203,7 +203,7 @@ how a path is drawn. All of these options only have an effect if the There are a number of predefined styles that provide more ``natural'' ways of setting the line width. You can also redefine these -styles. +styles. \begin{stylekey}{/tikz/ultra thin} Sets the line width to 0.1pt. @@ -279,8 +279,8 @@ styles. \begin{codeexample}[] \begin{tikzpicture}[line width=10pt] \draw[line join=round] (0,0) -- ++(.5,1) -- ++(.5,-1); - \draw[line join=bevel] (1.25,0) -- ++(.5,1) -- ++(.5,-1); - \draw[line join=miter] (2.5,0) -- ++(.5,1) -- ++(.5,-1); + \draw[line join=bevel] (1.25,0) -- ++(.5,1) -- ++(.5,-1); + \draw[line join=miter] (2.5,0) -- ++(.5,1) -- ++(.5,-1); \useasboundingbox (0,1.5); % make bounding box bigger \end{tikzpicture} \end{codeexample} @@ -288,9 +288,9 @@ styles. \begin{key}{/tikz/miter limit=\meta{factor} (initially 10)} When you use the miter join and there is a very sharp corner (a small angle), the miter join may protrude very far over the actual - joining point. In this case, if it were to protrude by + joining point. In this case, if it were to protrude by more than \meta{factor} times the line width, the miter join is - replaced by a bevel join. + replaced by a bevel join. \begin{codeexample}[] \begin{tikzpicture}[line width=5pt] @@ -309,7 +309,7 @@ styles. \textsc{metafont}. For example following pattern |on 2pt off 3pt on 4pt off 4pt| means ``draw 2pt, then leave out 3pt, then draw 4pt once more, then leave out 4pt - again, repeat''. + again, repeat''. \begin{codeexample}[] \begin{tikzpicture}[dash pattern=on 2pt off 3pt on 4pt off 4pt] @@ -389,6 +389,56 @@ dashing conveniently. \end{stylekey} +\begin{stylekey}{/tikz/dashdotted} + Shorthand for setting a dashed and dotted dash pattern. + +\begin{codeexample}[] +\tikz \draw[dashdotted] (0pt,0pt) -- (50pt,0pt); +\end{codeexample} +\end{stylekey} + +\begin{stylekey}{/tikz/densely dashdotted} + Shorthand for setting a densely dashed and dotted dash pattern. + +\begin{codeexample}[] +\tikz \draw[densely dashdotted] (0pt,0pt) -- (50pt,0pt); +\end{codeexample} +\end{stylekey} + +\begin{stylekey}{/tikz/loosely dashdotted} + Shorthand for setting a loosely dashed and dotted dash pattern. + +\begin{codeexample}[] +\tikz \draw[loosely dashdotted] (0pt,0pt) -- (50pt,0pt); +\end{codeexample} +\end{stylekey} + + +\begin{stylekey}{/tikz/dashdotdotted} + Shorthand for setting a dashed and dotted dash pattern with more dots. + +\begin{codeexample}[] +\tikz \draw[dashdotdotted] (0pt,0pt) -- (50pt,0pt); +\end{codeexample} +\end{stylekey} + +\begin{stylekey}{/tikz/densely dashdotdotted} + Shorthand for setting a densely dashed and dotted dash pattern with more dots. + +\begin{codeexample}[] +\tikz \draw[densely dashdotdotted] (0pt,0pt) -- (50pt,0pt); +\end{codeexample} +\end{stylekey} + +\begin{stylekey}{/tikz/loosely dashdotdotted} + Shorthand for setting a loosely dashed and dotted dash pattern with more dots. + +\begin{codeexample}[] +\tikz \draw[loosely dashdotdotted] (0pt,0pt) -- (50pt,0pt); +\end{codeexample} +\end{stylekey} + + \subsubsection{Graphic Parameters: Draw Opacity} When a line is drawn, it will normally ``obscure'' everything behind @@ -426,14 +476,14 @@ and may change in the future. The permissible values are all predefined arrow tips, though you can also define new arrow tip kinds as explained in Section~\ref{section-arrows}. This is often necessary to obtain - ``double'' arrow tips and arrow tips that have a fixed size. Since - |pgflibraryarrows| is loaded by default, all arrow tips described in - Section~\ref{section-library-arrows} are available. + ``double'' arrow tips and arrow tips that have a fixed size. You + need to load the |arrows| library if you need arrow tips other than + the default ones, see Section~\ref{section-library-arrows}. One arrow tip kind is special: |>| (and all arrow tip kinds containing the - arrow tip kind such as |<<| or \verb!>|!). This arrow tip type is not + arrow tip kind such as |<<| or \verb!>|!). This arrow tip type is not fixed. Rather, you can redefine it using the |>=| option, see - below. + below. \example You can also combine arrow tip types as in \begin{codeexample}[] @@ -469,16 +519,16 @@ and may change in the future. \begin{tikzpicture}[scale=2] \begin{scope}[>=latex] \draw[->] (0pt,6ex) -- (1cm,6ex); - \draw[>->>] (0pt,5ex) -- (1cm,5ex); + \draw[>->>] (0pt,5ex) -- (1cm,5ex); \draw[|<->|] (0pt,4ex) -- (1cm,4ex); \end{scope} \begin{scope}[>=diamond] \draw[->] (0pt,2ex) -- (1cm,2ex); \draw[>->>] (0pt,1ex) -- (1cm,1ex); \draw[|<->|] (0pt,0ex) -- (1cm,0ex); - \end{scope} + \end{scope} \end{tikzpicture} -\end{codeexample} +\end{codeexample} % << \end{key} @@ -545,7 +595,7 @@ and may change in the future. \begin{key}{/tikz/double distance=\meta{dimension} (initially 0.6pt)} Sets the distance the ``two'' lines are spaced apart. In reality, - this is the thickness of the line that is used + this is the thickness of the line that is used to draw the path for the second time. The thickness of the \emph{first} time the path is drawn is twice the normal line width plus the given \meta{dimension}. As a side-effect, this option @@ -560,8 +610,48 @@ and may change in the future. \end{codeexample} \end{key} +\begin{key}{/tikz/double distance between line centers=\meta{dimension}} + This option works like |double distance|, only the distance is not + the distance between (inner) borders of the two main lines, ut + between their centers. Thus, the thickness the + \emph{first} time the path is drawn is the normal line width + plus the given \meta{dimension}, while the line width of the + \emph{second} line that is drawn is \meta{dimension} minus the + normal line width. As a side-effect, this option ``selects'' the + |double| option. + +\begin{codeexample}[] +\begin{tikzpicture}[double distance between line centers=3pt] + \foreach \lw in {0.5,1,1.5,2,2.5} + \draw[line width=\lw pt,double] (\lw,0) -- ++(4mm,0); +\end{tikzpicture} +\end{codeexample} +\begin{codeexample}[] +\begin{tikzpicture}[double distance=3pt] + \foreach \lw in {0.5,1,1.5,2,2.5} + \draw[line width=\lw pt,double] (\lw,0) -- ++(4mm,0); +\end{tikzpicture} +\end{codeexample} +\end{key} + +\begin{stylekey}{/tikz/double equal sign distance} + This style selects a double line distance such that it corresponds + to the distance of the two lines in an equal sign. +\begin{codeexample}[] +\Huge $=\implies$\tikz[baseline,double equal sign distance] + \draw[double,thick,-implies](0,0.55ex) --++(3ex,0); +\end{codeexample} +\begin{codeexample}[] +\normalsize $=\implies$\tikz[baseline,double equal sign distance] + \draw[double,-implies](0,0.6ex) --++(3ex,0); +\end{codeexample} +\begin{codeexample}[] +\tiny $=\implies$\tikz[baseline,double equal sign distance] + \draw[double,very thin,-implies](0,0.5ex) -- ++(3ex,0); +\end{codeexample} +\end{stylekey} + - @@ -597,7 +687,7 @@ To fill a path, use the following option: is used), the path is filled \emph{first}, then the path is drawn \emph{second}. This is especially useful if different colors are selected for drawing and for filling. Even if the same color is - used, there is a difference between this command and a plain + used, there is a difference between this command and a plain |fill|: A ``filldrawn'' area will be slightly larger than a filled area because of the thickness of the ``pen.'' @@ -622,12 +712,12 @@ that contains a simple picture like a star. Then these tiles are (conceptually) repeated infinitely in all directions, but clipped against the path. -Tiling patterns come in two variants: \emph{inherently +Tiling patterns come in two variants: \emph{inherently colored patterns} and \emph{form-only patterns}. An inherently colored pattern is, say, a red star with a black border and will always look like this. A form-only pattern may have a different color each time it is used, only the form of the pattern will stay the same. As such, -form-only patterhns do not have any colors of their own, but when it +form-only patterns do not have any colors of their own, but when it is used the current \emph{pattern color} is used as its color. Patterns are not overly flexible. In particular, it is not possible to @@ -646,10 +736,10 @@ pattern. For complicated case, it may be easier to use two nested fill color will fill the path with a solid color once more. Strangely, no \meta{name}s are permissible by default. You need to - load for instance |pgflibrarypatterns|, see + load for instance the |patterns| library, see Section~\ref{section-library-patterns}, to install predefined - patterns. - + patterns. + \begin{codeexample}[] \begin{tikzpicture} \draw[pattern=dots] (0,0) circle (1cm); @@ -660,8 +750,8 @@ pattern. For complicated case, it may be easier to use two nested \begin{key}{/tikz/pattern color=\meta{color}} This option is used to set the color to be used for form-only - patterns. This option has no effect on inherently colored patterns. - + patterns. This option has no effect on inherently colored patterns. + \begin{codeexample}[] \begin{tikzpicture} \draw[pattern color=red,pattern=fivepointed stars] (0,0) circle (1cm); @@ -718,7 +808,7 @@ should be determined: \draw[->] (0,1) -- (.4,1); \draw[->] (0.25,0.75) -- (0.4,.75); - + \draw[->] (0.5,0.5) -- +(0,1) node[above] {crossings: $1+1 = 2$}; \end{scope} \end{tikzpicture} @@ -736,7 +826,7 @@ should be determined: and declare the point to be ``inside'' if the number of hits is odd. Using the even-odd rule, it is easy to ``drill holes'' into a path. - + \begin{codeexample}[] \begin{tikzpicture} \filldraw[fill=examplefill,even odd rule] @@ -753,7 +843,94 @@ should be determined: \label{section-fill-opacity} Analogously to the |draw opacity|, you can also set the filling opacity. Please see Section~\ref{section-tikz-transparency} for more -details. +details. + + +\subsection{Generalized Filling: Using Arbitrary Pictures to Fill a Path} + +Sometimes you wish to ``fill'' a path with something even more +complicated than a pattern, let alone a single color. For instance, +you might wish to use an image to fill the path or some other, +complicated drawing. In principle, this effect can be achieved +by first using the path for clipping and then, subsequently, drawing +the desired image or picture. However, there is an option that makes +this process much easier: + +\begin{key}{/tikz/path picture=\meta{code}} + When this option is given on a path and when the \meta{code} is not + empty, the following happens: After all other ``filling'' operations + are done with the path, which are caused by the options |fill|, + |pattern| and |shade|, a local scope is opened and the path is + temporarily installed as a clipping path. Then, the \meta{code} is + executed, which can now draw something. Then, the local scope ends + and, possibly, the path is stroked, provided the |draw| option has + been given. + + As with other keys like |fill| or |draw| this option needs to be + given on a path, setting the |path picture| outside a path has not + effect (the path picture is cleared at the beginning of each path). + + The \meta{code} can be any normal \tikzname\ code like |\draw ...| + or |\node ...|. As always, when you include an external graphic you + need to put it inside a |\node|. + + Note that no special actions are taken to transform the origin in + any way. This means that the coordinate |(0,0)| is still where is + was when the path was being constructed and not -- as one might + expect -- at the lower left corner of the path. However, you can use + the following special node to access the size of the path: + \begin{predefinednode}{path picture bounding box} + This node is of shape |rectangle|. Its size and position are those + of |current path bounding box| just before the \meta{code} + of the path picture started to be executed. The \meta{code} can + construct its own paths, so accessing the + |current path bounding box| inside the \meta{code} yields the + bounding box of any path that is currently being constructed + inside the \meta{code}. + \end{predefinednode} + +\begin{codeexample}[] +\begin{tikzpicture} + \draw [help lines] (0,0) grid (3,2); + \filldraw [fill=blue!10,draw=blue,thick] (1.5,1) circle (1) + [path picture={ + \node at (path picture bounding box.center) { + This is a long text. + };} + ]; +\end{tikzpicture} +\end{codeexample} + +\begin{codeexample}[] +\begin{tikzpicture}[cross/.style={path picture={ + \draw[black] + (path picture bounding box.south east) -- + (path picture bounding box.north west) + (path picture bounding box.south west) -- + (path picture bounding box.north east); + }}] + \draw [help lines] (0,0) grid (3,2); + \filldraw [cross,fill=blue!10,draw=blue,thick] (1,1) circle (1); + \path [cross,top color=red,draw=red,thick] (2,0) -- (3,2) -- (3,0); +\end{tikzpicture} +\end{codeexample} + +\begin{codeexample}[] + \begin{tikzpicture}[path image/.style={ + path picture={ + \node at (path picture bounding box.center) { + \includegraphics[height=3cm]{#1} + };}}] + \draw [help lines] (0,0) grid (3,2); + + \draw [path image=brave-gnu-world-logo,draw=blue,thick] + (0,1) circle (1); + \draw [path image=brave-gnu-world-logo,draw=red,very thick,->] + (1,0) parabola[parabola height=2cm] (3,0); + +\end{tikzpicture} +\end{codeexample} +\end{key} \subsection{Shading a Path} @@ -791,9 +968,6 @@ path is temporarily used for clipping and then the rectangular shading is drawn, scaled and shifted such that all parts of the path are filled. - -\subsubsection{Choosing a Shading Type} - The default shading is a smooth transition from gray to white and from above to bottom. However, other shadings are also possible, for example a shading that will sweep a color from the @@ -805,44 +979,27 @@ needed, which are explained below. \begin{key}{/tikz/shading=\meta{name}} This selects a shading named \meta{name}. The following shadings are - predefined: - \begin{itemize} - \item \declare{|axis|} - This is the default shading in which the color changes gradually - between three horizontal lines. The top line is at the top - (uppermost) point of the path, the middle is in the middle, the - bottom line is at the bottom of the path. - + predefined: |axis|, |radial|, and |ball|. \begin{codeexample}[] \tikz \shadedraw [shading=axis] (0,0) rectangle (1,1); -\end{codeexample} - - The default top color is gray, the default bottom color is white, - the default middle is the ``middle'' of these two. - \item \declare{|radial|} - This shading fills the path with a gradual sweep from a certain - color in the middle to another color at the border. If the path is - a circle, the outer color will be reached exactly at the - border. If the shading is not a circle, the outer color will - continue a bit towards the corners. The default inner color is - gray, the default outer color is white. - -\begin{codeexample}[] \tikz \shadedraw [shading=radial] (0,0) rectangle (1,1); +\tikz \shadedraw [shading=ball] (0,0) circle (.5cm); \end{codeexample} - \item \declare{|ball|} - This shading fills the path with a shading that ``looks like a - ball.'' The default ``color'' of the ball is blue (for no - particular reason). -\begin{codeexample}[] -\tikz \shadedraw [shading=ball] (0,0) rectangle (1,1); -\end{codeexample} + The shadings as well as additional shadings are described in more + detail in Section~\ref{section-library-shadings}. + To change the color of a shading, special options are needed like + |left color|, which sets the color of an axis shading from left to + right. These options implicitly also select the right shading type, + see the following example \begin{codeexample}[] -\tikz \shadedraw [shading=ball] (0,0) circle (.5cm); +\tikz \shadedraw [left color=red,right color=blue] + (0,0) rectangle (1,1); \end{codeexample} - \end{itemize} + + For a complete list of the possible options see + Section~\ref{section-library-shadings} once more. \begin{key}{/tikz/shading angle=\meta{degrees} (initially 0)} This option rotates the shading (not the path!) by the given @@ -862,101 +1019,6 @@ filling paths are given in Section~\ref{section-shading-a-path}. -\subsubsection{Choosing a Shading Color} - -The following options can be used to change the colors used for -shadings. When one of these options is given, the |shade| option is -automatically selected and also the ``right'' shading. - -\begin{key}{/tikz/top color=\meta{color}} - This option prescribes the color to be used at the top in an |axis| - shading. When this option is given, several things happen: - \begin{enumerate} - \item - The |shade| option is selected. - \item - The |shading=axis| option is selected. - \item - The middle color of the axis shading is set to the average of the - given top color \meta{color} and of whatever color is currently - selected for the bottom. - \item - The rotation angle of the shading is set to 0. - \end{enumerate} - -\begin{codeexample}[] -\tikz \draw[top color=red] (0,0) rectangle (2,1); -\end{codeexample} -\end{key} - -\begin{key}{/tikz/bottom color=\meta{color}} - This option works like |top color|, only for the bottom color. -\end{key} - -\begin{key}{/tikz/middle color=\meta{color}} - This option specifies the color for the middle of an axis - shading. It also sets the |shade| and |shading=axis| options, but it - does not change the rotation angle. - - \emph{Note:} Since both |top color| and |bottom color| change the - middle color, this option should be given \emph{last} if all of - these options need to be given: - -\begin{codeexample}[] -\tikz \draw[top color=white,bottom color=black,middle color=red] - (0,0) rectangle (2,1); -\end{codeexample} -\end{key} - -\begin{key}{/tikz/left color=\meta{color}} - This option does exactly the same as |top color|, except that the - shading angle is set to $90^\circ$. -\end{key} - -\begin{key}{/tikz/right color=\meta{color}} - Works like |left color|. -\end{key} - -\begin{key}{/tikz/inner color=\meta{color}} - This option sets the color used at the center of a |radial| - shading. When this option is used, the |shade| and |shading=radial| - options are set. - -\begin{codeexample}[] -\tikz \draw[inner color=red] (0,0) rectangle (2,1); -\end{codeexample} -\end{key} - -\begin{key}{/tikz/outer color=\meta{color}} - This option sets the color used at the border and outside of a - |radial| shading. - -\begin{codeexample}[] -\tikz \draw[outer color=red,inner color=white] - (0,0) rectangle (2,1); -\end{codeexample} -\end{key} - - -\begin{key}{/tikz/ball color=\meta{color}} - This option sets the color used for the ball shading. It sets the - |shade| and |shading=ball| options. Note that the ball will never - ``completely'' have the color \meta{color}. At its ``highlight'' spot - a certain amount of white is mixed in, at the border a certain - amount of black. Because of this, it also makes sense to say - |ball color=white| or |ball color=black| - -\begin{codeexample}[] -\begin{tikzpicture} - \shade[ball color=white] (0,0) circle (2ex); - \shade[ball color=red] (1,0) circle (2ex); - \shade[ball color=black] (2,0) circle (2ex); -\end{tikzpicture} -\end{codeexample} -\end{key} - - - \subsection{Establishing a Bounding Box} \pgfname\ is reasonably good at keeping track of the size of your picture @@ -973,7 +1035,8 @@ a shorthand for |\path[use as bounding box]|. the size of all \emph{subsequent} paths are ignored. However, if there were previous path operations that have already established a larger bounding box, it will not be made - smaller by this operation. + smaller by this operation (consider the |\pgfresetboundingbox| command + to reset the previous bounding box). In a sense, |use as bounding box| has the same effect as clipping all subsequent drawing against the current path---without actually @@ -992,7 +1055,7 @@ Left of picture\begin{tikzpicture} In a second application this option can be used to get better control over the white space around the picture: - + \begin{codeexample}[] Left of picture \begin{tikzpicture} @@ -1005,15 +1068,18 @@ right of picture. Note: If this option is used on a path inside a \TeX\ group (scope), the effect ``lasts'' only till the end of the scope. Again, this behavior is the same as for clipping. + + + Consider using |\useasboundingbox| together with |\pgfresetboundingbox| in order to replace the bounding box with a new one. \end{key} There is a node that allows you to get the size of the current bounding box. The |current bounding box| node has the |rectangle| -shape and its size is always the size of the current +shape and its size is always the size of the current bounding box. Similarly, the |current path bounding box| node has the |rectangle| -hape and the size of the bounding box of the current path. +shape and the size of the bounding box of the current path. \begin{codeexample}[] @@ -1032,6 +1098,72 @@ hape and the size of the bounding box of the current path. \end{codeexample} +Occasionally, you may want to align multiple |tikzpicture| environments horizontally and/or vertically at some prescribed position. The vertical alignment can be realized by means of the |baseline| option since \TeX\ supports the concept of box depth natively. For horizontal alignment, things are slightly more involved. The following approach is realized by means of negative |\hspace|s before and/or after the picture, thereby removing parts of the picture. However, the actual amount of negative horizontal space is provided by means of image coordinates using the |trim left| and |trim right| keys: + +\begin{key}{/tikz/trim left=\meta{dimension or coordinate or \texttt{default}} (default 0pt)} + The |trim left| key tells \pgfname\space to discard everything which is left of the provided \meta{dimension or coordinate}. Here, \meta{dimension} is a single $x$ coordinate of the picture and \meta{coordinate} is a point with $x$ and $y$ coordinates (but only its $x$ coordinate will be used). The effect is the same as if you issue |\hspace{-s}| where |s| is the difference of the picture's bounding box lower left $x$ coordinate and the $x$ coordinate specified as \meta{dimension or coordinate}: +\begin{codeexample}[] +Text before image.% + \begin{tikzpicture}[trim left] + \draw (-1,-1) grid (3,2); + \fill (0,0) circle (5pt); + \end{tikzpicture}% +Text after image. +\end{codeexample} + Since |trim left| uses the default |trim left=0pt|, everything left of $x=0$ is removed from the bounding box. + + The following example has once the relative long label $-1$ and once the shorter label $1$. Horizontal alignment is established with |trim left|: +\begin{codeexample}[pre={\vbox\bgroup\hsize=5cm},post=\egroup,width=8cm] +\begin{tikzpicture} + \draw (0,1) -- (0,0) -- (1,1) -- cycle; + \fill (0,0) circle (2pt); + \node[left] at (0,0) {$-1$}; +\end{tikzpicture} +\par +\begin{tikzpicture} + \draw (0,1) -- (0,0) -- (1,1) -- cycle; + \fill (0,0) circle (2pt); + \node[left] at (0,0) {$1$}; +\end{tikzpicture} +\par +\begin{tikzpicture}[trim left] + \draw (0,1) -- (0,0) -- (1,1) -- cycle; + \fill (0,0) circle (2pt); + \node[left] at (0,0) {$-1$}; +\end{tikzpicture} +\par +\begin{tikzpicture}[trim left] + \draw (0,1) -- (0,0) -- (1,1) -- cycle; + \fill (0,0) circle (2pt); + \node[left] at (0,0) {$1$}; +\end{tikzpicture} +\end{codeexample} + + Use |trim left=default| to reset the value. +\end{key} + +\begin{key}{/tikz/trim right=\meta{dimension or coordinate or \texttt{default}}} + This key is similar to |trim left|: it discards everything which is right of the provided \meta{dimension or coordinate}. As for |trim left|, \meta{dimension} denotes a single $x$ coordinate of the picture and \meta{coordinate} a coordinate with $x$ and $y$ value (although only its $x$ component will be used). + + We use the same example from above and add |trim right|: +\begin{codeexample}[] +Text before image.% + \begin{tikzpicture}[trim left, trim right=2cm, baseline] + \draw (-1,-1) grid (3,2); + \fill (0,0) circle (5pt); + \end{tikzpicture}% +Text after image. +\end{codeexample} + In addition to |trim left=0pt|, we also discard everything which is right of $x$|=2cm|. Furthermore, the |baseline| key supports vertical alignment as well (using the $y$|=0cm| baseline). + + Use |trim right=default| to reset the value. +\end{key} + +Note that |baseline|, |trim left| and |trim right| are currently the \emph{only} supported way of truncated bounding boxes which are compatible with image externalization (see the |external| library for details). + +\begin{key}{/pgf/trim lowlevel=\mchoice{true,false} (initially false)} + This affects only the basic level image externalization: the initial configuration |trim lowlevel=false| stores the normal image, without trimming, and the trimming into a separate file. This allows reduced bounding boxes without clipping the rest away. The |trim lowlevel=true| information causes the image externalization to store the trimmed image, possibly resulting in clipping. +\end{key} \subsection{Clipping and Fading (Soft Clipping)} @@ -1071,7 +1203,7 @@ transparency in general. \end{codeexample} It is usually a \emph{very} good idea to apply the |clip| option only - to the first path command in a scope. + to the first path command in a scope. If you ``only wish to clip'' and do not wish to draw anything, you can use the |\clip| command, which is a shorthand for |\path[clip]|. @@ -1094,7 +1226,7 @@ transparency in general. \draw (0,0) -- (30:1cm); \begin{scope}[fill=red] \fill[clip] (0.2,0.2) rectangle (0.5,0.5); - + \draw (0,0) -- (40:1cm); \draw (0,0) -- (50:1cm); \draw (0,0) -- (60:1cm); @@ -1110,8 +1242,8 @@ transparency in general. code we could not have moved the |fill=red| to the |\fill| command. The reasons for this have to do with the internals of the \pdf\ specification. You do not want to know the details. It is best - simply not to specify any options for these - commands. + simply not to specify any options for these + commands. \end{key} @@ -1187,7 +1319,7 @@ options: In the following example, we use one |preaction| to add a shadow and another to provide a shading, while the main action is to use a - pattern. + pattern. \begin{codeexample}[] \begin{tikzpicture} \draw[help lines] (0,0) grid (3,2); @@ -1262,7 +1394,7 @@ options: \end{tikzpicture} \end{codeexample} - In another example, we use a postaction to ``colorzie'' a path: + In another example, we use a postaction to ``colorize'' a path: \begin{codeexample}[] \begin{tikzpicture} @@ -1287,7 +1419,7 @@ that slightly varied. Such morphings are a special case of the more general ``decorations'' described in detail in Section~\ref{section-tikz-decorations}. For instance, in the following example the path is drawn twice: Once normally and then in a morphed -(=decorated) manner. +(=decorated) manner. \begin{codeexample}[] \begin{tikzpicture} \draw (0,0) rectangle (3,2); @@ -1305,4 +1437,3 @@ pre- or postaction. It is also possible to deform shapes: fill=blue!20,draw,thick,circle] {Hello!}; \end{tikzpicture} \end{codeexample} - |