LaTeX forum ⇒ Graphics, Figures & TablestikZ | Scale Picture

Information and discussion about graphics, figures & tables in LaTeX documents.
Singularity
Posts: 155
Joined: Sat Jan 22, 2011 9:55 pm

tikZ | Scale Picture

Postby Singularity » Mon Sep 05, 2011 10:43 pm

How do I scale this tikz graphic I once made? I tried using
  1. \begin{tikzpicture}[scale=1.5]

but that created spaces and didn't move the text. Thank you.

  1. \begin{tikzpicture}
  2. % Left wall
  3. \draw[very thick] (0,-.5) -- (0,.5);
  4.  
  5. % First spring (s_0)
  6. \draw (0,0) -- (0+.25,0);
  7. \draw (0+.375,-.0125) ellipse (1.25mm and 1.25mm)
  8. (0+.500,-.0125) node [above,outer sep=2pt,name=s0] {$s_{_0}$} ellipse (1.25mm and 1.25mm)
  9. (0+.625,-.0125) ellipse (1.25mm and 1.25mm);
  10. \draw (0+.75,0) -- (0+1,0);
  11.  
  12. % First two masses and two springs (m_1, s_1, m_2, s_2)
  13. \foreach \x in {1,2} {
  14. % Mass (it's just a rectangle)
  15. \draw ((1.75*\x-.75,0) node[draw,rectangle,name=m\x,anchor=west] {$m_{_\x}$};
  16.  
  17. % Spring (three circles with connecting lines on the ends).
  18. \draw (1.75*\x,0) -- (1.75*\x+.25,0);
  19. \draw (1.75*\x+.375,-.0125) ellipse (1.25mm and 1.25mm)
  20. (1.75*\x+.500,-.0125) node [above,outer sep=2pt,name=s\x] {$s_{_\x}$} ellipse (1.25mm and 1.25mm)
  21. (1.75*\x+.625,-.0125) ellipse (1.25mm and 1.25mm);
  22. \draw (1.75*\x+.75,0) -- (1.75*\x+1,0);
  23. }
  24.  
  25. % Ellipses
  26. \foreach \i in {0,...,2} {
  27. \path (4.65+\i*.1,0) coordinate (X\i);
  28. \fill (X\i) circle (1pt);
  29. }
  30.  
  31. % First post-ellipses spring (s_{N-1})
  32. \draw (5,0) -- (5.25,0);
  33. \draw (5.375,-.0125) ellipse (1.25mm and 1.25mm)
  34. (5.500,-.0125) node [above,outer sep=2pt,name=sN-1] {$s_{_{N-1}}$} ellipse (1.25mm and 1.25mm)
  35. (5.625,-.0125) ellipse (1.25mm and 1.25mm);
  36. \draw (5.75,0) -- (6,0);
  37.  
  38. % Last mass and spring (m_N, s_N).
  39. \foreach \x in {1} {
  40. % Mass (it's just a rectangle)
  41. \draw (6,0) node[draw,rectangle,name=mn,anchor=west] {$m_{_N}$};
  42.  
  43. % Spring (three circles with connecting lines on the ends).
  44. \draw (6.8,0) -- (6.8+.25,0);
  45. \draw (6.8+.375,-.0125) ellipse (1.25mm and 1.25mm)
  46. (6.8+.500,-.0125) node [above,outer sep=2pt,name=sn] {$s_{_N}$} ellipse (1.25mm and 1.25mm)
  47. (6.8+.625,-.0125) ellipse (1.25mm and 1.25mm);
  48. \draw (6.8+.75,0) -- (6.8+1,0);
  49. }
  50. \draw[very thick] (7.8,-.5) -- (7.8,.5);
  51.  
  52. % The original spring and mass.
  53. % \draw (0,0) -- (.25,0);
  54. % \draw (.375,-.0125) ellipse (1.25mm and 1.25mm)
  55. % (.500,-.0125) node [above,outer sep=2pt,name=s0] {$s_0$} ellipse (1.25mm and 1.25mm)
  56. % (.625,-.0125) ellipse (1.25mm and 1.25mm);
  57. %
  58. % \draw (.75,0) -- (1,0);
  59. %% \draw (1,-.25) rectangle (2,.25) (1.5,0) node [name=m0] {$m_0$};
  60. % \draw (1,0) node[draw,rectangle,name=m0,anchor=west] {$m_0$};
  61. \end{tikzpicture}
Last edited by Singularity on Tue Sep 06, 2011 1:33 pm, edited 1 time in total.

User avatar
shadgrind
Posts: 140
Joined: Thu Jul 16, 2009 12:39 am

Postby shadgrind » Tue Sep 06, 2011 10:22 am

Use the graphicx package and put your tikzpicture environment inside a \scalebox command:

  1. \documentclass{article}
  2. \usepackage{graphicx}
  3. \usepackage{tikz}
  4. \begin{document}
  5.  
  6. \scalebox{1.5}{\begin{tikzpicture}
  7. % Put your tikz code here
  8. \end{tikzpicture}}
  9.  
  10. \end{document}
System: TeX Live 2012, Fedora 18 x86_64, GNU Emacs 24.2

Singularity
Posts: 155
Joined: Sat Jan 22, 2011 9:55 pm

Postby Singularity » Tue Sep 06, 2011 1:33 pm

Worked first time.
Thanks.


Return to “Graphics, Figures & Tables”

Who is online

Users browsing this forum: No registered users and 3 guests