3

I am drawing a Picture using TikZ with two \draw commands.
The first one works but on the second LaTeX claims

! Undefined control sequence. l.44 \draw (0,2) -- (-.5,2);

What can I do to fix that...
Thanks in the preface

EDIT: MWE

\begin{figure}[htbp]
\centering
\begin{tikz}
    % First the house
    \draw [thick,color=gray] (0,0) -- (0,2) -- (1,3) -- (2,2) -- (2,0) -- cycle (0,2) -- (2,2);
    % This command doesnt work...
    \draw (0,1) -- (-.5,1);
\end{tikz}
\end{figure}
  • 1
    The previos TikZ command is ended correctly with an ';' – Peter Parker Jan 2 '14 at 13:16
  • 1
    Welcome to tex.se! Please provide an MWE – papabravo Jan 2 '14 at 13:21
  • 1
    Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – jub0bs Jan 2 '14 at 13:30
  • 1
    The tikz package defines a \tikz macro, but no tikz environment. Did you mean \begin{tikzpicture} ... \end{tikzpicture}? – jub0bs Jan 2 '14 at 13:31
  • 5
    The first command did work because \begin{tikz} is issuing a \tikz comand and this grabbed the first \draw. – Ulrike Fischer Jan 2 '14 at 13:55
5

Try this. It should work.

\begin{tikzpicture}
% First the house
\draw [thick,color=gray] (0,0) -- (0,2) -- (1,3) -- (2,2) -- (2,0) -- cycle (0,2) -- (2,2);
% This command DOES work!
\draw (0,1) -- (-.5,1);
\end{tikzpicture}
  • 2
    Thank you but the mistake was using a tikz environment rather than an tikzpicture environment... – Peter Parker Jan 2 '14 at 17:00

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.