Trying to use "\~" to generate tilde symbol in math mode
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).
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.
\documentclass{article}
\usepackage{mathtools} % for "\mathclap" macro; loads "amsmath" package
\begin{document}
\[
= \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})
\]
\end{document}
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{booktabs,array,lmodern}
\newcolumntype{C}{>{$}c<{$}} % automatic-math version of "c" column type
\begin{document}
\begin{tabular}{@{} l c c >{\itshape}c l C C @{}}
\toprule
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} \\
\midrule
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}\\
\bottomrule
\end{tabular}
\end{document}
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 )
I solved the issue by replacing \~{A}
with \tilde{A}
.