I use the following resizedtikzpicture environment in order to rescale my tikzpictures. Would it be possible to add an optional argument, taking into account the tikz option? For example the color or baseline.
MWE:
\documentclass[twocolumn]{article}
\usepackage{tikz,tikzpagenodes}
\newsavebox\mybox
\newenvironment{resizedtikzpicture}[1]{%
\def\mywidth{#1}%
\begin{lrbox}{\mybox}%
\begin{tikzpicture}
}{%
\end{tikzpicture}%
\end{lrbox}%
\resizebox{\mywidth}{!}{\usebox\mybox}%
}
%\newsavebox\mybox
%\newenvironment{wrongresizedtikzpicture}[2][\unskip]{%
% \def\mywidth{#1}%
% \begin{lrbox}{\mybox}%
% \begin{tikzpicture}[ #2]
% }{%
% \end{tikzpicture}%
% \end{lrbox}%
% \resizebox{\mywidth}{!}{\usebox\mybox}%
%}
\begin{document}
ABCDE
\begin{resizedtikzpicture}{\columnwidth}
\draw [thick,->] (-5,0)--(5,0);
\draw [thick,->] (0,-5)--(0,5);
\draw [very thick, domain=-5:5,samples=200] plot(\x,{\x+0.2});
\draw [very thick, domain=-5:0,samples=200] plot(\x,{\x});
\draw [very thick, domain=0:5,samples=200] plot(\x,{0*\x});
\draw [very thick, domain=-5:0,samples=200] plot(\x,{0*\x});
\draw [very thick, domain=0:5,samples=200] plot(\x,{\x});
\draw (-6,-4.5) node{{\(x \mapsto x\)}};
\end{resizedtikzpicture}
% Goal :
%\begin{resizedtikzpicture}{\columnwidth}[baseline=0]
%\draw [thick,->] (-5,0)--(5,0);
%\draw [thick,->] (0,-5)--(0,5);
%\draw [very thick, domain=-5:5,samples=200] plot(\x,{\x+0.2});
%
%\draw [very thick, domain=-5:0,samples=200] plot(\x,{\x});
%\draw [very thick, domain=0:5,samples=200] plot(\x,{0*\x});
%
%\draw [very thick, domain=-5:0,samples=200] plot(\x,{0*\x});
%\draw [very thick, domain=0:5,samples=200] plot(\x,{\x});
%
%\draw (-6,-4.5) node{{\(x \mapsto x\)}};
%\end{resizedtikzpicture}
\end{document}

\begin{resizedtikzpicture}{\columnwidth}{baseline=0}”, which is a syntax for a mandatory argument. I have added another example where the second argument is optional (thus, you were right tagging the question withxparseand I'll readd it). – frougon Apr 13 '20 at 00:01