How can I define an environment that would treat each word or group as an argument of a function?
I am writing a handbook that contains calculator entries, which I would like to typeset as buttons. So far, I am typesetting the buttons with tikz, but repeating the same command over and over again makes the code unreadable even if the command is just one letter long.
The tikz command is taken from here
\usepackage{tikz}
\usetikzlibrary{shadows}
\newcommand*\x[1]{% keystroke
\tikz[baseline=(key.base)]
\node[draw, fill=white,
drop shadow={shadow xshift=0.25ex,shadow yshift=-0.25ex,fill=black,opacity=0.75},
rectangle, rounded corners=2pt, inner sep=2pt,
line width=0.5pt, font=\normalsize\sffamily
](key) {#1\strut};
}
I use it, e.g., as
\begin{quote}
\x{(}\x{4}\x{EXP}\x{2}\x{)}\x{$\div$}\x{(}\x{3}\x{EXP}\x{4}\x{)}\x{=}
\end{quote}
which creates a mess. I would much rather have an environment
\newenvironment{calc}{%
% the wanted definitions for my commands here
\begin{quote}
}{%
\end{quote}
}
that would take separate words or groups
\begin{calc}
( 4 EXP 2 ) {$\div$} ( 3 EXP 4 ) =
\end{calc}
and produced the same result.
I have found that very similar behaviour can be achieved for tables using \catcode
here but I was not able to make it work for my case.