Re: Bug in ETeX
- From: noirel@xxxxxxxxxxxxxx (Josselin Noirel)
- Date: Wed, 28 Mar 2007 17:32:50 +0000 (UTC)
M.Bensimhoun@xxxxxxxxx wrote in message
<1175100909.058433.255180@xxxxxxxxxxxxxxxxxxxxxxxxxxx>:
Suppose I have designed a macro \section#1 to display section headers,
such that it puts also these headers into bookmarks via \special.
Now suppose the user want to make the title uppercase, but don't want
(this is legitime) to put it uppercase by hand. I provide the user a
toks \everysectionheader that is put automatically at the begining of
the header of each section header. I want to provide the user a macro
\capital, so that he may be able to type \everysectiontoks={\capital}
and get what he want. But of course, that takes into account the
bookmarks.
Is \capital supposed to take an argument? If so, I wouldn't put it in
any \everywhatsoever register. Usually a token register isn't supposed
to release any command taking any argument.
It I were to do that, I would simply have a switch that the user could
turn on or turn off to put the bookmarks in capitals.
\newif \ifcapitalisedbookmarks
and use the method I told you before. As a matter of fact \uppercase is
not expandable, and we have live with it.
Even if there is a more elegant solution, I would be pleased to know
about this macro, because I seek the solution of this problem
sufficiently long.
If you're aiming at developing a format, you should be aware that
elegance is not the only issue, the character replacement procedure is
extremely fragile too. If a feature of your format is hardly reliable,
it's better not including it. Well, OK, I give you the answer being
pretty sure that you will come back because it fails most of the time.
The argument of this macro cannot contain any group {...} nor any macro.
If you thought it's restrictive, I would agree.
\documentclass{article}
\makeatletter
\newcommand*{\xuppercase}[1]{\XUPPER@protectspaces {}#1 \@empty}
\def \XUPPER@protectspaces #1#2 #3{%
\ifx #3\@empty
\expandafter \@firstoftwo
\else
\expandafter \@secondoftwo
\fi
{\XUPPER@doupper #1#2\XUPPER@doupper}%
{\XUPPER@protectspaces{#1#2\ignorespaces}#3}%
}
\def \XUPPER@doupper #1{%
\ifx \ignorespaces #1%
\space
\expandafter \XUPPER@doupper
\else
\ifcsname XUPPER@map@\detokenize{#1}\endcsname
\csname XUPPER@map@\detokenize{#1}\endcsname
\expandafter \expandafter \expandafter \XUPPER@doupper
\else
#1%
\expandafter \expandafter \expandafter \XUPPER@doupper
\fi
\fi
}
\expandafter
\def \csname XUPPER@map@\detokenize{\XUPPER@doupper}\endcsname
#1#2#3#4{}
\def \XUPPER@map@a {A} \def \XUPPER@map@j {J} \def \XUPPER@map@s {S}
\def \XUPPER@map@b {B} \def \XUPPER@map@k {K} \def \XUPPER@map@t {T}
\def \XUPPER@map@c {C} \def \XUPPER@map@l {L} \def \XUPPER@map@u {U}
\def \XUPPER@map@d {D} \def \XUPPER@map@m {M} \def \XUPPER@map@v {V}
\def \XUPPER@map@e {E} \def \XUPPER@map@n {N} \def \XUPPER@map@w {W}
\def \XUPPER@map@f {F} \def \XUPPER@map@o {O} \def \XUPPER@map@x {X}
\def \XUPPER@map@g {G} \def \XUPPER@map@p {P} \def \XUPPER@map@y {Y}
\def \XUPPER@map@h {H} \def \XUPPER@map@q {Q} \def \XUPPER@map@z {Z}
\def \XUPPER@map@i {I} \def \XUPPER@map@r {R}
\makeatother
\begin{document}
\message{\xuppercase{Foo bar baz}}
\end{document}
--
Joss
.
- Follow-Ups:
- Re: Bug in ETeX
- From: M . Bensimhoun
- Re: Bug in ETeX
- From: M . Bensimhoun
- Re: Bug in ETeX
- From: M . Bensimhoun
- Re: Bug in ETeX
- References:
- Bug in ETeX
- From: M . Bensimhoun
- Re: Bug in ETeX
- From: M . Bensimhoun
- Re: Bug in ETeX
- From: Josselin Noirel
- Re: Bug in ETeX
- From: M . Bensimhoun
- Re: Bug in ETeX
- From: Josselin Noirel
- Re: Bug in ETeX
- From: M . Bensimhoun
- Bug in ETeX
- Prev by Date: Re: left aligning captions with \table
- Next by Date: Re: Bug in ETeX
- Previous by thread: Re: Bug in ETeX
- Next by thread: Re: Bug in ETeX
- Index(es):
Relevant Pages
|