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




$ \argghhh a $ 


produces error (but NOT if \usepackage{amsmath} is commented out):

LaTeX Warning: Command \= invalid in math mode on input line 7.

! Please use \mathaccent for accents in math mode.
\add@accent ...@spacefactor \spacefactor }\accent 
                                                  #1 #2\egroup \spacefactor ...
l.7 $ \argghhh a

Clearly this is math mode. But it chooses (1) \=, hence NOT math mode, then (2) complains about \= in math mode!

share|improve this question

adding \tracingall you will see that \bar is selected but its argument is \else

\bar ->\protect \mathaccentV {bar}016

\mathaccentV #1#2#3#4#5->\ifmmode \gdef \macc@tmp {\macc@depth \@ne }\setbox \z
@ \hbox {\let \mathaccentV \macc@test \let \use@mathgroup \@gobbletwo \let \sel
ect@group \@gobblethree \frozen@everymath {}$#5$}\macc@tmp \ifnum \macc@depth =
\@ne \global \let \macc@nucleus \@empty \mathaccent "\accentclass@ \else \@xp \
macc@nested \fi #2#3#4{#5}\macc@nucleus \else \@xp \nonmatherr@ \csname #1\endc
sname \fi 

You need the \else to expand before \bar is called.


The reasons why you don't get an error without amsmath are mainly accidental related to the fact that in that case you get the TeX primitive argument scanning which differs from the way macro arguments are scanned.

share|improve this answer

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.