2

I am trying to input some equations in my latex document, the first equation is fine, and the first equation number is shown on the side but for the second equation, the equation number is out of place as shown in the provided picture. I believe it is a formatting issue, any help would be appreciated.

\documentclass[12pt]{article}
\usepackage{array}
\usepackage{forest}
\usepackage{gensymb}
\usepackage{caption}
\usepackage{graphicx}
\usepackage{multirow}
\usepackage{hyperref}
\usepackage{booktabs}
\usepackage{blindtext}
\usepackage{algorithm}
\usepackage{subcaption}
\graphicspath{{figures/}}
\usepackage{algpseudocode}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[intoc]{nomencl}
\usepackage[nottoc]{tocbibind}

\usepackage{cite}
\usepackage[numbers]{natbib}



\begin{document}





\begin{equation}
PL_{LoS} = 20{\log}d + 20{\log}f + 20{\log}(\frac{4{\pi}}{c}) + \eta_{LoS}
\end{equation}

\begin{equation}
PL_{NLoS} = \underbrace{20{\log}d + 20{\log}f + 20{\log}(\frac{4{\pi}} 
{c})}_\textrm{FSPL} + \underbrace{\eta_{NLoS}}_{\textrm{{\eta}{\xi}}}
\end{equation}

\end{document}

My output

5
  • 1
    please try to make more reasonable examples, do you need forest package to show the problem? Nov 30, 2023 at 12:51
  • Never ignore errors, if you get an error ask about the error message (! Missing $ inserted. here) any pdf produced after an error is not intended to be usable. Nov 30, 2023 at 12:53
  • ok, thanks will try to get the errors sorted first
    – aniket32
    Nov 30, 2023 at 12:55
  • The forest package is for another part of my document, I included all the packages I used to make sure that there are no mistakes with the packages I have in my document.
    – aniket32
    Nov 30, 2023 at 12:57
  • please don't do that, it makes it harder for people to trace what tex is doing and answer your question, you can easily tell before posting that none of the packages listed are related to the error Nov 30, 2023 at 13:57

2 Answers 2

4

None of the 18 [!] packages that are loaded in the OP's code are needed to typeset the equations. Worse, some of those packages are mutually incompatible, such as the cite and natbib packages. The only package that's really needed here is amsmath -- which, oddly, isn't among the 18 selected by the OP.

Please rid yourself of the dreadful habit of encasing all instances of \log in curly braces. It's not only unnecessary, it's actually counterproductive as it badly messes up the spacing. Please also consider replacing (\frac{4{\pi}}{c}) with (4\pi/c) -- please no curly braces around \pi (or \xi!) either -- for the two equations at hand.

Last but not least, here's a suggestion already made by David Carlisle: Do replace {\textrm{{\eta}{\xi}} with {\eta\xi}. Aside: Why would you want to render the math-mode-only symbols \eta and \xi in text mode?

enter image description here

\documentclass[12pt]{article}
\usepackage{amsmath} % only package needed here

\begin{document}

\begin{align}
PL_{\mathrm{LoS}}  &= 20\log d + 20\log f + 20\log(4\pi/c) + \eta_{\mathrm{LoS}} \\
PL_{\mathrm{NLoS}} &= {\underbrace{20\log d + 20\log f + 20\log(4\pi/c)}_{\mathrm{FSPL}}} 
                     + \underbrace{\eta_{\mathrm{NLoS}}}_{\eta\xi}
\end{align}

\end{document}
4

Your document produces

! Missing $ inserted.
<inserted text> 
                $
l.37 ...erbrace{\eta_{NLoS}}_{\textrm{{\eta}{\xi}}
                                                  }
? 

(no pdf after an error is usable)

\textrm makes a box with nested text so does not allow math commands like \eta

Just use

_{\eta\xi}

not

_{\textrm{{\eta}{\xi}}

You must log in to answer this question.

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