Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I tried to use \uppercase in \newcommand:

\newcommand\universidad{My University}
\newcommand\Universidad{\uppercase{\universidad}} 

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

share|improve this question

3 Answers 3

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.

enter image description here

\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}​
share|improve this answer
    
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
1  
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

With both latin1 and utf8 encodings I get correct output from

\newcommand{\facultad}{Ingeniería}
\newcommand{\Facultad}{\expandafter\MakeUppercase\expandafter{\facultad}}
\Facultad

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

\newcommand\universidad{Universidad de Lugar}
\newcommand{\facultad}{Ingeniería}

\Capitalize{\Universidad}
\Capitalize{\facultad}

will define also \Universidad and \Facultad that will print "UNIVERSIDAD DE LUGAR" and "INGENIERÍA".

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

\newcommand{\Facultad}{%
   \texorpdfstring{\expandafter\MakeUppercase\expandafter{\facultad}}%
      {\facultad}}

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}
\newcommand{\facultad}{Ingeniería}
\newcommand{\Facultad}{\expandafter\MakeUppercase\expandafter{\facultad}}

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.

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

In my case, this article really helped:

http://www.tex.ac.uk/cgi-bin/texfaq2html?label=casechange

I use:

\usepackage[overload]{textcase}
(...)
\newcommand{\iemph}[1]{\MakeTextUppercase{#1}}
(...)
\begin{document}
XXX \iemph{abc def ghi}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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