Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Macro to capitalize the first letter of a word

2,001 views
Skip to first unread message

Brian Aydemir

unread,
Nov 13, 2009, 10:44:59 AM11/13/09
to
Hi,

I'm working in LaTeX. Suppose that I have a macro defined by

\newcommand{\FOO}{\textsc{foo}}

How do I define macro, call it \upcase, such that

word --> word % nothing special here
\FOO --> \textsc{foo} % nothing special here
\upcase word --> Word % capital 'W'
\upcase \FOO --> \textsc{Foo} % capital 'F'

Thanks,
Brian

Kumaresh PS

unread,
Nov 14, 2009, 12:12:45 AM11/14/09
to
> How do I define macro, call it \upcase, such that
> \upcase word    --> Word          % capital 'W'

Hi Brian,

Please check my below methodology. It may helpful for you.

\documentclass{article}

\makeatletter
\def\upcase{\expandafter\makeupcase}
\def\makeupcase#1{\uppercase{#1}}

\newcommand{\FOO}{\textsc{\upcase foo}}
\makeatother

\begin{document}

\upcase word

\FOO

\end{document}

Kumaresh PS

Nicola Talbot

unread,
Nov 14, 2009, 6:51:08 AM11/14/09
to

You could try \makefirstuc in mfirstuc package. For example,
\makefirstuc{foo} will produce Foo and \makefirstuc{\textsc{foo}} will
produce \textsc{Foo}.

Regards
Nicola Talbot

--
Home: http://theoval.cmp.uea.ac.uk/~nlct/
LaTeX Related Information: http://theoval.cmp.uea.ac.uk/~nlct/latex/
Creating a LaTeX Minimal Example:
http://theoval.cmp.uea.ac.uk/~nlct/latex/minexample/

0 new messages