# \textbeta and \textmu defined in the beamer class

I really like using UTF-8 greek letters in my latex code source and I use utf8x to convert them into \textalpha commands and then I define the \textalpha commands in a separate file where I write this, for each greek letter:

\newcommand{\textalpha}{\ensuremath{\alpha}}


And can even afford the luxury to use \varepsilon and \varphi.

This is actually the least intrusive and the most compatible way I found of doing this. (Well actually a little sed-parser was a lot more versatile and efficient because I knew what was going on but that's a very intrusive method)

Sadly this ... does not work with beamer because it seems to already have defined \textbeta and \textmu. Yes, only them. I don't know why.

Here is how to reproduce this. (This compiles. If you uncomment anything it won't compile)

\documentclass{beamer}
\usepackage[utf8x]{inputenc}
\newcommand{\textalpha}{\alpha}
%\newcommand{\textbeta}{\beta}
%\newcommand{\textmu}{\mu}
\begin{document}
$α$
% $β$
% $μ$
\end{document}



-
maybe you want to use \providecommand which does nothing, if the command already exist and does a \newcommand otherwise. –  Peter Breitfeld May 16 '12 at 13:30
@PeterBreitfeld thank you I will definitely use this as a workaround (with renewcommand). –  jmad May 16 '12 at 13:58

I have no idea why beamer has a \textbeta. Maybe someone else can give that answer.

There of course are ways to overwrite an existing macro.


\documentclass{beamer}
\usepackage[utf8x]{inputenc}

\makeatletter
% check if csname is defined
\newcommand*\checkfor[1]{%
\ifx#1\AMostCertainlyUndefinedCommand
\expandafter\@firstoftwo
\else
\expandafter\@secondoftwo
\fi}
% define in any case
\checkfor{#1}{\newcommand{#1}}{%
\GenericWarning{}{Warning: redefining \string#1}{}%
\renewcommand{#1}}}
\makeatother

\newcommand{\textalpha}{\alpha}
% this works, of course:
\def\textbeta{\beta}
% as will the new definition command:
\forcenewcommand{\textmu}{\mu}

% for demonstration purposes only:
\forcenewcommand\textbf[1]{(#1)}

\begin{document}
$α$
$β$
$μ$
\textbf{A}
\end{document}

-
Thank you. Is using \checkfor any better than doing \providecommand{\textbeta}{DEBUG-providecommand} \renewcommand{\textbeta}{\beta}? (Apart from the warning) –  jmad May 22 '12 at 13:44
@jmad I woudn't think so. Except less typing for you maybe if you don't have to define each command twice... –  clemens May 22 '12 at 14:15