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?
\documentclass[11pt,a4paper]{scrreprt}
%bigger margins than usual
\areaset{336pt}{705pt}
\usepackage{tikz}
\usepackage{amsmath}
\usetikzlibrary{automata,calc,patterns,decorations.pathmorphing,decorations.markings}
\tikzstyle{spring}=[thick,decorate,decoration={zigzag,pre length=0.3cm,post length=0.3cm,segment length=6}]
\tikzstyle{damper}=[thick,decoration={markings,
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{document}
\begin{center}
\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};
\end{tikzpicture}
\end{center}
\end{document}
I must say that I pretend to use this diagram inside a figure enviroment

includegraphics[width=\textwidth]{...}– Zarko Jan 27 '18 at 06:39\width=\textwidthwould be wrong as tikzkey.width=\textwidthwould be right, but AFAIK it doesn't has awidthkey. – Martin Scharrer Jan 27 '18 at 07:23