3

The entry for the /tikz/trim left option on pp. 176-177 of the TikZ & PGF manual for version 3.0.1a states (in the end of the option's description, on p. 177):

Use trim left = default to reset the value.

Why would anyone want to reset the value of the trim left option? If I understand correctly, (1) this option applies to the entire \tikzpicture environment, and (2) like every other option it has local effect.

Fact #1 implies that there is no sense in having more than one trim left option in a given environment, and therefore if you find yourself wishing to reset this value, which you had set previously in the current tikzpicture environment, you can simply avoid using this option to begin with.

Fact #2 implies that the value of the trim left option is automatically reset in every following \tikzpicture environment.

So what's the point in writing trim left = default? Can anyone please give an example where this feature is put to sensible use?


A tikz/trim left usage example

The tikz/trim left option is described in section 15.8 'Establishing a Bounding Box'. The effect of tikz/trim left=<dimension or coordinate> is described as follows.

The effect is the same as if you issue \hspace{-s} where s is the difference of the picture's bounding box's lower left x coordinate and the x coordinate specified as <dimension or coordinate>.

In other words, the picture is shifted horizontally in such a way that the imaginary vertical line through coordinate will pass through the point on the page where the lower-left corner of the bounding box would have normally been located (in the absence of the tikz/trim left option).

The following LaTeX manuscript is based on the example given on p. 176 of the manual:

\documentclass{article}
\usepackage{tikz}
\begin{document}
  Text before image.%
  \begin{tikzpicture}[trim left={(0,0)}]
    \draw(-1,-1) grid (3,2);
    \fill (0,0) circle (5pt);
  \end{tikzpicture}%
  Text after image.
\end{document}

The 'trim left' option in practice.

5
  • First of all you should give an example of the usage of trim left. I, for example, have no idea what it does. Jul 10, 2017 at 8:47
  • 1
    @HenriMenke: I've added an example.
    – Evan Aad
    Jul 10, 2017 at 9:05
  • 4
    IIRC, picture-wise options can be set globally with \tikzset{...}, so you need something that can turn the option back locally.
    – Symbol 1
    Jul 10, 2017 at 9:13
  • @Symbol1: This is a good answer; I've just tried it. Thanks.
    – Evan Aad
    Jul 10, 2017 at 9:19
  • If every picture defines a value for trim left, trim left=default becomes useful. Jul 10, 2017 at 12:58

1 Answer 1

3

Example of usage:

\documentclass{article}
\usepackage{tikz}
\tikzset{every picture/.style={trim left={(0,0)}}}

\begin{document}
  Text before image.%
  \begin{tikzpicture}
    \draw(-1,-1) grid (3,2);
    \fill (0,0) circle (5pt);
  \end{tikzpicture}%
  Text after image.

  Text before image.%
  \begin{tikzpicture}[trim left=default]
    \draw(-1,-1) grid (3,2);
    \fill (0,0) circle (5pt);
  \end{tikzpicture}%
  Text after image.
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.