2

I don't understand why "Missing $ inserted error" is occurring. The output table won't even show. At first, the output was fine with $$ inserted at both ends. and now it's messed up all the tables in the file. and it is not even in the output.

\begin{table}
\centering
\caption{Lexical Unification of Roman Urdu}
\begin{tabular}{l} 
\hline
Algorithm: \\ \hline
\begin{tabular}[c]{@{}l@{}}1.~~~~~ Maintain a CSV file of scrapped data  \\2.~~~~~ Clean the data by removing \\~ ~ ~ ~ ~a.~~~~~ @mentions, \#hashtags, URLs, and Unicode characters. \\~ ~ ~ ~ ~b.~~~~~ White spaces and from the start and end of the line. \\~ ~ ~ ~ ~c.~~~~~ Non-English, numeric values, and special symbols. \\3.~~~~~ Read the CSV file  \\4.~~~~~ Compute a list F of the most frequently occurring words \\~ ~ ~ ~ ~a.~~~~~ 
$$\sum_{i=1}^n(\text{string}S)$$
\\5.~~~~~ Select strings with the highest frequency  \\~ ~ ~ ~ ~a.~~~~~ 
\begin{equation}
\operatorname{MAX}\left[\sum_{i=1}^n(\operatorname{string} S)\right]
\end{equation}
\\6.~~~~~ Create a list of vowels V \\7.~~~~~ Compare each string to the list of vowels \\~ ~ ~ ~ ~a.~~~~~ Convert strings to lowercase \\~ ~ ~ ~ ~b.~~~~~ For each x in input string S \\~ ~ ~ ~ ~c.~~~~~ If x is in V \\~ ~ ~ ~ ~ ~ ~ ~ ~ i.~~~~ Replace it with empty space  \\~ ~ ~ ~ ~d.~~~~~ Else  \\~ ~ ~ ~ ~ ~ ~ ~ ~ i.~~~~ Retain it as it is \\8.~~~~~ Replace all instances of the original string in the CSV file \\ ~ ~ ~ ~ ~ with the resultant string with vowels removed.\end{tabular}  \\
\hline
\end{tabular}
\label{tab: 100}
\end{table}

enter image description here

2
  • You can't use display math in a tabular cell unless you put it in inside something like a \parbox or use a cell type that introduces paragraph mode (p, m, tabularx's X, etc.). Inline math should also work. Why are you using a tabular at all though? Wouldn't just nested enumerate environments make more sense for this kind of list? Or even use one of the packages specifically for algorithms? Incidentally, you should never use $$ at all in LaTeX; use \[..\] instead: see here.
    – frabjous
    Commented Oct 6, 2022 at 11:37
  • 1
    never do \\ ~ ~ ~ ~ what is the intention there? Commented Oct 6, 2022 at 11:45

2 Answers 2

3

$$ in this context is like $ $ and produces an empty inline math, so the following \sum is met in text mode and gives the error you show.

Use

$\displaystyle\sum_{i=1}^n(\text{string}S)$

or possibly better

$\displaystyle\sum_{i=1}^{n}(\mathrm{string}S)$
2

Your problem is solved by @David Carlisle's answer (+1) so here is an off-topic suggestion how can you write your table on more consistent way:

\documentclass[oneside,onecolumn]{article}

\begin{document}
    \begin{table}
\centering
\caption{Lexical Unification of Roman Urdu}
\begin{tabular}{@{} l p{28em} @{}}
    \hline
    & Algorithm:        \\ 
    \hline
1.  & Maintain a CSV file of scrapped data  \\
2.  & Clean the data by removing            \\ 
    & \begin{tabular}{@{} c l}
        a.  & @mentions, \#hashtags, URLs, and Unicode characters.  \\
        b.  & White spaces and from the start and end of the line.  \\
        c.  & Non-English, numeric values, and special symbols.     \\
      \end{tabular}         \\
3.  &  Read the CSV file  q \\
4.  & Compute a list F of the most frequently occurring words \\
    & \begin{tabular}{@{} c l}
        a.  & $\displaystyle\sum_{i=1}^n(\mathrm{string}S)$  \\
      \end{tabular}         \\
5.  & Select strings with the highest frequency  \\
    & \begin{tabular}{@{} c l}
        a.  & $\displaystyle\max\left[\sum_{i=1}^n(\mathrm{string} S)\right]$ \\
      \end{tabular}             \\
6.  & Create a list of vowels V \\
7.  & Compare each string to the list of vowels \\
    & \begin{tabular}{@{} c l}
        a.  & Convert strings to lowercase \\
        b.  & For each x in input string S \\
        c.  & If x is in V \\
            &\quad   i Replace it with empty space  \\
            &   Else  \\
            &\quad   Retain it as it is
      \end{tabular}            \\
8.  & Replace all instances of the original string in the CSV file
      with the resultant string with vowels removed.    \\
    \hline
\end{tabular}
\label{tab: 100}
    \end{table}
\end{document}

enter image description here

2
  • But my output is different, i have so much space between the rows. My document class is following \documentclass[oneside,onecolumn]{article}
    – Samia Aziz
    Commented Oct 6, 2022 at 12:40
  • @SamiaAziz, I do not know, how you test my MWE (Minimal Working Example). It gives the same result with your settings of document class. You should have in your document some settings which mage more space between text lines.
    – Zarko
    Commented Oct 6, 2022 at 12:49

You must log in to answer this question.

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