TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm still pursuing my quest to code a better \widebar command. I can do bars over single characters quite well already, but I have problems when it comes to letter combinations such as AW. \overline{AW} produces

output of \overline{AW}

which doesn't look nice in my opinion: the bar extends too far to the left; it doesn't take the skew of the A into account.

To correct this, I must be able to find out the first character of the argument of my \widebar command. For AW this is easy, but I also would like to cover the following arguments:

  1. \mathcal{AW} or \mathcal{A}W (where \mathcal{A} is the first character),
  2. \sin x (where an upright s is the first character),
  3. \mathchar"0141 (which is just the character A from the standard math font),
  4. \left(a^2+b^2\right) (where some ( is the first character).

Maybe #4 is too tricky since a large ( might turn out to be a box and not a character. Of course, fractions and radicals shouldn't come up in the beginning of the argument; personally, I wouldn't want to overline such quantities.

So my question is: given a math list that starts with a character, can one find out what that first character is?

share|improve this question
you cant deconstruct a math list in classic tex, however you could grab the tokenlist and inspect it by hand, similar to the way bm deconstructs math expressions to build an equivalent bold version – David Carlisle Sep 12 '12 at 19:07
@David: Thanks, I had already feared that one has to do it the hard way. Maybe one can hack into bm to solve the problem? – Hendrik Vogt Sep 12 '12 at 19:16
bm is a delicate thing, treat it with care if hacking..... – David Carlisle Sep 12 '12 at 19:20
@David: OK :-) – Hendrik Vogt Sep 12 '12 at 19:21

This is more or less bm reconstructed a bit. It produces

First letter A in \symsymbols
First letter A in \symsymbols
First letter s in \symoperators
First letter A in 1
First letter ( 

On the examples given in the question.





\typeout{First letter #1 %
\ifx\fcmathgroup\relax\else in \expandafter\string\fcmathgroup\fi


%  \def\xgroup{#1}\show\xgroup

%  \def\xumathgroup{#1//#2//#3/#4}\show\xumathgroup



\uppercase{\fc@expand a}}






$\firstchar{\sin x}$


share|improve this answer
The \fc@mathchar@ part is the best. I got to the end, having skimmed the big ugly TeX arithmetic part, and thought "but what if the character is given by its code?" And there it is: \uppercase{a} gets a typesetting construct into the input. Clever! – Ryan Reich Mar 17 '13 at 15:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.