Code: Select all
\card{3}{H}
As such: I've defined two commands, \suit and \suitcolor, as follows:
Code: Select all
\DeclareSymbolFont{extraup}{U}{zavm}{m}{n}
\DeclareMathSymbol{\varheart}{\mathalpha}{extraup}{86}
\DeclareMathSymbol{\vardiamond}{\mathalpha}{extraup}{87}
\newcommand{\suit}[1]{
\ifthenelse{\equal{#1}{H}}{\varheart}{}
\ifthenelse{\equal{#1}{D}}{\vardiamond}{}
\ifthenelse{\equal{#1}{C}}{\clubsuit}{}
\ifthenelse{\equal{#1}{S}}{\spadesuit}{}
}
Code: Select all
\newcommand{\suitcolor}[1]{
\ifthenelse{\equal{#1}{H}}{red}{
\ifthenelse{\equal{#1}{D}}{red}{black}
}
}
Code: Select all
\documentclass{amsart}
\usepackage{tikz,ifthen}
\DeclareSymbolFont{extraup}{U}{zavm}{m}{n}
\DeclareMathSymbol{\varheart}{\mathalpha}{extraup}{86}
\DeclareMathSymbol{\vardiamond}{\mathalpha}{extraup}{87}
\newcommand{\suit}[1]{
\ifthenelse{\equal{#1}{H}}{\varheart}{}
\ifthenelse{\equal{#1}{D}}{\vardiamond}{}
\ifthenelse{\equal{#1}{C}}{\clubsuit}{}
\ifthenelse{\equal{#1}{S}}{\spadesuit}{}
}
\newcommand{\suitcolor}[1]{
\ifthenelse{\equal{#1}{H}}{red}{
\ifthenelse{\equal{#1}{D}}{red}{black}
}
}
%%%-------------------------------------
\begin{document}
The command $\backslash$suit gives me exactly what I'd like:\\
\$$\backslash$suit\{H\}\$ gives $\suit{H}$\\
\$$\backslash$suit\{D\}\$ gives $\suit{D}$\\
\$$\backslash$suit\{C\}\$ gives $\suit{C}$\\
\$$\backslash$suit\{S\}\$ gives $\suit{S}$\\
Similarly, $\backslash$suitcolor returns the color of the suit as I'd hope:\\
$\backslash$suitcolor\{H\} gives \suitcolor{H}\\
$\backslash$suitcolor\{D\} gives \suitcolor{D}\\
$\backslash$suitcolor\{C\} gives \suitcolor{C}\\
$\backslash$suitcolor\{S\} gives \suitcolor{S}\\
But what I'd really like to be able to do is, with a single input, make (for example) a red heart.
I can easily do this with a bit of code:\\
\{$\backslash$color\{red\} \$$\backslash$suit\{H\}\$\} gives {\color{red} $\suit{H}$}
But something breaks down if I try to use $\backslash$suitcolor to define the color:\\
\{$\backslash$color\{$\backslash$suitcolor\{H\}\} \$$\backslash$suit\{H\}\$\} gives {\color{\suitcolor{H}} $\suit{H}$}\\
:( a black heart, not a red one as intended.
\end{document}
Thanks!