Re: Bug in ETeX



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
.



Relevant Pages

  • Re: Bug in ETeX
    ... because the whole section header is passed as an argument. ... Now suppose the user want to make the title uppercase, ... I want to provide the user a macro ... Even if there is a more elegant solution, I would be pleased to know ...
    (comp.text.tex)
  • Re: What is the gain of "inline"
    ... >> If it's trivial enough that being in a header makes sense make it a ... >> macro and uppercase. ... winter, cwi, science park 123, 1098 xg amsterdam, nederland, +31205924131 ...
    (comp.lang.c)
  • Re: What is the gain of "inline"
    ... >> If it's trivial enough that being in a header makes sense make it a ... >> macro and uppercase. ... > have fewer pitfalls than macros. ...
    (comp.lang.c)
  • Re: Spell Check Protected Form with Bookmarks
    ... Should I add it to a run macro on ... Bookmarks are not set to calculate on exit. ... it sets the Language setting back to do not spell check for the ...
    (microsoft.public.word.spelling.grammar)
  • Re: Spell Check Protected Form with Bookmarks
    ... Microsoft's Legal Users' Guide) http://addbalance.com/usersguide ... I'm by no means a Word or Macro expert so I don't know how to ... Bookmarks are not set to calculate on exit. ... because the text fields get set back to not spell check and it does not ...
    (microsoft.public.word.spelling.grammar)