8

I want to produce a bubble answer sheet where the number of questions are shown by \qCount. It is always below than 100. Is it possible to produce it dynamically? I cannot print the question numbers before each row and cannot show bubbles within the cells.

desired output: Sample

MWE:

\documentclass[a4paper]{article}

\usepackage{tikz}

\newcommand{\repeatntimes}[2]{
   \newcount\i
   \i=0
   \newtoks\ans
   \loop
      \ans=\expandafter{\the\ans #2}
      \advance\i by 1
      \ifnum\i<#1\repeat
   \the\ans
}

\newcommand{\countRepeatntimes}[2]{
   \newcount\i
   \i=0
   \newtoks\ans
   \loop
      \advance\i by 1
      \ans=\expandafter{\the\ans #2}
      \ifnum\i<#1\repeat
   \the\ans
}

\newcommand{\generateTable}[1]{%
\countRepeatntimes{#1}{\indent
\repeatntimes{4}{\textcolor{lightgray}{\rule{0.9\baselineskip}{0.9\baselineskip}} }\par
}
}

\begin{document}
\def\qCount{80}
\generateTable{\qCount}
\end{document}
remo
  • 541
  • 1
  • 4
  • 12

1 Answers1

5

I printed out a stepped counter in the loop for the problem number (and another counter for the bubble label) and changed the square \rule to a rotated "0", scaled and stretched appropriately. You can change the size via the numerical arguments to \scalebox{1.4}[1.5]{}. I also made it two column.

EDITED to provide sample filled block.

\documentclass[a4paper,twocolumn]{article}

\usepackage{tikz,graphicx} \usepackage[usestackEOL]{stackengine}

\newcommand{\repeatntimes}[2]{ \newcount\i \i=0 \newtoks\ans \loop \ans=\expandafter{\the\ans #2} \advance\i by 1 \ifnum\i<#1\repeat \the\ans }

\newcommand{\countRepeatntimes}[2]{ \newcount\i \i=0 \newtoks\ans \loop \advance\i by 1 \ans=\expandafter{\the\ans #2} \ifnum\i<#1\repeat \the\ans }

\newcounter{problem} \newcounter{choice} \newcommand{\generateTable}[1]{% \countRepeatntimes{#1}{\stepcounter{problem}\makebox[2ex][r]{\theproblem.}%\indent \setcounter{choice}{0}% \repeatntimes{4}{\stepcounter{choice}\textcolor{black!35}{% \raisebox{-1.5pt}{\scalebox{1.5}[1.8]{\stackinset{c}{}{c}{}{% \scalebox{.6}{\tiny \Alph{choice}}}{\rotatebox{90}{0}}}}} }\par } }

\def\sampleblock{% \makebox[5.1ex]{} \stepcounter{choice}\textcolor{black!35}{% \raisebox{-1.5pt}{\scalebox{1.5}[1.8]{\stackinset{c}{}{c}{}{% \scalebox{.6}{\tiny \Alph{choice}}}{\rotatebox{90}{0}}}}} \stepcounter{choice}\textcolor{black!35}{% \raisebox{-1.5pt}{\scalebox{1.5}[1.8]{\stackinset{c}{}{c}{}{% \scalebox{.6}{\tiny \Alph{choice}}}{\rotatebox{90}{0}}}}} \stepcounter{choice}\textcolor{black!35}{% \smash{\raisebox{-1.5pt}{\scalebox{1.5}[1.8]{\stackinset{c}{}{c}{-1pt}{% \scalebox{6}[3.5]{\color{black}$\cdot$}}{\rotatebox{90}{0}}}}}} \stepcounter{choice}\textcolor{black!35}{% \raisebox{-1.5pt}{\scalebox{1.5}[1.8]{\stackinset{c}{}{c}{}{% \scalebox{.6}{\tiny \Alph{choice}}}{\rotatebox{90}{0}}}}} \par} \voffset=\dimexpr\voffset+.5in \textheight=\dimexpr\textheight-.5in

\begin{document}

\smash{\Shortstack[l]{% Name \underline{\hspace{2.4in}} Class\underline{\hspace{1.2in}} Date\underline{\hspace{1.2in}}\ \textcolor{black!50}{\rule{5.9in}{2ex}}\ \rule[2ex]{10ex}{2ex}\sffamily\itshape\Huge Bubble Answer Sheet\ \strut\ \sampleblock\ \rule{0ex}{4pt}\}% }\vspace{-\baselineskip}\par \def\qCount{80} \generateTable{\qCount} \end{document}

enter image description here

enter image description here


SUPPLEMENT

A comment requested a version with circular choices:

\documentclass[a4paper,twocolumn]{article}

\usepackage{tikz,graphicx} \usepackage[usestackEOL]{stackengine}

\newcommand{\repeatntimes}[2]{ \newcount\i \i=0 \newtoks\ans \loop \ans=\expandafter{\the\ans #2} \advance\i by 1 \ifnum\i<#1\repeat \the\ans }

\newcommand{\countRepeatntimes}[2]{ \newcount\i \i=0 \newtoks\ans \loop \advance\i by 1 \ans=\expandafter{\the\ans #2} \ifnum\i<#1\repeat \the\ans }

\newcounter{problem} \newcounter{choice} \newcommand{\generateTable}[1]{% \countRepeatntimes{#1}{\stepcounter{problem}\makebox[2ex][r]{\theproblem.}%\indent \setcounter{choice}{0}% \repeatntimes{4}{\stepcounter{choice}\textcolor{black!35}{% \raisebox{0.5pt}{\scalebox{1.0}{\stackinset{c}{}{c}{}{% \scalebox{.6}{\footnotesize \Alph{choice}}}{$\bigcirc$}}}} }\par } }

\def\sampleblock{% \makebox[5.1ex]{} \stepcounter{choice}\textcolor{black!35}{% \raisebox{-1.5pt}{\scalebox{1.0}{\stackinset{c}{}{c}{}{% \scalebox{.6}{\footnotesize \Alph{choice}}}{$\bigcirc$}}}} \stepcounter{choice}\textcolor{black!35}{% \raisebox{-1.5pt}{\scalebox{1.0}{\stackinset{c}{}{c}{}{% \scalebox{.6}{\footnotesize \Alph{choice}}}{$\bigcirc$}}}} \stepcounter{choice}\textcolor{black!35}{% \smash{\raisebox{-1.5pt}{\scalebox{1.0}{\stackinset{c}{}{c}{-2.5pt}{% \scalebox{8}{\color{black}$\cdot$}}{$\bigcirc$}}}}} \stepcounter{choice}\textcolor{black!35}{% \raisebox{-1.5pt}{\scalebox{1.0}{\stackinset{c}{}{c}{}{% \scalebox{.6}{\footnotesize \Alph{choice}}}{$\bigcirc$}}}} \par} \voffset=\dimexpr\voffset+.5in \textheight=\dimexpr\textheight-.5in

\begin{document}

\smash{\Shortstack[l]{% Name \underline{\hspace{2.4in}} Class\underline{\hspace{1.2in}} Date\underline{\hspace{1.2in}}\ \textcolor{black!50}{\rule{5.9in}{2ex}}\ \rule[2ex]{10ex}{2ex}\sffamily\itshape\Huge Bubble Answer Sheet\ \strut\ \sampleblock\ \rule{0ex}{4pt}\}% }\vspace{-\baselineskip}\par \def\qCount{80} \generateTable{\qCount} \end{document}

enter image description here