1

I checked out this page and they have very good answers but not exactly what I'd need. I would want the justification to be like it is in the answer they gave with everything in one line touching the margins but would like to make a new command for it instead of typing everything each time. Something like it is given in this page

\choice{apple}{banana}{orange}{pear}

So I tried defining a command like

\documentclass[a4paper,addpoints,answers,12pt]{exam}
\usepackage{graphicx,tabularx,caption,color,subcaption,amsmath,amssymb,lmodern,textcomp,gensymb,ifpdf,ifthen}

\newcommand{\mcq}{%
    \begin{oneparchoices}
        \choice #1
        \choice #2
        \choice #3
        \choice #4
        \choice #5
    \end{oneparchoices}
}
    \begin{document}
        \mcq{uihoo}{eifhw2u}{fiwuhr}{fjwhf}{fnweir}
    \end{document}

But this has too many errors:

line 12: Illegal parameter number in definition of \mcq. }
line 12: Illegal parameter number in definition of \mcq. }
line 12: Illegal parameter number in definition of \mcq. }
line 12: Illegal parameter number in definition of \mcq. }
line 12: Illegal parameter number in definition of \mcq. }
line 14: You can't use `macro parameter character #' in horizontal mode. \mcq
line 14: You can't use `macro parameter character #' in horizontal mode. \mcq
line 14: You can't use `macro parameter character #' in horizontal mode. \mcq
line 14: You can't use `macro parameter character #' in horizontal mode. \mcq
line 14: You can't use `macro parameter character #' in horizontal mode. \mcq

I will try whatever solution given with oneparcheckboxes too but let's first have this answer.

Zack Fair
  • 471
  • Please don't ask more than one question in any given post :) You should remove the second part of this question and post a new one -- nobody will come running at you with pitchforks for asking too many questions :) – Sean Allred May 21 '15 at 18:38
  • A command with 5 parameters should be avoided on user-level, in my point of view –  May 21 '15 at 21:31
  • @ChristianHupfer Agreed. Really, there's nothing wrong with the environment if you have editor support for \choice as \item. – Sean Allred May 22 '15 at 00:45
  • Oh I usually find it's not good to make too many new threads so thought should try getting as many issues answered in one question as possible. Edited it. Will ask those separately.

    What's wrong with 5 parameters? Not like I have any other option either.

    – Zack Fair May 23 '15 at 18:28
  • It's just a too confusing for my taste. If the choices have logical meaning, I would use a key-value interface. (Take a look at l3keys in texdoc interface3.) Otherwise, there's no advantage to using a macro rather than the {oneparchoices} environment. – Sean Allred May 23 '15 at 18:54

1 Answers1

5

You need to tell LaTeX how many arguments there will be:

\newcommand{\mcq}[5]{...
Sean Allred
  • 27,421