3

I would like to create worksheets with problems filled by rows instead of columns. I am using probsoln to store and call the problems, but they always end up filling the worksheet vertically. I tried putting them in a table, but I can't get that to work.

\documentclass[letter]{article}

\usepackage{probsoln}
\usepackage{amsmath}
\usepackage{multicol}

\PSNrandseed{2004}

\hideanswers

\begin{document}
\ifthenelse{\boolean{showanswers}}{\textbf{Solution Sheet}}{}
\loadrandomproblems{10}{AddingFractionsDatabase}

\begin{tabular}{lllll}
\foreachproblem{\thisproblem\\}%
\end{tabular}


\end{document}

I would like to be able to pull one or two rows of problems from each file as needed. I would like to use exam class if possible.

Test Database

\newproblem{addfractions:1212} 
{$\frac{1}{2} + \frac{1}{2} = $} 
{$\frac{1}{2} + \frac{1}{2} = \frac{2}{2} = 1$} 

\newproblem{addfractions:1213} 
{$\frac{1}{2} + \frac{1}{3} = $} 
{$\frac{1}{2} + \frac{1}{3} = \frac{3}{6} + \frac{2}{6} = \frac{5}{6}$} 

\newproblem{addfractions:1223} 
{$\frac{1}{2} + \frac{2}{3} = $} 
{$\frac{1}{2} + \frac{2}{3} = \frac{3}{6} + \frac{4}{6} = \frac{7}{6} = 1 \frac{1}{6}$} 

\newproblem{addfractions:1214} 
{$\frac{1}{2} + \frac{1}{4} = $} 
{$\frac{1}{2} + \frac{1}{4} = \frac{2}{4} + \frac{1}{4} = \frac{3}{4}$}

\newproblem{addfractions:1216}
{$\frac{1}{2} + \frac{1}{6} = $}
{$\frac{1}{2} + \frac{1}{6} = \frac{3}{6} + \frac{1}{6} = \frac{4}{6} = \frac{2}{3}$}

\newproblem{addfractions:1256}
{$\frac{1}{2} + \frac{5}{6} = $}
{$\frac{1}{2} + \frac{5}{6} = \frac{3}{6} + \frac{5}{6} = \frac{8}{6} = 1 \frac{2}{6} = 1 \frac{1}{3}$}

\newproblem{addfractions:1217}
{$\frac{1}{2} + \frac{1}{7} = $}
{$\frac{1}{2} + \frac{1}{7} = \frac{7}{14} + \frac{2}{14} = \frac{9}{14}$}

\newproblem{addfractions:1227}
{$\frac{1}{2} + \frac{2}{7} = $}
{$\frac{1}{2} + \frac{2}{7} = \frac{7}{14} + \frac{4}{14} = \frac{11}{14}$}

\newproblem{addfractions:1237}
{$\frac{1}{2} + \frac{3}{7} = $}
{$\frac{1}{2} + \frac{3}{7} = \frac{7}{14} + \frac{6}{14} = \frac{13}{14}$}

\newproblem{addfractions:1247}
{$\frac{1}{2} + \frac{4}{7} = $}
{$\frac{1}{2} + \frac{4}{7} = \frac{7}{14} + \frac{8}{14} = \frac{15}{14} = 1 \frac{1}{14}$}

\newproblem{addfractions:1257}
{$\frac{1}{2} + \frac{5}{7} = $}
{$\frac{1}{2} + \frac{5}{7} = \frac{7}{14} + \frac{10}{14} = \frac{17}{14} = 1 \frac{3}{14}$}

\newproblem{addfractions:1267}
{$\frac{1}{2} + \frac{6}{7} = $}
{$\frac{1}{2} + \frac{6}{7} = \frac{7}{14} + \frac{12}{14} = \frac{19}{14} = 1 \frac{5}{14}$}

\newproblem{addfractions:1218}
{$\frac{1}{2} + \frac{1}{8} = $}
{$\frac{1}{2} + \frac{1}{8} = \frac{4}{8} + \frac{1}{8} = \frac{5}{8}$}

\newproblem{addfractions:1238}
{$\frac{1}{2} + \frac{3}{8}= $}
{$\frac{1}{2} + \frac{3}{8} = \frac{4}{8} + \frac{3}{8} = \frac{7}{8}$}

\newproblem{addfractions:1258}
{$\frac{1}{2} + \frac{5}{8}= $}
{$\frac{1}{2} + \frac{5}{8} = \frac{4}{8} + \frac{5}{8} = \frac{9}{8} = 1 \frac{1}{8}$}

\newproblem{addfractions:1278}
{$\frac{1}{2} + \frac{7}{8}= $}
{$\frac{1}{2} + \frac{7}{8} = \frac{4}{8} + \frac{7}{8} = \frac{11}{8} = 1 \frac{3}{8}$}

\newproblem{addfractions:1219}
{$\frac{1}{2} + \frac{1}{9}= $}
{$\frac{1}{2} + \frac{1}{9} = \frac{9}{18} + \frac{2}{18} = \frac{11}{18}$}
  • Can you add some example problems? It's difficult to test without a database to load. – Nicola Talbot May 15 '13 at 19:39
  • \newproblem{addfractions:1212} {$\frac{1}{2} + \frac{1}{2} = $} {$\frac{1}{2} + \frac{1}{2} = \frac{2}{2} = 1$} \newproblem{addfractions:1213} {$\frac{1}{2} + \frac{1}{3} = $} {$\frac{1}{2} + \frac{1}{3} = \frac{3}{6} + \frac{2}{6} = \frac{5}{6}$} \newproblem{addfractions:1223} {$\frac{1}{2} + \frac{2}{3} = $} {$\frac{1}{2} + \frac{2}{3} = \frac{3}{6} + \frac{4}{6} = \frac{7}{6} = 1 \frac{1}{6}$} \newproblem{addfractions:1214} {$\frac{1}{2} + \frac{1}{4} = $} {$\frac{1}{2} + \frac{1}{4} = \frac{2}{4} + \frac{1}{4} = \frac{3}{4}$} – Nicole Mathisen May 15 '13 at 22:34
  • 1
    @NicoleMathisen Updated the question with the test database. In future do update in question rather than in comments to make question stand on it's own irrespective of comments, as comments don't have any backups(without UPS :) ). – texenthusiast May 16 '13 at 2:13
  • Note that the exam class has its own mechanism for recording solutions. – Sean Allred May 16 '13 at 3:17
3

You can achieve it by keeping track of which column you are in as follows:

\documentclass{article}

\usepackage{etoolbox}
\usepackage{probsoln}
\usepackage{amsmath}
\usepackage{multicol}

\PSNrandseed{2004}

\hideanswers

\begin{document}
\ifthenelse{\boolean{showanswers}}{\textbf{Solution Sheet}}{}
\loadrandomproblems{10}{AddingFractionsDatabase}

\newcounter{colcount}
\begin{tabular}{lllll}
\foreachproblem{\thisproblem
 \global\stepcounter{colcount}%
 \ifnumless{\value{colcount}}{4}{&}{\global\setcounter{colcount}{0}\\}%
}%
\end{tabular}


\end{document}

Result:

Image of result

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.