I asked for help once to draw some diagrams using Tikz, the answer that suited my needs used \begin{tikzpicture}[scale=1.1, every node/.style={scale=1.3}] to set the enviroment, and some diagrams doesn't fit the textwidth of my document, I tried to changed the options to [\width=\textwidth, every node/.style={\width=\textwidth}] but I get the following error

Package pgfkeys Error: I do not know the key '/tikz/width', to which you passed '\textwidth ', and I am going to ignore it. Perhaps you misspelled it. ...th, every node/.style={width=\textwidth}]

even though I get a PDF with the desired output

What is the right way to do what I stated before?

    %bigger margins than usual
        \tikzstyle{spring}=[thick,decorate,decoration={zigzag,pre length=0.3cm,post length=0.3cm,segment length=6}]
        mark connection node=dmp,
        mark=at position 0.5 with 
            \node (dmp) [thick,inner sep=0pt,transform shape,rotate=-90,minimum width=15pt,minimum height=3pt,draw=none] {};
            \draw [thick] ($(dmp.north east)+(2pt,0)$) -- (dmp.south east) -- (dmp.south west) -- ($(dmp.north west)+(2pt,0)$);
            \draw [thick] ($(dmp.north)+(0,-5pt)$) -- ($(dmp.north)+(0,5pt)$);
    }, decorate]
    \tikzstyle{ground}=[fill,pattern=north east lines,draw=none,minimum width=0.75cm,minimum height=0.3cm,inner sep=0pt,outer sep=0pt]
        \begin{tikzpicture}[scale=1, every node/.style={scale=1.3}]

\node [draw, outer sep=0pt, thick] (M) [minimum width=2cm, minimum height=1cm,yshift=-1cm] {$\mathrm{m}$};

\node (ground) [ground,anchor=north,yshift=3.3cm,minimum width=4cm,xshift=0cm] at (M.north) {};
\node [outer sep=0pt, thick] (ground2) [minimum width=2cm, minimum height=1cm, yshift =3cm] {};

\draw (ground.south east) -- (ground.south west);

\draw [spring] (ground2.south) -- (M.north) node [midway,left] {$\mathrm{k}$};

\draw [-latex,ultra thick] (M.north west) ++ (-0.5cm, 0.0cm) -- +(0cm,-1cm);
\draw [dashed] (M.north west) ++ (0cm, 0cm) -- +(-0.8cm,0cm);
\node (y1) at (M.north west) [xshift = -0.7cm, yshift = -0.8cm] {$x$};

\draw [dashed] (M.north west) ++ (-0.8cm, 0.5cm) -- +(14cm,0cm);
\node (y2) at (M.north west) [align=center,xshift = -0.8cm, yshift = 0.4cm] {Posición\\original};


I must say that I pretend to use this diagram inside a figure enviroment

  • Please provide a MWE that can reproduce your problem. This way nobody can help you except of some general answers like tjhese here: tex.stackexchange.com/questions/4338/…
    – koleygr
    Jan 27, 2018 at 6:39
  • 1
    from your fragments is difficult to figured out how we can help you. the simplest is include image as pdf graphics like includegraphics[width=\textwidth]{...}
    – Zarko
    Jan 27, 2018 at 6:39
  • \width=\textwidth would be wrong as tikzkey. width=\textwidth would be right, but AFAIK it doesn't has a width key. Jan 27, 2018 at 7:23
  • I´ve updated my question with a MWE
    – Paul Lara
    Jan 27, 2018 at 8:31
  • related question: tex.stackexchange.com/questions/411671/…
    – Ignasi
    Jan 29, 2018 at 8:52

1 Answer 1


You can use the adjustbox package to scale any content:



This scales the tikzpicture as box, so everything including the text.

  • could I put the adjustbox enviroment inside a figure enviroment?
    – Paul Lara
    Jan 27, 2018 at 8:23
  • @PaulLara: Yes. You can place basically everything inside a figure environment (except other floats), as it is just a floating container. Jan 27, 2018 at 15:16
  • A better option is probably the tikzscale package @PaulLara.
    – cfr
    Jan 28, 2018 at 4:12

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.