Capilatizing the first character

37 views
Skip to first unread message

Vittorio

unread,
Nov 6, 2003, 11:03:03 AM11/6/03
to
What package should I use to make the **first** character of a string
a capital one?

This could be useful when I use, for instance, textmerg and need to
capitilize the first part of a \Fields...

Ciao
Vittorio

Markus Kohm

unread,
Nov 6, 2003, 11:06:26 AM11/6/03
to
Vittorio wrote:

> What package should I use to make the **first** character of a string
> a capital one?

--> <news:1416048.e...@ID-107054.user.dfncis.de> three days ago.

Markus

Vittorio

unread,
Nov 6, 2003, 3:31:37 PM11/6/03
to

Markus,
I can't reach the link. Are you sure about it?
Vittorio

Ben

unread,
Nov 6, 2003, 3:57:17 PM11/6/03
to

"Vittorio" <vic...@none.it> wrote in message news:Jcyqb.427100 >

> I can't reach the link. Are you sure about it?

----[message]----

mng wrote:

> In a book that I am writing, I would like to put all headings at
> \section{} level and below into lower case letters, except for the first
> letter which should be upper case

\documentclass{book}

\makeatletter
\newcommand*{\@Sect}{}
\let\@Sect\@sect
\def\@sect#1#2#3#4#5#6[#7]#8{%
\@Sect{#1}{#2}{#3}{#4}{#5}{#6}[{#7}]{\XMakeLowercase{#8}}%
}
\DeclareRobustCommand*{\XMakeLowercase}[1]{%
\expandafter\@XMakeLowercase#1\end}
\newcommand{\@XMakeLowercase}{}
\def\@XMakeLowercase#1#2\end{#1\MakeLowercase{#2}}
\makeatother

\begin{document}
\chapter{Test Test}
\section{Test TEST}
\subsection{TEST TEST}
\end{document}

Markus

----[end of message]----

HTH, HAND, Ben

--
Real address: first name at robotics dot stanford dot edu


Saravanan,M.

unread,
Nov 6, 2003, 10:31:05 PM11/6/03
to
I think you ask about the drop cap:

The following is the format for make the dropcap:

\usepackage{drop}

\drop{T}his is a test.

I think the above is your requirement. If not so pl confirm me.

Best of Luck
Saravanan,M.
India


"Ben" <lo...@my.sig.invalid> wrote in message news:<boecje$oc8$1...@news.Stanford.EDU>...

Danie Els

unread,
Nov 7, 2003, 7:20:17 AM11/7/03
to
vi...@email.it (Vittorio) wrote in message news:<c942feb2.03110...@posting.google.com>...

Here is a wonderfull (magical) macro posted by Dan Leucking a long
time ago.

\def\FirstcapD#1#2\delimiter{%%% Delimited
\iffalse{\fi
\uppercase{\edef\Fcap{\iffalse}\fi#1}#2}}%

or

\newcommand*\Firstcap[1]{%%% Argument
\expandafter\FirstcapD#1\delimiter
\Fcap}

Use it as \FirstcapD string.... \delimiter. The string with the first
letter capitalized is then returned in \Fcap for example:

\FirstcapD string\delimiter\Fcap -> String

The power of it is that \Fcap contains {String} and not
{\uppercase{s}tring}

NB: Can the gurus please explain this macro. I understand the basics
of the \iffalse{\fi dirty tricks (TeXBook p385) but this one is realy
dirty.

Danie Els
(dnjels at sun dot ac dot za)

Dan Luecking

unread,
Nov 7, 2003, 3:29:34 PM11/7/03
to
On 7 Nov 2003 04:20:17 -0800, dnj...@netscape.net (Danie Els) wrote:

>vi...@email.it (Vittorio) wrote in message news:<c942feb2.03110...@posting.google.com>...
>> What package should I use to make the **first** character of a string
>> a capital one?
>>
>> This could be useful when I use, for instance, textmerg and need to
>> capitilize the first part of a \Fields...
>>
>> Ciao
>> Vittorio
>
>Here is a wonderfull (magical) macro posted by Dan Leucking a long
>time ago.

This is so magical that I don't even remember posting it.

>
>\def\FirstcapD#1#2\delimiter{%%% Delimited
> \iffalse{\fi
> \uppercase{\edef\Fcap{\iffalse}\fi#1}#2}}%

When expanded, \FirstcapD string\delimiter gives

\iffalse{\fi
\uppercase{\edef\Fcap{\iffalse}\fi s}tring}

The first "{" is discarded because \iffalse is always false, and then
\uppercase is executed on
{\edef\Fcap{\iffalse}\fi s}
Everything in there is a command, except the "s", so nothing is
uppercased except the "s". Now we have
\edef\Fcap{\iffalse}\fi String}
Normally this would have unbalanced braces, but an \edef expands as it
reads, and so the first right brace is skipped and we have \Fcap defined
to be String. Note that
\def\x{string}
\FirstcapD \x\delimiter

Wouldn't produce String since now \x is the argument, and \uppercase
won't change commands.

>
>\newcommand*\Firstcap[1]{%%% Argument
> \expandafter\FirstcapD#1\delimiter
> \Fcap}

This gets around the last problem by trying to expand the argument
before processing it with \FirstcapD. Neither of these is very robust.
\Firstcap would generate an error on first use in most moving arguments
and and incorrect result on second and third use in such places.


>
>Use it as \FirstcapD string.... \delimiter. The string with the first
>letter capitalized is then returned in \Fcap for example:
>
> \FirstcapD string\delimiter\Fcap -> String
>
>The power of it is that \Fcap contains {String} and not
>{\uppercase{s}tring}

In some settings, the second might be preferred, and is often just
as good. I would guess I answered a post wanting the first behavior.

>
>NB: Can the gurus please explain this macro. I understand the basics
>of the \iffalse{\fi dirty tricks (TeXBook p385) but this one is realy
>dirty.

I deny that there is anything dirty about my tricks. They are all as
pure as the driven snow. Just ask my mother. :-)

Dan\def\xp#1#2{#2#1} L\xp eucking

--
Dan Luecking Department of Mathematical Sciences
University of Arkansas Fayetteville, Arkansas 72701
luecking at uark dot edu

Reply all
Reply to author
Forward
0 new messages