How would I make the following diagram and label the values? I would prefer it if instead of a box, there were a ball rolling down the ramp and the horizontal ground displacement were labeled as well. The force arrow is not necessary. Thank you.
[Tex/LaTex] Simple Ramp Diagram with Ball
diagramstikz-pgf
Related Solutions
The description of the problem is still somehow vague, but perhaps something like this could help:
\documentclass{article}
\usepackage{tikz}
\newcommand\TBox[3][]{%
\tikz\node[draw,ultra thick,text width=#2,align=left,#1] {#3};}
\begin{document}
\TBox{5cm}{%
\TBox[fill=brown]{3cm}{\TBox[fill=red!30]{1cm}{B}\hfill\TBox[fill=cyan!30]{1cm}{C}} \\[1ex]
\TBox[fill=green!30]{1cm}{D}\quad\TBox[fill=yellow!30]{1cm}{E}}
\end{document}
\Tbox
has three arguments: the (first) optional argument can be used to pass options to the rectangular \node
for the box; the second argument specifies the text width, and the third argument is used for the contents.
After the comments, this can be closer to the desired result; now \TBox
has one optional argument (to pass options to the node) and one mandatory argument (the contents of the box):
\documentclass{article}
\usepackage{tikz}
\newcommand\TBox[2][]{%
\tikz\node[draw,ultra thick,align=left,#1] {#2};\hskip2pt}
\begin{document}
\TBox{%
\TBox[fill=brown]{Some test text \\ \TBox[fill=red!30]{Some}\TBox[fill=cyan!30]{A}} \\
\TBox[fill=green!30]{B}\TBox[fill=yellow!30]{Text}}
\end{document}
\documentclass[11pt]{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\draw[<-] (0,0) -- node[right]{$W_{m}$}(0,2)
node[circle,fill,inner sep=3mm,text=white,anchor=south] (m) {$m$};
\draw (m.north) -- node[right]{$T \uparrow$} +(0,2);
\end{scope}
\begin{scope}[shift={(2cm,-8mm)}]
\draw[<-] (0,0) -- node[right]{$W_{2m}$}(0,2)
node[circle,fill,inner sep=6mm,text=white,anchor=south] (m) {$m$};
\draw (m.north) -- node[right]{$T \uparrow$} +(0,2);
\end{scope}
\end{tikzpicture}
\end{document}
Explanations:
scope
forms a group around its contents so that we can perform operations (like shift) on the entire group. Every node
's contents are separated from the border by inner sep
(In other words, the distance between the contents and the border). By adjusting inner sep
we can make the node bigger or smaller (so as to just enclose the contents). We can label
a node by (m)
so that we can use that node's anchors (for ex, m.north
) later whereas {m}
is the content of the node. And finally (m.north) -- +(0,2)
means draw a line fron m.north
to a point that is 0cm
away horizontally and 2cm
away vertically.
Best Answer