5

I am writing a beamer. I got lots of Missing $ inserted \end{frame}. Where I havent missed any $. this is the part of the code I have used where similar error is shown

\begin{frame}
\begin{normalsize}
Sectors and angle of each sectors are shown in Table 1:

\begin{table}[hb]
\caption{Sectors and Sector Angle}
\label{Sectors and Sector Angle}
\vspace{0.35cm}
\centering
\begin{tabular}{|c|c|}
\hline \textbf{SECTOR} & \textbf{DEGREE} \\ 
\hline Sector 1 & -30\leq\theta_s\leq30 \\ 
\hline Sector 2 & 30\leq\theta_s\leq 90 \\ 
\hline Sector 3 & 90\leq\theta_s\leq 150 \\ 
\hline Sector 4 & 150\leq\theta_s\leq-150 \\ 
\hline Sector 5  & -150\leq\theta_s\leq-90 \\ 
\hline Sector 6 & -90\leq\theta_s\leq-30\\ 
\hline 
\end{tabular}
\end{table}
\end{normalsize}
\end{frame}
  • 3
    The right column should be in math mode $...$ – AboAmmar Jun 26 '17 at 13:26
  • Welcome to TeX.SX. When you are adding some code, you can either leave 4 whitespaces to each line or by selecting the code and clicking {} button to mark it as a code. That's what I've just did. – percusse Jun 26 '17 at 13:26
10

The right column in your table consists mainly of math formulas, so you need to add $ to the column specification. Instead of inserting $..$ at each cell, you can save typing by modifying the column specification as \begin{tabular}{|c|>{$}c<{$}|}.

A better visual alignment is to make the term theta_s at the center of the column, this is achieved via \begin{tabular}{|c|>{$}r<{$} @{${}\leq\theta_s\leq{}$} >{$}l<{$}|}. Now we have split the right column into two r and l and the expression {}\leq\theta_s\leq{} at the center. The two {} are there just to correct spacing around the binary operator \leq.

\documentclass[12pt,a4paper]{beamer}
\usepackage{lmodern,array}
\begin{document}

\begin{frame}
\begin{normalsize}
Sectors and angle of each sectors are shown in Table 1:

\begin{table}[hb]
\caption{Sectors and Sector Angle}
\label{Sectors and Sector Angle}
\vspace{0.35cm}
\centering
\begin{tabular}{|c|>{$}r<{$} @{${}\leq\theta_s\leq{}$} >{$}l<{$}|}
\hline \textbf{SECTOR} & \multicolumn{2}{c|}{\textbf{DEGREE}} \\ 
\hline Sector 1 &  -30 &   30 \\ 
\hline Sector 2 &   30 &   90 \\ 
\hline Sector 3 &   90 &  150 \\ 
\hline Sector 4 &  150 & -150 \\ 
\hline Sector 5 & -150 &  -90 \\ 
\hline Sector 6 &  -90 &  -30 \\ 
\hline 
\end{tabular}
\end{table}
\end{normalsize}
\end{frame}

\end{document}

enter image description here

|improve this answer|||||
  • 3
    Can you take a moment to explain what your code does? I certainly understand it, but maybe OP just sees a solution that works magically (given that OP stumbles over a missing $…$). – Huang_d Jun 26 '17 at 13:40
  • A small suggestion: the split r and l columns should still be set in math mode, so that you get proper minus signs for the negative numbers, instead of hyphens. (Compare the typesetting of \fbox{$-150$} and \fbox{-150} to see the difference.) – zwol Jun 26 '17 at 14:43
5

AboAmmar has explained how to fix the problem; this is a complementary answer, which explains the error message.

TeX generates the same error message, Missing $ inserted, for two very different circumstances:

  • You left out the closing $ on a math expression. This error gets reported at the point where you leave the "group" construct or paragraph that contains the opening dollar sign for the math expression.

  • You left out the opening $. This error gets reported at the point where you use a TeX primitive that is only allowed in math mode.

In both cases, the place where the $ should have been is almost always some distance before the place where TeX reports the error.

The error message you got looks like it's complaining about a missing closing $, because it's associated with \end{frame}, but the mistake you actually made is to write

-30\leq\theta_s\leq30

instead of

$-30\leq\theta_s\leq30$

(and similarly for the other rows) because \leq, \theta, and the subscript character _ can only be used in math mode.

I don't know why you only got a complaint at the point of \end{frame}; probably Beamer and/or the table machinery are doing something which causes the error not to be reported promptly.

|improve this answer|||||
  • Your explanation helped me to figure out that \widehat{=} should also be wrapped into $ sings. – San Droid Jan 10 '19 at 8:15

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.