0

enter image description hereI'm writing math practicing textbooks to students and I intend to provide an answer key at the end of them. I'm trying to implement the answer key using a storing box with all solutions. But I can't make the solutions respect the paragraph. I would very much appreciate splitting the answer key page into two columns. I know I still typeset such a noob. That's becouse I've been studying LaTeX for a couple of months. Sorry about that. Anyway, I'll appreciate any help.

\documentclass[10pt]{exam}
\usepackage[hmargin=1.27cm,tmargin=1.37cm, bmargin=1.5cm]{geometry}
\usepackage{indentfirst}
\usepackage[brazil]{babel}
\usepackage{amsmath,amsfonts,amssymb}
\usepackage[T1]{fontenc}
\usepackage{multicol, multirow, array, booktabs, adjustbox} % pacotes pra construção de tabelas
\setlength\extrarowheight{2pt} % define a altura de uma célula em uma tabela
\usepackage[utf8]{inputenc}



\renewcommand{\solutiontitle}{\noindent\textbf{$\;$}\enspace}


\printanswers
\unframedsolutions
% Box of all answers in the solution environment----------------------------

\newbox\allanswers
\setbox\allanswers\hbox{}

\renewenvironment{solution}{\global\setbox\allanswers=\hbox\bgroup\unhbox\allanswers}{\egroup}

\newcommand{\showallanswers}{\noindent\usebox\allanswers}
%----------------------------------------------------------------------------


\begin{document}

\begin{questions}

% Question 1--------------------------------------------------------------------

\question Os séculos são representados através de algarismos romanos. O século I iniciou-se no ano 1 da era cristã (A.D.), tendo como referência o nascimento de Jesus Cristo. O século XX encerrou-se em 2000, e século XXI começou a partir do ano 2001 e se encerrará no ano 2100, iniciando-se, em 2101, o século XXII.\\ Escreva a que século pertence:
\begin{parts}
\begin{minipage}{.48\linewidth}
\bigskip
\item o ano 1999;
\hrule width.9\textwidth
\begin{solution}
\textbf{\thequestion. }\textbf{\thepartno)} $XX$
\end{solution}
\bigskip
\item o ano 1851;
\hrule width.9\textwidth
\begin{solution}
\textbf{\thepartno)} $XIX$
\end{solution}
\bigskip 
\item o ano 1700;
\hrule width.9\textwidth
\begin{solution}
\textbf{\thepartno)} $XVII$
\end{solution}
\bigskip
\item o ano 345;
\hrule width.9\textwidth
\begin{solution}
\textbf{\thepartno)} $IV$
\end{solution}
\bigskip
\end{minipage}
\begin{minipage}{.48\linewidth}
\bigskip
\item o ano 1601;
\hrule width.9\textwidth
\begin{solution}
\textbf{\thepartno)} $XVII$
\end{solution}
\bigskip
\item o ano 598;
\hrule width.9\textwidth
\begin{solution}
\textbf{\thepartno)} $VI$
\end{solution}
\bigskip
\item o ano 33;
\hrule width.9\textwidth
\begin{solution}
\textbf{\thepartno)} $I$
\end{solution}
\bigskip
\item o ano 1201.
\hrule width.9\textwidth
\begin{solution}
\textbf{\thepartno)} $XIII$
\end{solution}
\bigskip
\end{minipage}
\end{parts} 
 
% Question 2------------------------------------------------------------------
 
\question Escreva os seguintes números usando símbolos romanos: 

\begin{parts}
\vspace{1mm}
\begin{minipage}{.48\linewidth}
\bigskip
\item 99
\begin{solution}
\textbf{\thequestion. }\textbf{\thepartno)} $XX$
\end{solution}
\hrule width.9\textwidth
\bigskip
\item 149
\begin{solution}
\textbf{\thepartno)} $XX$
\end{solution}
\hrule width.9\textwidth
\bigskip
\item 13
\begin{solution}
\textbf{\thepartno)} $XX$
\end{solution}
\hrule width.9\textwidth
\bigskip
\item 29
\begin{solution}
\textbf{\thepartno)} $XX$
\end{solution}
\hrule width.9\textwidth
\bigskip
\item 88
\begin{solution}
\textbf{\thepartno)} $XX$
\end{solution}
\hrule width.9\textwidth
\bigskip
\item 94
\begin{solution}
\textbf{\thepartno)} $XX$
\end{solution}
\hrule width.9\textwidth
\bigskip
\end{minipage}
\begin{minipage}{.48\linewidth}
\bigskip
\item 648
\begin{solution}
\textbf{\thepartno)} $XX$
\end{solution}
\hrule width.9\textwidth
\bigskip
\item 2103
\begin{solution}
\textbf{\thepartno)} $XX$
\end{solution}
\hrule width.9\textwidth
\bigskip
\item 781
\hrule width.9\textwidth
\bigskip
\item 302
\begin{solution}
\textbf{\thepartno)} $XX$
\end{solution}
\hrule width.9\textwidth
\bigskip
\item 1103
\begin{solution}
\textbf{\thepartno)} $XX$
\end{solution}
\hrule width.9\textwidth
\bigskip
\item 69
\begin{solution}
\textbf{\thepartno)} $XX$
\end{solution}
\hrule width.9\textwidth
\bigskip
\end{minipage}
\end{parts}

% Question 3-----------------------------------------------------------------

\question Determine o menor e o maior número de três algarismos diferentes que se pode escrever com os algarismos 0, 5, 6, 8 e 9. 
\fillwithlines{.7cm}
 \begin{solution}
\textbf{\thequestion. }$2135$ e $3216$
\end{solution}
\end{questions}

\begin{center}
Answer Key
\end{center}


\showallanswers% show all answers------------------------------------------------

\end{document}
2

1 Answer 1

0

Why not trying

\newcommand{\showallanswers}{\noindent\unhbox\allanswers}

instead of

\newcommand{\showallanswers}{\noindent\usebox\allanswers}

to avoid overfull

2
  • Dude! You are just a genius! I would kiss you if you were a girl. You just made my day, no my week, no my month. I happen to have two kidneys. you know where you got one if you need it. Jul 26, 2020 at 19:19
  • I am happy to hear that :)
    – domperor
    Jul 26, 2020 at 23:53

You must log in to answer this question.

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