6

I'm trying to use tikz to draw a line that changes color at two different points. As you can see from the code below, what I want is a line that starts solid red, changes to dotted gray, and ends as solid green. When I compile, though, I get the red section only, without the other two. What is the remedy?

\documentclass[border=2mm]{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}

    %% The line itself

    \draw [red, very thick, |-] (0,0) -- (22,0);
    \draw [gray, very thick, dotted] (22,0 -- 26,0);
    \draw [green, very thick, ->] (26,0 -- 40,0);

\end{tikzpicture}
\end{document}
crmdgn
  • 2,628
  • 2
    Write (22,0) -- (26,0) instead of (22,0 -- 26,0), and (26,0) -- (40,0) instead of (26,0 -- 40,0). – jub0bs Jun 26 '14 at 20:30
  • 1
    ...And this is why it's a bad idea to code when you're tired. I can't believe I did that. – crmdgn Jun 26 '14 at 20:36
  • 2
    This question appears to be off-topic because it was solved by correcting a simple typo. – Paul Gessler Jun 26 '14 at 23:04
  • 5
    This question appears to be off-topic because it was solved by correcting a simple typo. – Masroor Jun 26 '14 at 23:29
  • 1
    The notice above suggests that I rewrite the question, but I don't really see how to do that: the existing question accurately depicts my problem at the time, and @Jubobs pointed out my error, so it's not like there's a new question to ask. – crmdgn Jun 27 '14 at 16:50
  • @crmdgn Questions that stem from a relatively straighforward syntax error tend to get closed as off-topic on TeX.SX. Don't worry about that automated message; sometimes, those messages aren't really appropriate to the situation. You got a solution to your problem; that's all that matters. – jub0bs Jun 27 '14 at 16:56
  • I do not understand. We have question asking for variable width, but we cannot have question asking for variable color? – Symbol 1 Apr 01 '17 at 02:29
  • @Symbol1 I don't really understand what you don't understand. Of course we can have a question for variable color (and there is at least one about changing color along a path). The point, as I see it, is that the OP had code that did what (s)he wanted to do, except for the fact that he had forgotten a couple of parentheses. So the question stems from a typo, and thus was closed. – Torbjørn T. Apr 01 '17 at 09:14
  • @Symbol1 See for example http://tex.stackexchange.com/questions/10980/ or http://tex.stackexchange.com/questions/162919/ or http://tex.stackexchange.com/questions/32294/ or http://tex.stackexchange.com/questions/133138/ or http://tex.stackexchange.com/questions/243689/ or http://tex.stackexchange.com/questions/141378/ for questions regarding changing color along a path. – Torbjørn T. Apr 01 '17 at 09:20
  • 4
    I'm voting to close this question as off-topic because the problem was caused by a typo (forgetting a couple of parentheses). – Torbjørn T. Apr 01 '17 at 09:25
  • @TorbjørnT. I see your point. My bad. I was reviewing unanswered questions with ≥3 point and I did not expect that it is a typo. – Symbol 1 Apr 01 '17 at 12:40
  • @TorbjørnT. I think that the "off-topic" label is misleading. The label says, "This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center." Perhaps the help center provides more info, but how can a user know if code syntax is bad? I suggest that another category be created, "user error." Then, the question would be completely removed, after the OP is notified of the error. –  Apr 01 '17 at 14:28
  • 1
    @RobtA That is because the other people who voted to close didn't use my close reason (which you can see in my comment above). I think if they had done that, that same text is what would have been written in the yellow box above. That said: 1. The user in this case obviously knew the right syntax; 2. I'm just a user and no one else will see your suggestion here, so https://tex.meta.stackexchange.com is the right place to for that (i.e. a suggesting a new close reason). – Torbjørn T. Apr 01 '17 at 16:00

0 Answers0