Straight forward question:
\newcommand{\optaxis}[1][]{
\ifemptyarg{#1}
{\begin{axis} [xtick={0}, xmin=-1, xmax =1, xticklabels={#2}, box plot width=5mm]}
{\begin{axis} [xtick={0,1}, xmin=-1, xmax =2, xticklabels={{#1},{#2}}, box plot width=5mm]}%
}
How can I get the part here to work correctly - {{#1},{#2}} - I am getting a variety of errors which I cannot seem to resolve. If I change that to {test,test2} it works and compiles fine.
The specific error message is:
You meant to type ## instead of #, right?
edit:
I am trying to use from here:
\makeatletter
\def\ifemptyarg#1{%
\if\relax\detokenize{#1}\relax % H. Oberdiek
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi}
\makeatother
\newcommand{\optaxis}[1][]{
\ifemptyarg{#2}
{\begin{axis} [xtick={0}, xmin=-1, xmax =1, xticklabels={#1}, box plot width=5mm]}
{\begin{axis} [xtick={0,1}, xmin=-1, xmax =2, xticklabels={{#1},{#2}}, box plot width=5mm]}
}
I want to be able to call this like:
\optaxis{test1}
\optaxis{test1, test2}
and have each called respectively.
\optaxis{test1, test2}which istest1, test2. If you used\optaxis{test1}{test2}then you would have two parameters. – Peter Grill Mar 29 '13 at 22:30[]if you do not define it as optional then the argument would be surrounded by{}– David Carlisle Mar 29 '13 at 22:33