0

I wish to adding bubble answer sheet in the following MWE:

\documentclass[twoside,a4paper,cleardoublepage=empty,14pt]{book}
\usepackage{exsheets}
\SetupExSheets[question]{type=exam}
\SetupExSheets{counter-format=ch.qu[1]}
\RenewQuSolPair{question}[headings-format=\large\bfseries,name=Problem]{solution}
\usepackage{enumerate,tikz}

\newcommand\squared[1]{\tikz[baseline=(char.base)]{ \node[shape=rectangle,draw,inner sep=3pt] (char) {#1};}} \usepackage{enumitem} \usepackage{multicol} \setlist[enumerate]{label=\protect\squared{\arabic}} \begin{document}

\chapter{Analysis of Algorithms}

\begin{question}
    Which of the following answers is correct for the given recurrence relation $T(n)=T(n-1)+n$?
    \begin{enumerate}
        \item $O(n^2)$
        \item $O(n^3)$
        \item $O(n^4)$
        \item $O(n\log n)$
    \end{enumerate}
\end{question}

\begin{solution}
    this is a solution
\end{solution}
\chapter{answer Sheet}




\end{document}

In more detail, I am writing a multiple choice book. I wish to add a bubble answer sheet to chapter Answer Sheet so that for each question mark correct choice like below image:

enter image description here

Krishna
  • 125
tstt
  • 187
  • Related: https://tex.stackexchange.com/questions/219425/how-to-generate-a-dynamic-bubble-answer-sheet-for-multiple-choice-exam and https://tex.stackexchange.com/questions/309359/multiple-choice-questions-with-xparse-package – Steven B. Segletes Nov 05 '23 at 20:35
  • @StevenB.Segletes Unfortunately, I can't use those post to resolve my issue. – tstt Nov 06 '23 at 06:23
  • @StevenB.Segletes How it possible to use those in my MWE? Could you guide me? – tstt Nov 06 '23 at 06:37
  • The exsheets package is outdated. Are you ure you want to use it? Maybe give its successor xsim a try. Also, you should probably not load the enumerate package which is an outdated predecessor of enumitem. – Jasper Habicht Nov 07 '23 at 12:06

1 Answers1

1

This can be accomplished without modifying exsheets.

demo

\documentclass[twoside,a4paper,cleardoublepage=empty,14pt]{book}
\usepackage{exsheets}
\SetupExSheets[question]{type=exam}
\SetupExSheets{counter-format=ch.qu[1]}
\RenewQuSolPair{question}[headings-format=\large\bfseries,name=Problem]{solution}
\usepackage{enumerate,tikz}

\newcommand\squared[1]{\tikz[baseline=(char.base)]{ \node[shape=rectangle,draw,inner sep=3pt] (char) {#1};}} \usepackage{enumitem} \usepackage{multicol} \setlist[enumerate]{label=\protect\squared{\arabic}}

\newcommand{\bubble}[1]% #1 is correct choice (out of 4) {\bgroup \fboxsep=0pt \count1=0 \count2=#1\relax \loop\ifnum\count1<4 \advance\count1 by 1 \ifnum\count1=\count2 \fbox{\rule[-\dp\strutbox]{1em}{\baselineskip}}\quad \else \fbox{\makebox[1em]{\number\count1}\strut}\quad \fi \repeat \egroup}

\begin{document}

\chapter{Analysis of Algorithms}

\begin{question}
    Which of the following answers is correct for the given recurrence relation $T(n)=T(n-1)+n$?
    \begin{enumerate}
        \item $O(n^2)$
        \item $O(n^3)$
        \item $O(n^4)$
        \item $O(n\log n)$
    \end{enumerate}
\end{question}

\begin{solution}
    \bubble{3}
\end{solution}
\chapter{answer Sheet}

\printsolutions

\end{document}

John Kormylo
  • 79,712
  • 3
  • 50
  • 120
  • But I use Solution environment for complete solution of the problem. Could you use another environment? Thank you. – tstt Nov 06 '23 at 21:38
  • @tstt From the code you posted in your question, it is not clear how exactly you use the solution environment. At least, it is not clear to me. – Jasper Habicht Nov 07 '23 at 12:08
  • The solution environment was an already solved problem. Modifying or replaceing it is more difficult. – John Kormylo Nov 07 '23 at 15:38