TransWikia.com

Missing $ Inserted error thrown in a custom command

TeX - LaTeX Asked by Atharva Dubey on August 8, 2021

This is my first post on this community. I am fairly new to latex and have added a custom function using newcommand. The command is as follows –


newcommand{addQuestion}[6]{
    textbf{#1}. #2
    begin{multicols}{2}
    begin{enumerate}[label=(alpha*)]
    item #3
    item #5
    item #4
    item #6
    end{enumerate}
    end{multicols}
}

and my document is as –

begin{document}
begin{multicols}{2}
addQuestion{Q27}{a sample question}{This}{That}{this}{that}
end{multicols}
end{document}

The Error is thrown on the line with addQuestion which says

xAssignment.tex.swp:23: Missing $ inserted.
<inserted text> 
                $
l.23 ...a sample question}{This}{That}{this}{that}

I did browse through the previous posts but found nothing helpful. Could anyone please help me with this.
TIA

One Answer

In order to get an alphabetic numbering, you should type alph; alpha is the command to create the Greek letter α, which only works in math mode.

Note that you did not post a Minimal Working Example. I had to guess that you were using both the multicol and the enumitem packages. This will work:

documentclass{article}
usepackage{multicol}
usepackage{enumitem}
newcommand{addQuestion}[6]{
    textbf{#1}. #2
    begin{multicols}{2}
    begin{enumerate}[label=(alph*)]
    item #3
    item #5
    item #4
    item #6
    end{enumerate}
    end{multicols}
  }
begin{document}
addQuestion{Q27}{a sample question}{This}{That}{this}{that}
end{document}

Correct answer by José Carlos Santos on August 8, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP