I have a GrayBox environment defined as follows.
It is used \begin{GrayBox}...\end{GrayBox}
or \begin{GrayBox}[\textwidth]...\end{GrayBox}
, that is, it can pass optional parameter to the environment.
I guess #1 is the setup for default value, and #2 is for setup for the value given.
Question
How is #2 possible? I mean, is it LaTeX's rule that if #1
is not given, the default value in []
is used instead? Is there any reference about this? Is the same technique can be applied to \newcommand
?
\newlength{\RoundedBoxWidth}
\newsavebox{\GrayRoundedBox}
\newenvironment{GrayBox}[1][\dimexpr\textwidth-4.5ex]% **** #1
{\setlength{\RoundedBoxWidth}{\dimexpr#1} **** #2
\begin{lrbox}{\GrayRoundedBox}
\begin{minipage}{\RoundedBoxWidth}}%
{ \end{minipage}
\end{lrbox}
\begin{center}
\begin{tikzpicture}%
\draw node[draw=black,fill=black!10,rounded corners,%
inner sep=2ex,text width=\RoundedBoxWidth]%
{\usebox{\GrayRoundedBox}};
\end{tikzpicture}
\end{center}}
???
in the question, BTW? Was it intentional or some Unicode char that got corrupted?\relax
after the expression evaluated by\dimexpr
just to be on the safe side, even if it's not strictly necessary here.