1

i am trying to make assignment sheets using AMC, and to save space on some questions, i am using multicols

Here is an MWE

\documentclass[a4paper]{article}

\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usepackage[version=4]{mhchem}
\usepackage{amsmath,amssymb}
\usepackage{multicol}
% \TBmulticolcolumns

\usepackage{xspace}
\usepackage{siunitx}
\usepackage{tasks}
\usepackage{diffcoeff}
\usepackage{mathtools}
\usepackage{booktabs}
% \usepackage{chem}
% \input{chem.sty}
\RequirePackage{etex}
\usepackage[box,completemulti,nopage,noshufflegroups,separateanswersheet,noshuffle]{automultiplechoice}    
\everymath{\displaystyle}
\begin{document}

\AMCrandomseed{1237893}
\AMCboxStyle{shape=oval}
\def\AMCformQuestion#1{{\sc Q #1:}}    

\setdefaultgroupmode{withoutreplacement}



\element{general}{
  \begin{question}{nb-ue}
    How many different states were members of the European Union in Jan. 2009?
    \begin{multicols*}{2}

    \begin{choices}
      \wrongchoice{15}
      \wrongchoice{21}
      \correctchoice{27}
      \wrongchoice{31}
    \end{choices}
    \end{multicols*}
  \end{question}
}


% QUESTIONS ON NUMBER OFATOMS AND MOLAR MASS 
\element{easy}{
\begin{question}{Q.5}
 1.2 gm of Mg (At. mass 24) will produce MgO equal to 
 \begin{multicols}{2}
 \begin{choices}
\correctchoice{ (A)  0.05 mol  }
\wrongchoice{ (B)  40 gm  }
\wrongchoice{ (C)  40 mg  }
\wrongchoice{ (D)  4 gm  }
\end{choices}
\end{multicols}
\end{question}}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
%
%Nothing is relevant to my problem below this
%%%%%%%%%%%%%%%%%%%%%%%

\onecopy{1}{

%%% beginning of the test sheet header:

\noindent{\bf QCM  \hfill TEST}

\vspace*{.5cm}
\begin{minipage}{.4\linewidth}
  \centering\large\bf Test\\ Examination on Jan. 1st, 2008
\end{minipage}

\begin{center}\em
Duration : 10 minutes.

  No documents allowed. The use of electronic calculators is forbidden.

  Questions using the sign \multiSymbole{} may have
  zero, one or several correct answers.  Other questions have a single correct answer.

  Negative points may be attributed to \emph{very
    bad} answers.

\end{center}
\vspace{1ex}

%%% end of the header

\insertgroup{general}
\insertgroup{easy}

\AMCcleardoublepage    

% \AMCaddpagesto{3} 

\AMCformBegin    

%%% beginning of the answer sheet header

{\large\bf Answer sheet:}
\hfill \namefield{\fbox{    
    \begin{minipage}{.5\linewidth}
      Firstname and lastname:

      \vspace*{.5cm}\dotfill
      \vspace*{1mm}
    \end{minipage}
  }}

\begin{center}
  \bf\em Answers must be given exclusively on this sheet:
  answers given on the other sheets will be ignored.
\end{center}

%%% end of the answer sheet header

\AMCform    

% \AMCaddpagesto{5} 

}

\end{document}

The output looks something like this

enter image description here

My issue is that the options are aligned as

a c

b d

whereas what I want is the options to align

a b

c d

There have been several questions on the same topic, however none have been able to help me.

how do i achieve this effect using multicol? or if it is too difficult using multicol, how do i do it using tasks?

Edit: Adding a smaller MWE.


\documentclass[a4paper]{article}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[version=4]{mhchem}
\usepackage{amsmath,amssymb}
\usepackage{multicol}
\usepackage{xspace}
\usepackage{siunitx}
\usepackage{tasks}
\usepackage{booktabs}
\usepackage[box,completemulti,nopage,noshufflegroups,separateanswersheet,noshuffle]{automultiplechoice}    
\begin{document}

\AMCrandomseed{1237893}
\setdefaultgroupmode{withoutreplacement}



\element{general}{
  \begin{question}{nb-ue}
    How many different states were members of the European Union in Jan. 2009?
    \begin{multicols}{2}
    \begin{choices}
      \wrongchoice{15}
      \wrongchoice{21}
      \correctchoice{27}
      \wrongchoice{31}
    \end{choices}
    \end{multicols}
  \end{question}
}

\element{general}{
\begin{question}{Q.5}
 1.2 gm of Mg (At. mass 24) will produce MgO equal to 
 \begin{multicols}{2}
 \begin{choices}
\correctchoice{ (A)  0.05 mol  }
\wrongchoice{ (B)  40 gm  }
\wrongchoice{ (C)  40 mg  }
\wrongchoice{ (D)  4 gm  }
\end{choices}
\end{multicols}
\end{question}}


\onecopy{1}{
\insertgroup{general}
\AMCcleardoublepage    
\AMCformBegin    
\AMCform    

}

\end{document}

Please refer to the smaller MWE

6
  • 1
    multicol makes as the names indicates columns. For such horizontal lists use the tasks package. And don't use utf8x and the etex package, both are not needed and not really compatible with a current latex. Commented May 5, 2021 at 14:33
  • 1
    Please try to make your MWE a little more minimal. Also, cannot find automultiplechoice.sty. I was going to demonstrate how to use \makebox or \parbox to achieve this effect. Commented May 5, 2021 at 14:51
  • @JohnKormylo Here's the link to download AMC.sty link i am sure the MWE could be made smaller. But i am a noob, and I wasn't sure what lines were unimportant.
    – Aman
    Commented May 5, 2021 at 17:52
  • @UlrikeFischer, Thats what i couldnt do. How would i use tasks function, since every "question" environment takes "correctchoice" or "wrongchoice" to itemize. ?
    – Aman
    Commented May 5, 2021 at 17:54
  • sorry but like John I find your code much too long and can't compile it. Make an example that doesn't contain all this irrelevant packages and code parts. Side remark: don't use \bf, use \bfseries. Commented May 5, 2021 at 17:57

2 Answers 2

1

Option 1: do it by hand

In the first example I use the choiceshoriz environment to print everything horizontally.

In the second example I use the choicescustom environment with some tricks to print two columns. Note that this only works for SHORT answers. What I do is define a new boolean toggle that keeps track of whether I am setting an odd column or not. Each time AMC prints an item, the toggle changes value, and at even columns, we print a linebreak. The formatting is entirely done with \hspace and \rlap, so text that are too long will overprint.

\documentclass[a4paper]{article}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[version=4]{mhchem}
\usepackage{amsmath,amssymb}
\usepackage{xspace}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage[box,completemulti,nopage,noshufflegroups,separateanswersheet,noshuffle]{automultiplechoice}    

\newif\ifAMCoddcolumn
\AMCoddcolumntrue
\def\AMCbeginAnswer{\vspace{\topsep}\par\AMCoddcolumntrue}
\def\AMCendAnswer{\par}
\def\AMCanswer#1#2{\hspace*{0.1\textwidth}\rlap{#1 #2}\hspace*{0.35\textwidth}\ifAMCoddcolumn\AMCoddcolumnfalse\else\par\AMCoddcolumntrue\fi}


\begin{document}

\AMCrandomseed{1237893}
\setdefaultgroupmode{withoutreplacement}



\element{general}{
  \begin{question}{nb-ue}
    How many different states were members of the European Union in Jan. 2009?
    \begin{choiceshoriz}
      \wrongchoice{15}
      \wrongchoice{21}
      \correctchoice{27}
      \wrongchoice{31}
    \end{choiceshoriz}
  \end{question}
}

\element{general}{
\begin{question}{Q.5}
 1.2 gm of Mg (At. mass 24) will produce MgO equal to 
 \begin{choicescustom}
\correctchoice{ (A)  0.05 mol  }
\wrongchoice{ (B)  40 gm  }
\wrongchoice{ (C)  40 mg  }
\wrongchoice{ (D)  4 gm  }
\end{choicescustom}
\end{question}}


\onecopy{1}{
\insertgroup{general}
\AMCcleardoublepage    
\AMCformBegin    
\AMCform    

}

\end{document}

enter image description here

(The screen shot taken of an older version without the extra \vspace{\topsep} that adds some vertical padding between the question and answer.)

Option 2: using tasks

To use tasks, because of the peculiar way that tasks processes the listing, the syntax is a little bit surprising. You have to put \begin{tasks}... inside \begin{choicescustom} and also manually insert the \task. (Essentially you want to let tasks process the splitting of the arguments and placement first, before letting AMC print the MC answers.)

\documentclass[a4paper]{article}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[version=4]{mhchem}
\usepackage{amsmath,amssymb}
\usepackage{xspace}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{tasks}
\usepackage[box,completemulti,nopage,noshufflegroups,separateanswersheet,noshuffle]{automultiplechoice}    

\def\AMCanswer#1#2{#1 #2}


\begin{document}

\AMCrandomseed{1237893}
\setdefaultgroupmode{withoutreplacement}



\element{general}{
  \begin{question}{nb-ue}
    How many different states were members of the European Union in Jan. 2009?
    \begin{choiceshoriz}
      \wrongchoice{15}
      \wrongchoice{21}
      \correctchoice{27}
      \wrongchoice{31}
    \end{choiceshoriz}
  \end{question}
}

\element{general}{
\begin{question}{Q.5}
 1.2 gm of Mg (At. mass 24) will produce MgO equal to 
 \begin{choicescustom}
         \begin{tasks}[label={}](2)
                \task \correctchoice{ (A)  0.05 mol  }
                \task \wrongchoice{ (B)  40 gm  }
                \task \wrongchoice{ (C)  40 mg  }
                \task \wrongchoice{ (D)  4 gm  }
        \end{tasks}
\end{choicescustom}
\end{question}}


\onecopy{1}{
\insertgroup{general}
\AMCcleardoublepage    
\AMCformBegin    
\AMCform    

}

\end{document}

enter image description here

4
  • Hi, thanks for your answer. I could not use method 1 when i had to put options in a single column ( because the choices where too long) and also i couldn't use it when options were small enough to fit in a single row. however method two was very useful and it helped me expand on it and solve my task! thanks for it!
    – Aman
    Commented May 6, 2021 at 11:17
  • Hey @Willie since you helped me in this issue, here is a similar issue i would like your help in. Question .
    – Aman
    Commented Jul 5, 2021 at 10:48
  • @Aman: while I have previously used the AMC package, I have not used the mcexam package before. I don't think I can help beyond what the answer you already got there says. Commented Jul 5, 2021 at 22:29
  • can you help me with this question? link .
    – Aman
    Commented Sep 8, 2021 at 15:12
0

I managed to solve this with the help of @willie answer. to anyone else who might come looking for it, here is my solution. "Tasks" worked great and it also helped my issues with lining up options. Here is my final code and sample output.

\documentclass[a4paper]{article}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[version=4]{mhchem}
\usepackage{amsmath,amssymb}
\usepackage{xspace}
\usepackage{siunitx}
\usepackage{booktabs}
\usepackage{tasks}
\usepackage[box,completemulti,nopage,noshufflegroups,separateanswersheet,noshuffle]{automultiplechoice}

\def\AMCanswer#1#2{#1 #2}


\begin{document}

\AMCrandomseed{1237893}
\setdefaultgroupmode{withoutreplacement}



\element{general}{
\begin{question}{nb-ue}
This is a questoin where all the options are in a single column. useful when the answer or choices are long and multiple would not fit in a single row!
\begin{choicescustom}
\begin{tasks}[label={}](2)
\task* \wrongchoice{15}
\task* \wrongchoice{21}
\task* \correctchoice{27}
\task* \wrongchoice{31}
\end{tasks}
\end{choicescustom}
\end{question}
}



\element{general}{
\begin{question}{Q.5}
This is a question where the options are present in two rows.
\begin{choicescustom}
\begin{tasks}[label={}](2)
\task \correctchoice{ (A)  0.05 mol  }
\task \wrongchoice{ (B)  40 gm  }
\task \wrongchoice{ (C)  40 mg  }
\task \wrongchoice{ (D)  4 gm  }
\end{tasks}
\end{choicescustom}
\end{question}}

\element{general}{
\begin{question}{nb-ue2}
This is a question where all options are present in a single row. Useful if the options are very small.
Also you will Notice the all the options including the previous two questions line up well.
\begin{choicescustom}
\begin{tasks}[label={}](4)
\task \wrongchoice{15}
\task \wrongchoice{21}
\task \correctchoice{27}
\task \wrongchoice{31}
\end{tasks}
\end{choicescustom}
\end{question}
}


\onecopy{1}{
\insertgroup{general}
\AMCcleardoublepage
\AMCformBegin
\AMCform

}

\end{document}

the only important point that i think i must mentions is using choicescustom while using tasks.

here is the same output. as you can see options line up very well. i havent tried the same with images, but i dont think it should pose an issue.

enter image description here

You must log in to answer this question.

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