1

Here is my code in Overleaf:

\begin{equation}
\left(\begin{tabular}{l}\sum\limits_{i=0}^n\bigg |\sum\limits_{j=0}^ip_{j}-q_{j}\bigg | \geq \bigg | \sum\limits_{i=0}^n\sum\limits_{j=0}^ip_{j}-q_{j}\bigg | = \bigg | \sum\limits_{j=0}^n\sum\limits_{i=0}^jp_{j}-q_{j}\bigg |\\ = \bigg |\sum\limits_{j=0}^n(p_{j}-q_{j})(j+1)\bigg | = \bigg |\sum\limits_{j=0}^n j(p_{j}-q_{j}) + (p_{j}-q_{j})\bigg |\\
=   \bigg |\sum\limits_{j=0}^n jp_{j} - \sum\limits_{j=0}^n jq_{j}\bigg | = \bigg |\mu_{p} - \mu_{q}\bigg |\end{tabular}\right)
\end{equation}

It runs and produces the output I want, but it gives me a "Missing $ inserted" error, even though I was under the impression that $'s weren't necessary for math mode. Here is a more detailed error message when I make a mistake that for some reason leaves it unable to compile.

Error

I get the feeling that that mistake relates to the "Missing $" error, so now I want to see if I can rectify it.

Marcus Müller
  • 34,677
  • 4
  • 53
  • 94
Jason K.
  • 17
  • 3
  • That latex code is completely impossible to read and reason about. You need to help yourself a lot here, by starting to simply use line breaks! There's no need to have everything on one line. – Marcus Müller Oct 31 '21 at 18:35

1 Answers1

0

A tabular is for text, thus the cells of a tabular will be in text mode and you will correctly get errors if you use math content without $ or similar within them.

You could e.g. use aligned instead:

\documentclass{article}

\usepackage{mathtools}

\begin{document}

\begin{equation}
\left(\begin{aligned}
&\sum\limits_{i=0}^n\bigg |\sum\limits_{j=0}^ip_{j}-q_{j}\bigg | \geq \bigg | \sum\limits_{i=0}^n\sum\limits_{j=0}^ip_{j}-q_{j}\bigg | = \bigg | \sum\limits_{j=0}^n\sum\limits_{i=0}^jp_{j}-q_{j}\bigg |\\
& = \bigg |\sum\limits_{j=0}^n(p_{j}-q_{j})(j+1)\bigg | = \bigg |\sum\limits_{j=0}^n j(p_{j}-q_{j}) + (p_{j}-q_{j})\bigg |\\
&=   \bigg |\sum\limits_{j=0}^n jp_{j} - \sum\limits_{j=0}^n jq_{j}\bigg | = \bigg |\mu_{p} - \mu_{q}\bigg |
\end{aligned}\right)
\end{equation}


\end{document}