Since you mention capitalizing itemize
d labels, I'm assuming you're using
\begin{itemize}
\item[<label>] ...
\item[<label>] ...
...
\end{itemize}
If this is the case, you could just use the description
environment, and modify \descriptionlabel
- the macro that makes the description
environment labels:

\documentclass{article}
\renewcommand*\descriptionlabel[1]{\hspace\labelsep
\normalfont\bfseries\MakeUppercase{#1}}% Make description environment label bold/CAPITALIZED
\begin{document}
\noindent Here is some text
\begin{description}
\item[one] Here is some text
\item[two] Here is some more text
\item[three] Here is the final item
\end{description}
Here is some more text
\end{document}
You have to isolate the first token in #1
from the rest and uppercase it; the fact that \uppercase
doesn't expand anything and puts back the token list into the input stream after its operation can be exploited in the following way:
\newcommand{\mycommand}[1]{\mycommandaux#1\relax}
\def\mycommandaux#1#2\relax{%
\uppercase{\expandafter\gdef\csname #1}#2\endcsname{the macro #1#2 expanded}%
}
\mycommand{abc}
\show\Abc
Of course an empty argument to \mycommand
will result in an error.
If you want to provide a definition, say
\mycommand{abc}{Something else}
to be equivalent to \def\Abc{Something else}
, just leave out the tokens after \endcsname
\newcommand{\mycommand}[1]{\mycommandaux#1\relax}
\def\mycommandaux#1#2\relax{%
\uppercase{\expandafter\gdef\csname #1}#2\endcsname
}
\mycommand{abc}{Something else}
\show\Abc
The command \uppercase
is a bit stranger than other TeX primitives. Indeed the <general text>
it requires as argument first does a travel down TeX's stomach to be "regurgitated" after each character token has been transformed using the \uccode
vector: if a character has positive \uccode
, TeX will transform it into that character (the category code is unchanged). So, for instance, TeX is setup so that \uccode`a=`A
and so an a
becomes an A
after regurgitation. Non character token are left unchanged and no expansion is performed.
Here's the working in slow motion (first version).
\mycommand{abc}
Here #1
is abc
\mycommandaux abc\relax
Here #1
is a
and #2
is bc
(argument #2
is delimited by \relax
, while #1
is undelimited, so the only first token is grabbed)
\uppercase{\expandafter\gdef\csname a}bc\endcsname {the macro abc expanded}
Tex executes the \uppercase
and puts back
\expandafter\gdef\csname A
in the input stream.
\expandafter\gdef\csname Abc\endcsname{the macro abc expanded}
\gdef\Abc{the macro abc expanded}
Et voilà.
A variant with \newcommand
instead of \gdef
, that makes it easy to define macros with arguments:
\newcommand{\mycommand}[1]{\mycommandaux#1\relax}
\def\mycommandaux#1#2\relax{%
\uppercase{\expandafter\newcommand\csname #1}#2\endcsname
}
\mycommand{abc}{Something else}
\show\Abc
\mycommand{uvw}[1]{Something else with #1}
\show\Uvw
With \gdef
the standard parameter text should be used.
\newcommand{\mycommand}[1]{\mycommandaux#1\relax}
\def\mycommandaux#1#2\relax{%
\uppercase{\expandafter\gdef\csname #1}#2\endcsname
}
\mycommand{abc}{Something else}
\show\Abc
\mycommand{uvw}#1{Something else with #1}
\show\Uvw
Best Answer
The following is a solution which works with
hyperref
. Ifhyperref
is not loaded you can just use\lowercase
like this:\section{Foo \lowercase{no upper case} bar}
If
hyperref
is loaded this results in a warning ("Token not allowed in a PDF string...") and because of this we have to additionally use\texorpdfstring
. I defined a\titlelowercase
macro for this usage. Now you'd have to use\section{Foo \titlelowercase{no upper case} bar}
:You might as well use
\MakeTextLowercase
instead of\lowercase
. It is provided by thetextcase
package (which is loaded byabntex2
as well) and should handle some characters\lowercase
doesn't (as far as I know).