Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
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. –  Martin Scharrer Mar 1 '11 at 17:22
    
You mean using a full preamble with minimal document class? –  jrhorn424 Mar 1 '11 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. –  Martin Scharrer Mar 1 '11 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 Mar 1 '11 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. –  Matthew Leingang Mar 1 '11 at 18:18
show 3 more comments

1 Answer

up vote 3 down vote accepted

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}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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