$$ = \sum_{e \in A} w(e)
   = \sum_{e \in A} w(e)+ \sum_{e \in \{(r,v)| v \in V(G)\}} w(e) 
   = w( \~{A} ) $$

I get the following error message:

Error: Please use \mathaccent for accents in math mode for the following code

I'm not sure what's wrong with it. I'm in math mode by using $$ $$, am I not?

  • 2
    Are you using Plain TeX or LaTeX?
    – egreg
    Dec 7, 2015 at 12:59

4 Answers 4


The immediate problem is solved by replacing the text-mode instruction \~{A} with the math-mode directive \tilde{A}.

You may also want to make the equation both more compact and more readable by (a) introducing a line break in the material set below the third \sum symbol (via a \substack instruction) and (b) eliminating the whitespace that's otherwise inserted to the left and right of that summation symbol (via a \mathclap instruction).

enter image description here

Addendum: For the sake of completeness/reference, here's a list of common accents and how they should be produced in text and math mode, respectively. Note that the positions and, in the case of text-upright versus text-italic font shapes, even the shapes of the accents can differ between text and math modes. In math mode, in contrast, the shapes of the math-accent characters are the same regardless of whether \mathrm ("math roman") or \mathit ("math italics" -- the default) is in effect.

enter image description here

\usepackage{mathtools} % for "\mathclap" macro; loads "amsmath" package
   = \sum_{e \in A} w(e)
   = \sum_{e \in A} w(e) + 
     \sum_{\mathclap{\substack{e \in \{(r,v)\} \\ \text{s.t.}\, v \in V(G)}}} w(e) 
   = w(\tilde{A}) 

\newcolumntype{C}{>{$}c<{$}} % automatic-math version of "c" column type
\begin{tabular}{@{} l c c >{\itshape}c l C C @{}}
Accent name & \multicolumn{3}{c}{Text mode} 
            & \multicolumn{3}{c@{}}{Math mode} \\
\cmidrule(lr){2-4} \cmidrule(l){5-7}
            & how to & \multicolumn{2}{c}{result} 
            & how to & \multicolumn{2}{c@{}}{result} \\
acute             & \verb|\'| & \'A & \'A & \verb|\acute| & \acute{\mathrm{A}} & \acute{A} \\
grave             & \verb|\`| & \`A & \`A & \verb|\grave| & \grave{\mathrm{A}} & \grave{A} \\
circumflex        & \verb|\^| & \^A & \^A & \verb|\hat|   & \hat{\mathrm{A}}   & \hat{A}   \\
squiggle, tilde   & \verb|\~| & \~A & \~A & \verb|\tilde| & \tilde{\mathrm{A}} & \tilde{A} \\
macron, bar       & \verb|\=| & \=A & \=A & \verb|\bar|   & \bar{\mathrm{A}}   & \bar{A}   \\
dot accent        & \verb|\.| & \.A & \.A & \verb|\dot|   & \dot{\mathrm{A}}   & \dot{A}   \\
diereris, Umlaut  & \verb|\"| & \"A & \"A & \verb|\ddot|  & \ddot{\mathrm{A}}  & \ddot{A}  \\
breve             & \verb|\u| &\u{A}&\u{A}& \verb|\breve| & \breve{\mathrm{A}} & \breve{A} \\
caron, check, v-check&\verb|\v|&\v{A}&\v{A}&\verb|\check| & \check{\mathrm{A}} & \check{A} \\
ring              & \verb|\r| &\r{A}& \r{A}&\verb|\mathring|&\mathring{\mathrm{A}}& \mathring{A}\\
  • Thank you for the answer. It's very helpful. May I ask a separate question about Tex code you give for the table? What does @{} do? How do you align "Math Mode" with second "How to"?
    – Christin
    Sep 15, 2016 at 23:07
  • @Christin - The @{} directives serve to suppress the vertical whitespace (in the amount of \tabcolsep) that would otherwise be inserted at the left-hand and right-hand edges of the tabular environment. To left-align the "Math mode" header with the right-hand "how to" header, change \multicolumn{2}{c@{}}{Math mode} to \multicolumn{2}{l@{}}{Math mode}.
    – Mico
    Sep 16, 2016 at 0:33

Text accents and math accents have different syntax in LaTeX: to get Ã, you would use \~{A} in textmode, but \tilde A or \widetilde A (the latter for a wider version) in mathmode.

Here is a table showing how to get different kinds of accents in textmode and mathmode.

Thus, your corrected code is

= \sum_{e \in A} w(e) = \sum_{e \in A} w(e)+ \sum_{e \in {(r,v)| v \in V(G)}} w(e) = w( \tilde A )
  • While you're at it, you should also replace | with \mid. The spacing around the two symbols is quite different.
    – Mico
    Dec 7, 2015 at 6:16
  • Or use a better construction for set syntax. \mid is not the proper symbol to use in general as it cannot be scaled (when needed). But useful as a one of.
    – daleif
    Dec 7, 2015 at 6:26
  • @daleif: a bar in the middle is the way I generally denote set syntax in writing, and I try to keep that notation in LaTeX. What would I use to make it scale when needed? Dec 7, 2015 at 16:55
  • 1
    These days I tend to use this construction: tex.stackexchange.com/a/150516/3929, the idea behind it is (1) if I choose to use a bar syntax, I'd like it to be scalable along with the braces. (2) the spacing should be fully configurable from the preamble, not something that is manually inserted each time. (3) the input syntax should not be dependent on the choice for "given" symbol (here a bar), the syntax should make sense no matter the output symbol. (4) I want to get the scaller macros out of the way. In this construction "*" means autoscalling, and [\big] us manually scaled.
    – daleif
    Dec 7, 2015 at 18:39

I solved the issue by replacing \~{A} with \tilde{A}.

  • 3
    Your answer has already been provided by Mico, hasn't it? Jul 12, 2016 at 10:13

Just use the package lmodern.




$$ y = w( \~{A} ) $$

You can also disregard the use of \verb=\~{A}= and use à directly, like the example below:

$$ y = w( Ã ) $$   


enter image description here

  • 1
    You get LaTeX Warning: Command \~ invalid in math mode and moreover the A is not in math italic. Is it so difficult to use \tilde{A}, which is the proper markup?
    – egreg
    Apr 4, 2019 at 20:30
  • Yes, Kurt, you're right. I didn't see that before posting here. At Mico's answer, however, the usage of lmodern package is not explicit from the beginning. Thank you for the welcome.
    – Roberto
    Apr 6, 2019 at 1:50
  • There's no need to load the lmodern package in order to generate $\tilde{a} \hat{b} \check{c}$ etc
    – Mico
    Feb 6 at 15:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .