1

I'm creating a math test, this is the file I'm using. I like this file, basically I coped this from different latex files, at the beginning, I used the table to input the right keys, this way is too slow and I made a lot of mistakes, I saw some people can fix this use add \CC in front of the right answer or use \correctchoice (in exam), I don't know how to add maybe \renewenvironment.

enter image description here

\documentclass[12pt]{article}
\usepackage{answers}
\usepackage[utf8]{inputenc}
\usepackage[T2A]{fontenc}
\usepackage{xpatch}
\usepackage{graphicx}
\usepackage{amssymb}
\usepackage{multicol}

\newcommand{\ds}{\displaystyle}

\usepackage{tasks}
\setlength{\columnsep}{0.1cm}
\setlength{\columnseprule}{0.2pt}
\usepackage{geometry}
 \geometry{
 a4paper,
 total={170mm,257mm},
 left=5mm,
 right=5mm,
 top=15mm,
 }



\usepackage{tikz}
\usepackage{amsmath}
\usepackage{amsmath,amssymb}
\usepackage{enumitem}
\usepackage{varwidth}


\usetikzlibrary{calc}

\newcommand{\mybox}[4][\textwidth-\pgfkeysvalueof{/pgf/inner xsep}-2mm]{%
\begin{figure}[!h]
\centering
\begin{tikzpicture}
\node[line width=.5mm, rounded corners, draw=#2, inner ysep=10pt, text width=#1, outer sep=0] (one) {\vspace*{15pt}\\\begin{varwidth}{\textwidth}#4\end{varwidth}};
\node[text=white,anchor=north east,align=center, minimum height=20pt] (two) at (one.north east) {#3 \hspace*{.5mm}};
\path[fill=#2] 
    (one.north west|-two.west) --
    ($(two.west)+(-1.5cm,0)$) 
    to[out=0,in=180] (two.south west) --
    (two.south east) [rounded corners] --
    (one.north east) -- 
    (one.north west) [sharp corners] -- cycle;
\node[text=white,anchor=north east,align=center, minimum height=20pt, text height=2ex] (three) at (one.north east) {#3 \hspace*{.5mm}};
\end{tikzpicture} 
\end{figure}
}




\begin{document}


\begin{center}
\mybox{gray!70!black}{\Large{Test 1}}{
\hspace*{7.5cm}
Angles in parallel lines
}
\end{center}

\begin{multicols*}{2}
\begin{enumerate}
%%%%%%%%%%%%%Q1%%%%%%%%%%%%%
\item If the ratio of two supplementary angles is $\dfrac{4}{11}$, what is the measure of small angle?
\begin{tasks}[counter-format = {(tsk[A])},label-offset = {0.8em},item-indent={-0.1cm},label-format = {\bfseries}](5)
\task $36^\circ$
\task $44^\circ$
\task $48^\circ$
\task $52^\circ$
\task $60^\circ$
\end{tasks}\vspace*{1cm}
%C

%%%%%%%%%%%%%Q2%%%%%%%%%%%%%
\item 
\begin{tasks}[counter-format = {(tsk[A])},label-offset = {0.8em},item-indent={-0.1cm},label-format = {\bfseries}](4)
\task 
\task 
\task 
\task 
\end{tasks}

%%%%%%%%%%%%%Q3%%%%%%%%%%%%%
\item 
\begin{tasks}[counter-format = {(tsk[A])},label-offset = {0.8em},item-indent={-0.1cm},label-format = {\bfseries}](4)
\task 
\task 
\task 
\task 
\end{tasks}

\end{enumerate}
\end{multicols*}
\newpage



\end{document}
1
  • What style do you want to apply for the item of correct choice? – muzimuzhi Z Jun 19 '20 at 21:19
0

I suggest to

Then we can have a clean input in the document...

\begin{document}

\begin{examtitle}{Test 1}
  Angles in parallel lines
\end{examtitle}

\begin{multicols*}{2}
\begin{exercise}
  If the ratio of two supplementary angles is $\frac{4}{11}$, what is the
  measure of the small angle?
  \begin{choices}(5)
    \choice \ang{36}
    \choice \ang{44}
    \choice \answer{\ang{48}}
    \choice \ang{52}
    \choice \ang{60}
  \end{choices}
\end{exercise}
\begin{exercise}
  .
  .
  .
\end{document}

... and still maintain your desired output:

enter image description here


Here is the complete code:

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}

\usepackage{parskip}
\usepackage{geometry}
\geometry{
  a4paper,
  total={170mm,257mm},
  left=5mm,
  right=5mm,
  top=15mm,
}

\usepackage{multicol}
\setlength{\columnsep}{0.1cm}
\setlength{\columnseprule}{0.2pt}

\usepackage[most]{tcolorbox}

\makeatletter
\newtcolorbox{examtitle}[2][]{
  halign=flush center,
  colframe=gray!70!black,
  fonttitle=\Large,
  enhanced, 
  breakable,
  colback=white,
  attach boxed title to top right={yshift=-2pt}, title={#2},
  boxed title size=standard,
  boxrule=0pt,
  boxed title style={
    sharp corners, 
    rounded corners=northeast, 
    colback=tcbcolframe, 
    boxrule=0pt},
  sharp corners=north,
  overlay unbroken={
    \path[fill=tcbcolback] 
      ([xshift=2pt]title.south west) 
      to[out=180, in=0] ([xshift=-1.5cm]title.west)--
      (title.west-|frame.west) |- 
      ([xshift=2pt]title.south west)--cycle;
    \path[fill=tcbcolframe] (title.south west) 
      to[out=180, in=0] ([xshift=-1.5cm]title.west)--
      (title.west-|frame.west)
      [rounded corners=\kvtcb@arc] |- 
      (title.north-|frame.north) 
      [sharp corners] -| (title.south west);
    \draw[line width=.5mm, rounded corners=\kvtcb@arc, 
      tcbcolframe] 
      (title.north east) rectangle 
      (frame.south west);
  }, 
  overlay first={
    \path[fill=tcbcolback] 
      ([xshift=2pt]title.south west) 
      to[out=180, in=0] ([xshift=-1.5cm]title.west)--
     (title.west-|frame.west) |- 
      ([xshift=2pt]title.south west)--cycle;
    \path[fill=tcbcolframe] (title.south west) 
      to[out=180, in=0] ([xshift=-1.5cm]title.west)--
      (title.west-|frame.west)
      [rounded corners=\kvtcb@arc] |- 
      (title.north-|frame.north) 
      [sharp corners] -| (title.south west);
    \draw[line width=.5mm, rounded corners=\kvtcb@arc, 
      tcbcolframe] 
      (frame.south west) |- (title.north) -| 
      (frame.south east);
  }, 
  overlay middle={
    \draw[line width=.5mm, tcbcolframe] 
    (frame.north west)--(frame.south west) 
    (frame.north east)--(frame.south east);
  },
  overlay last={
    \draw[line width=.5mm, rounded corners=\kvtcb@arc, 
      tcbcolframe] 
      (frame.north west) |- (frame.south) -|
      (frame.north east);
  }, 
  #1
}
\makeatother

\usepackage{siunitx}

\usepackage{xsim}
\xsimsetup{
  load-style = layouts ,
  exercise/template = minimal ,
  exercise/the-counter = \arabic{exercise}. ,
  exercise/end-hook = \vspace{\baselineskip}
}
  
\usepackage{tasks}
\NewTasksEnvironment[
  label = (\Alph*) ,
  label-format = \bfseries ,
  label-width = 21pt
]{choices}[\choice]

\DeclareExerciseProperty{answer}    
\newcommand*\answer[1]{%
  \SetExpandedExerciseProperty{answer}{ \thetask\ \unexpanded{#1}}%
 #1%
}

\newcommand*\getanswers{%
  \def\betweenanswers{\def\betweenanswers{\hspace{2em}}}%
  \ForEachUsedExerciseByID{%
    \betweenanswers##3\ExercisePropertyGet{##1}{##2}{answer}%
  }%
}

\usepackage{amsmath}
\usepackage{amsmath,amssymb}
\usepackage{enumitem}

\begin{document}

\begin{examtitle}{Test 1}
  Angles in parallel lines
\end{examtitle}

\begin{multicols*}{2}
\begin{exercise}
  If the ratio of two supplementary angles is $\frac{4}{11}$, what is the
  measure of the small angle?
    \begin{choices}(5)
      \choice \ang{36}
      \choice \ang{44}
      \choice \answer{\ang{48}}
      \choice \ang{52}
      \choice \ang{60}
    \end{choices}
  \end{exercise}
  \begin{exercise}
    Is this really a question?
    \begin{choices}(4)
      \choice \answer{yes}
      \choice no
      \choice maybe
      \choice no idea
    \end{choices}
  \end{exercise}
    \begin{exercise}
    This really is a question!
    \begin{choices}(4)
      \choice yes
      \choice \answer{no}
      \choice maybe
      \choice no idea
    \end{choices}
  \end{exercise}
  \subsection*{Answers}
  \getanswers
\end{multicols*}

\end{document}

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.