2

I made a code that has a special way to write the cents.

Here's a MWE:

\documentclass{article}
\usepackage{graphicx}

\makeatletter
\newif\if@thecomma
\def\normal@comma{,}
{
 \catcode`\,=\active
 \gdef,{
    \if@thecomma
        \expandafter\special@comma
    \else
        \expandafter\normal@comma
    \fi}
}
\AtBeginDocument{\catcode`\,=\active}
\def\special@comma#1#2{
    \ifx#1,
    \else
        \ifmmode
            \hspace{-0.1em}\normal@comma{\raisebox{-0.10em}{\hspace{-0.28em}\scalebox{0.94}{$^{#1#2}$}}}\@thecommafalse
        \else
            ,#1#2
        \fi
    \fi
}
\def\U{\ifmmode\@thecommatrue\scalebox{0.95}{\scalebox{0.98}{U\hspace{0.05em}\scalebox{0.96}{$\$$}}}\hspace{0.2em}\fi}
\makeatother

\begin{document}

I spent $\U213,22$ in last month.

\end{document}

This code it's working for many purposes, but I'm having a conflict with TikZ node - not so clear why. Any sugestions to get a better code, without that corner cases?

2

In my opinion it's easier to stick with standard LaTeX notation for arguments:

\documentclass{article}
\usepackage{xparse}

\NewDocumentCommand{\U}{>{\SplitArgument{1}{,}}m}{%
  \mbox{\normalfont U\$\,\Uinner#1}%
}
\NewDocumentCommand{\Uinner}{mm}{%
  #1,%
  \Uraise{\IfNoValueTF{#2}{00}{#2}}%
}
\NewDocumentCommand{\Uraise}{m}{%
  \begingroup\sbox{0}{0}%
  \raisebox{\dimexpr\ht0-\height}{\scriptsize#1}%
  \endgroup
}

\begin{document}

I spent \U{213,22} in last month and \U{10} today.

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.