Missing $ inserted. Extra }, or forgotten $. Missing } inserted

The \textrm{...} command converts the contents of command to text mode, consequently r^3 cannot work. Instead it you should use \marthrm{r^3} as suggested @Sebastiano in his answer (+1) or better and more correct \mathrm{r}^3 as suggested @GuM in his comment. However, I wonder why you like to write variable in roman shape. They are usually written in italic shape. So to my opinion is better write your equation as follows:

\documentclass{article}
\usepackage{mathtools}
\DeclarePairedDelimiter\abs{\lvert}{\rvert} % new, it better align vertical bars

\begin{document}
\begin{equation}
 \frac{\Delta{f}}{f} 
    = - \frac{\pi r^3}{W} 
        \frac{\epsilon_r - 1}{\epsilon_r + 2}\epsilon_0 \abs*{E_0^2}
 \label{eq. 5}
\end{equation}
\end{document}

which gives:

enter image description here

If you persist to use upshape r, than you need to be consistent:

\documentclass{article}
\usepackage{mathtools}
\DeclarePairedDelimiter\abs{\lvert}{\rvert}

\begin{document}
\begin{equation}
 \frac{\Delta{f}}{f} 
    = - \frac{\pi \mathrm{r}^3}{W} 
        \frac{\epsilon_{\mathrm{r}} - 1}{\epsilon_{\mathrm{r}} + 2}\epsilon_0 \abs*{E_0^2}
 \label{eq. 5}
\end{equation}
\end{document}

which gives:

enter image description here


Often it is very important to put a complete code starting from \documentclass{...} to \end{document}. There are two mistakes: \label{eq.5} into the formula e when you use a formula the correct syntax is: \mathrm instead of \textrm. After my humble suggestion: use \epsilon_{0} instead of \epsilon_0, it is very important for the future.

enter image description here

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath,amssymb}
\begin{document}\label{eq.5}
\begin{equation} 
 \frac{\Delta {f}}{f} = -\frac{\pi\mathrm{r^3}}{W} \frac{\epsilon_r-1}{\epsilon_r+2}\epsilon_0{|{E_0}^2|}
\end{equation}
\end{document}

Tags:

Math Mode