I really like Tikz for drawing little and easy diagrams in my LaTex documents. However, I am not very skilled so I'm looking for someone to give me a help to realize this drawing (without colors: D). Thank you all for the help!
-
11Welcome to TeX.SX. Questions about how to draw specific graphics that just post an image of the desired result are really not reasonable questions to ask on the site. Please post a minimal compilable document showing that you've tried to produce the image and then people will be happy to help you with any specific problems you may have. See minimal working example (MWE) for what needs to go into such a document.– jub0bsNov 15, 2014 at 17:08
-
4Basically, if you do the easy bits and post the code, somebody else will show you how to do the hard bits. I should also say that 'easy' and 'hard' are relative to you i.e. easy is however much or however little you know how to do; hard is whatever you're stuck on ;).– cfrNov 15, 2014 at 18:27
2 Answers
Since you are a beginner and I had some time to kill, I am going to provide you with a very basic starting point for your diagram. Actually, it replicates the diagram fairly well. You could play around with this and the PGF manual.
Hope you tikz more and help others in future in LaTeX Stack Exchange.
\documentclass[margin=1mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\begin{document}
\begin{tikzpicture}[scale=1.3]
\begin{scope}[fill=teal!20]
\fill[rounded corners=2mm] (0,0) rectangle (2,2);
\fill (2,1.25) rectangle (3,1.5)
(3,1) rectangle (3.75,1.75)
(3.75,1.75) rectangle (7,0.5);
\node [shape=isosceles triangle, fill=black,rotate=90,scale=0.3] at (2.5,1.25){};
\node [shape=isosceles triangle, fill=black,rotate=-90,scale=0.3] at (2.5,1.5){};
\end{scope}
\begin{scope}[fill=gray!60]
\fill [rounded corners=1mm] (3.1,1.1) rectangle (4.1,1.65);
\fill [rounded corners=1mm] (3.85,1.65) rectangle (7.0,0.6);
\fill (7,1) rectangle (8,1.25);
\end{scope}
\fill [yellow] (8,0.75) rectangle (10,1.5);
\fill [black]
(8.4,0.6) circle (0.15)
(8.7,0.6) circle (0.15)
(9.3,0.6) circle (0.15)
(9.6,0.6) circle (0.15);
\draw[thick] (10,1.2) .. controls (10.25,1.2) and (10.25,2) .. (10.5,2);
\foreach \y in {0.8,0.9,1.0,1.3,1.4}
\draw[red,<-] (7,\y) -- (7.5,\y);
\foreach \y in {1.15, 1.35, 1.55}
\draw[red,->] (2.75,\y) -- (3.1,\y);
\draw [red,->] (2.75,0.95) .. controls (3.5,1) and (3,0.7) .. (3.85,0.7);
\node [align=center,anchor=north] at (1,0) {Serbatoio ad\\aria compressa};
\node [anchor=north] at (2.75,0) {Valvola};
\node [align=center,anchor=north] at (5.5,0) {Sistema cilindro - pistone\\con sezione a scalino};
\node [align=center,anchor=north] at (9,0) {Slitta di\\alaggio};
\node[red] at (2.75,2) {Pressione};
\node[red] at (6.75,2) {Contro-Pressione};
\node [align=center] at (9.75,2) {Cavo di\\traino};
\end{tikzpicture}
\end{document}
Thank you so much anakrich! I hadn't posted any code because I didn't know how to start XD I tried to play with your code to get something more stylish :P Here is the modified code:
\begin{tikzpicture}[scale=1]
% Cylinder
\begin{scope}[fill=teal!20]
\fill[draw, rounded corners=2mm] (0,0) rectangle (2,3);
\fill (1.9,1.25) rectangle (3,1.5)
(3,1) rectangle (3.75,1.75)
(3.75,1.75) rectangle (7,0.5);
\node [shape=isosceles triangle, fill=black,rotate=90,scale=0.3] at (2.5,1.25){};
\node [shape=isosceles triangle, fill=black,rotate=-90,scale=0.3] at (2.5,1.5){};
\end{scope}
% Cylinder Boundary
\draw[thick] (2,1.25) -- (3,1.25);
\draw[thick] (3,1.25) -- (3,1);
\draw[thick] (3,1) -- (3.75,1);
\draw[thick] (3.75,1) -- (3.75,0.5);
\draw[thick] (3.75,0.5) -- (6.98,0.5);
\draw[thick] (6.98,0.5) -- (6.98,0.6);
\draw[thick] (6.98,1.65) -- (6.98,1.75);
\draw[thick] (6.98,1.75) -- (3,1.75);
\draw[thick] (3,1.75) -- (3,1.5);
\draw[thick] (3,1.5) -- (2,1.5);
% Piston
\begin{scope}[fill=gray!60]
\fill (3.1,1.1) rectangle (4.1,1.65);
\fill (3.85,1.65) rectangle (7.0,0.6);
\fill (7,1) rectangle (8,1.25);
\end{scope}
% Piston Boundary
\draw[thick] (7,1) -- (8, 1);
\draw[thick] (7,1.25) -- (8, 1.25);
\draw[thick] (3.85,0.6) -- (7, 0.6);
\draw[thick] (7,0.6) -- (7, 1);
\draw[thick] (7,1.25) -- (7, 1.65);
\draw[thick] (3.1,1.65) -- (7, 1.65);
\draw[thick] (3.1,1.65) -- (3.1, 1.1);
\draw[thick] (3.1,1.1) -- (3.85, 1.1);
\draw[thick] (3.85,1.1) -- (3.85, 0.6);
% Sled
\fill [yellow] (8,0.75) rectangle (10,1.5);
\fill [black]
(8.4,0.6) circle (0.15)
(8.7,0.6) circle (0.15)
(9.3,0.6) circle (0.15)
(9.6,0.6) circle (0.15);
\draw[thick] (10,1.2) .. controls (10.25,1.2) and (10.25,2) .. (10.5,2);
% Sled Boundary
\draw[thick] (8,0.75) -- (10,0.75);
\draw[thick] (10,0.75) -- (10, 1.5);
\draw[thick] (8,1.5) -- (10,1.5);
\draw[thick] (8,0.75) -- (8, 1.5);
% Ground
\draw[thick] (8,0.45) -- (10,0.45);
\fill [pattern = north east lines] (8,0.25) rectangle (10,0.45);
% Text
\node [align=center,anchor=north] at (1,0) {Serbatoio ad\\aria compressa};
%\node [anchor=north] at (2.75,0) {Valvola};
\node [align=center,anchor=north] at (5.3,0) {Sistema cilindro - pistone\\con sezione a scalino};
\node [align=center,anchor=north] at (9,0) {Slitta di\\alaggio};
\node[red] at (2.85,2) {Pressione};
\node[red] at (6.75,2) {Contro-Pressione};
\node [align=center] at (9.75,2.5) {Cavo di\\traino};
% Arrows
\foreach \y in {0.7,0.9,1.35,1.55}
\draw[thick, red,<-] (7,\y) -- (7.5,\y);
\foreach \y in {1.15, 1.35, 1.55}
\draw[thick, red,->] (2.75,\y) -- (3.1,\y);
\draw [thick, red,->] (2.75,0.95) .. controls (3.5,1) and (3,0.7) .. (3.85,0.7);
\end{tikzpicture}
Again, thank you so much !!!