1

Rather than define a single decorator for all lines at the tikzpicture level, I'd like to use scopes to selectively apply certain decorations to certain parts of my drawing. As a minimal example:

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{decorations}

\begin{document}

\begin{tikzpicture}
%%% Draw the axis.
\begin{scope}[decoration={ticks}]
\draw [->] (0,0) -- (8,0);
\draw [decorate] (0,0) -- (8,0);
\end{scope}
\end{tikzpicture}

\end{document}

This should produce an axis eight units long with tick marks, and the decoration should not "bleed" into other areas of the figure.

Instead, I get an axis, but no tickmarks!

EDIT: It turns out, calling \usetikzlibrary{decorations} in the preamble doesn't work. Instead, use \usetikzlibrary{decorations.pathreplacing}. Can anyone tell me why loading the whole decorations library doesn't work?

8
  • Please post a complete and compilable, but minimal example. This means with all required packages and TikZ libraries but with no unrelated thing like scale (there is a ] missing anyway). Thanks. Commented Mar 1, 2011 at 17:22
  • You mean using a full preamble with minimal document class?
    – jrhorn424
    Commented Mar 1, 2011 at 17:25
  • Yes a full preamble. If now with article or minimal class doesn't matter. The minimal refers to no unrelated code, not to the minimal class. Also you should put an @Martin in your comment so that I get notified about your comment. This isn't required for the original author of the question or answer, which is the reason I skipped the @jrhorn424 in my comments. Commented Mar 1, 2011 at 17:27
  • 1
    The minimal example doesn't compile for me (even with decorations.pathmorphing), it complains about not knowing the axis key. Is this a style you defined yourself somewhere else? Also, if you manage to find a solution to your problem, you can post that as an answer and accept it, to close the issue.
    – Jake
    Commented Mar 1, 2011 at 17:48
  • 3
    In answer to your question about why doesn't \usetikzlibrary{decorations} result in the decorations.pathmorphing library also be loaded, it's better to think of decorations as a base library and decorations.pathmorphing as an extension, rather than decorations.pathmorphing as a sub-library of decorations. The dot doesn't have any special LaTeX meaning here; it's just the file that contains the code is called tikzlibrarydecorations.pathmorphing.code.tex. Commented Mar 1, 2011 at 18:18

1 Answer 1

4

It requires the library decorations.pathreplacing. The axis style for a path doesn't exist by default. Perhaps you can clarify that. The code below works. But perhaps not as expected.

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{decorations.pathreplacing}

\begin{document}
  \begin{tikzpicture}
    \begin{scope}[decoration={ticks}]
      \draw[->] (0,0) -- (8,0);
      \draw[decorate] (0,0) -- (8,0);
    \end{scope}
  \end{tikzpicture}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .