5

I know this gets asked pretty often but I can not find my error. And since the code renders just fine I am really at odds here.

\begin{equation} 
 \frac{\Delta {f}}{f} = -\frac{\pi\textrm{r^3}}{W} \frac{\epsilon_r-1}{\epsilon_r+2}\epsilon_0{|{E_0}^2|}
 \label{eq. 5}
\end{equation}
  • 2
    Welcome to TeX.SE. – Sebastiano Sep 1 at 11:20
  • Is there any particular reason for wanting “r” in upright type? I see none. – egreg Sep 1 at 13:16
  • 2
    My supervisor. End of story. – julesc Sep 1 at 22:27
7

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

6

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}
  • 3
    I find \mathrm{r}^3 more elegant… – GuM Sep 1 at 11:25
  • @GuM But my English language is horrible :-(...ahhahaha. – Sebastiano Sep 1 at 11:28
  • Thanks. You are correct. I can only accept one answer. Sorry :(. – julesc Sep 1 at 11:46
  • @julesc Don't worry I'm very happy to help you a bit. The Zarko's answer is the best. – Sebastiano Sep 1 at 11:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.