I want to draw the following in Tikz (Tikz is the way to go here right?) System

As I am new to Tikz, I tried do draw it by hand to see if someone here can help me. Drawing

If possible, it would be nice for it to have the dimensions of the parts of the system too.

Thanks a lot.

EDIT: I did this until now: (Inspired by Marco comment here Simple Ramp Diagram with Ball)


%\draw [help lines] (0,0) grid (25,15);

\draw [fill=gray, gray] (0,0) rectangle (1,6); 
\draw [|<->|] (-0.8,0) -- (-0.8,6) node [midway,align=left,xshift=-0.2cm]{$h$};
\draw [fill=gray, gray] (0,5) rectangle (20,6);   
\draw [fill=gray, gray] (19,6) rectangle (20,0);
\draw [fill=gray, gray] (2,6) rectangle (3,12);
\draw [|<->|] (-0.8,6.1) -- (-0.8,11.9) node [midway,align=left,xshift=-0.25cm]{$H$};


I'm struggling to make the angled retangle and the ball in the same style as the other retangles.

Any sugestion from a more experienced Tikz user would be welcome!

  • 4
    It would probably be very useful for you to go through the tutorials in the first part of the TikZ manual. That will likely tell you almost all you need to know to make that sketch. Then if any specific parts are troublesome, show the code you have so far, and ask about those. Apr 29 '16 at 20:25
  • 1
    (TikZ is the most traveled way around here, but there are several other ways leading to same destination. Probably each way has it own nice parts and pitfalls.) Apr 29 '16 at 20:27
  • @TorbjørnT. I read the Tikz manual, so I understand it a little bit. I even made some simpler drawings (can I post code in a comment?). This just is being too frustrating to me. Soo hard!
    – Gabriel
    Apr 29 '16 at 20:36
  • @GabrielRibeiro You cannot post a code sample in a comment, but you can append it to your question by editing it. Apr 29 '16 at 20:40
  • 2
    You might start with either of the answers to this question. (Especially mine with Metapost :-)
    – Thruston
    Apr 29 '16 at 20:44

For this I would start by placing (and naming) nodes or coordinates at the desired locations. (A coordinate is basically a node with no size and no caption.) In the example below I name them according to location, with l/r meaning left/right, and t/m/b meaning top/mid/bottom.

I would then connect the nodes as necessary. Using a thick line may be easier in this case than orienting a rectangle. See p. 38 of the TikZ manual for an explanation of |-.

enter image description here

\begin{tikzpicture}[scale=0.25,inner sep=2pt,myball/.style={draw=black,line width=0.5pt,fill=red!50,circle,radius=2pt,above=1.5pt}]
\coordinate(bl) at (0,0);
\coordinate(ml) at (0,6);
\coordinate(tl) at (2,10);
\coordinate(mr) at (19,6);
\coordinate(br) at (19,0);
\coordinate(rampend) at (16,6);

\draw[line width=3pt,gray](bl)--(ml)--(mr)--(br)-- ++(5,0)
    node[near start,myball]{};
\draw[line width=3pt,gray](ml) (ml -| tl) -- (tl) -- (rampend)

\draw [|<->|] (bl)  ++(-0.75,0) node(leftlabel)[shape=coordinate]{} -- (ml -| leftlabel) node [midway,left]{$h$};
\draw [|<->|] (ml -| leftlabel) -- (tl -| leftlabel) node [midway,left]{$H$};

This isn't much, but perhaps it will help you get started.

  • Nice, I learned a lot from your answer! Thanks!
    – Gabriel
    Apr 29 '16 at 23:34

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.