# \uppercase in \newcommand

I tried to use \uppercase in \newcommand:

When I use this I get

My University

and not

MY UNIVERSITY

Why?

### EDIT

I can't use \MakeUppercase because I need use latin quote, example: ingeniería. And this latin case has problems with \MakeUppercase

-

With both latin1 and utf8 encodings I get correct output from

The problem with your definition is that \uppercase acts on the token list \universidad and doesn't do nothing, because at that level there's no letter to be uppercased; \universidad is expanded only later. With \expandafter we perform the expansion before \MakeUppercase comes into action.

Just as an exercise, here is a macro \Capitalize that takes as argument a control sequence and defines its "uppercase variant"

\makeatletter
\newcommand{\Capitalize}[1]{%
\edef\@tempa{\expandafter\@gobble\string#1}%
\edef\@tempb{\expandafter\@car\@tempa\@nil}%
\edef\@tempa{\expandafter\@cdr\@tempa\@nil}%
\uppercase\expandafter{\expandafter\def\expandafter\@tempb\expandafter{\@tempb}}%
\@namedef{\@tempb\@tempa}{\expandafter\MakeUppercase\expandafter{#1}}}
\makeatother

After this magic code you can say

Note that \MakeUppercase does not go along with hyperref, so in case you use these commands where this package extracts something for building bookmarks you should give it a safe token list; for example

and, in the automatic defining command, change the line

\@namedef{\@tempb\@tempa}{\expandafter\MakeUppercase\expandafter{#1}}}

into

\@namedef{\@tempb\@tempa}{%
\texorpdfstring{\expandafter\MakeUppercase\expandafter{#1}}{#1}}}

In case one's using utf8x, the definitions must be preceded by \PrerenderUnicode:

\PrerenderUnicode{Ingeniería}

The \Capitalize macro could be

\makeatletter
\newcommand{\Capitalize}[1]{%
\@ifpackagewith{inputenc}{utf8x}{\PrerenderUnicode{#1}}{}%
\edef\@tempa{\expandafter\@gobble\string#1}%
\edef\@tempb{\expandafter\@car\@tempa\@nil}%
\edef\@tempa{\expandafter\@cdr\@tempa\@nil}%
\uppercase\expandafter{\expandafter\def\expandafter\@tempb\expandafter{\@tempb}}%
\@namedef{\@tempb\@tempa}{\expandafter\MakeUppercase\expandafter{#1}}}
\makeatother

so that \PrerenderUnicode is performed automatically when needed.

-
with you answer I get this –  JuanPablo Nov 21 '11 at 22:59
@JuanPablo Please, edit your question to show the problem. Where do you get it? –  egreg Nov 21 '11 at 23:05

You need to use \MakeUppercase instead of \uppercase. For information on the difference, see Case-changing oddities from the UK TeX FAQ.

For ligatures like í, you can either escape the character using \'{i}, or use it as-is with

\usepackage[utf8]{inputenc}

in your document preamble. This should accommodate the use of ligatures in your input.

\documentclass{article}
\usepackage[utf8]{inputenc}
\begin{document}
\begin{tabular}{ll}
\verb!\MakeUppercase{ingeniería}!: & \MakeUppercase{ingeniería} \\
\verb!\MakeUppercase{ingenier\'{i}a}!: & \MakeUppercase{ingenier\'{i}a}
\end{tabular}
\end{document}​
-
I use quote,example Ingeniería and have problems with MakeUppercase –  JuanPablo Nov 21 '11 at 21:21
If you escape the ligature í as \'i and use \MakeUppercase{Ingenier\'{i}a} you obtain the correct result. –  Werner Nov 21 '11 at 21:23
Just to nit-pick a bit: I don't think 〈í〉 can be considered a ligature, which would be a combination of two glyphs/graphemes, e.g. 〈æ〉. 〈í〉 is simply an accented character/glyph/letter/grapheme. –  doncherry Nov 21 '11 at 21:38