LaTeX forum ⇒ Math & ScienceRightarrow gives Missing $ inserted error Topic is solved

Information and discussion about LaTeX's math and science related features (e.g. formulas, graphs).
thinkpadder
Posts: 5
Joined: Fri May 21, 2021 12:01 pm

Rightarrow gives Missing $ inserted error

Postby thinkpadder » Sun Jun 06, 2021 6:00 pm

On this very basic math formula:

\documentclass[a5paper,12pt]{article}
\usepackage{amsmath}
\begin{document}

if $n = 0$ then $a_n = 0$; if $n \geq 1$ then $a_n = 1$ 

\end{document}


I'd like to replace the if and then words with one \Rightarrow so that it will look better

but when I do it and write:

\documentclass[a5paper,12pt]{article}
\usepackage{amsmath}
\begin{document}

$n = 0$ \Rightarrow $a_n = 0$; $n \geq 1$ \rightarrow $a_n = 1$ 

\end{document}


it gives error (using Miktex pdflatex. exe or xelatex.exe)

! Missing $ inserted.
<inserted text>
                $
l.5 $n = 0$ \Rightarrow
                        $a_n = 0$; $n \geq 1$ \rightarrow $a_n = 1$
?


Considering \Rightarrow is found inside the amssymb package I add \usepackage{amssymb} but the same error.

How to add \Rightarrow inside those math expressions?

User avatar
Ijon Tichy
Posts: 502
Joined: Mon Dec 24, 2018 10:12 am

Postby Ijon Tichy » Sun Jun 06, 2021 6:19 pm

Just stay in math mode for the whole formula:
\documentclass[a5paper,12pt]{article}
\usepackage{amsmath}
\begin{document}

Use either:
$n = 0 \Rightarrow a_n = 0; n \geq 1 \rightarrow a_n = 1$ 
for an inline formula or
\[ 
n = 0 \Rightarrow a_n = 0; n \geq 1 \rightarrow a_n = 1
\]
for displayed math.

\end{document}


BTW: You don't need amsmath for this. Nevertheless amsmath is a recommended package for math. I even would recommend mathtools, an extension of amsmath. See the manuals for more information.

thinkpadder
Posts: 5
Joined: Fri May 21, 2021 12:01 pm

Postby thinkpadder » Sun Jun 06, 2021 7:00 pm

Ijon Tichy wrote:Just stay in math mode for the whole formula

Ops! Yep! Just couldn't imagine that those extra $'s were causing the error. Thanks.


Return to “Math & Science”

Who is online

Users browsing this forum: No registered users and 4 guests