Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- newcounter{num}
- newcommand{soal}[2]{
- stepcounter{num} thenum & {#1} & {#2} \[4pt] hline
- }
- documentclass{article}
- usepackage{calculator}
- usepackage{ifthen}
- newboolean{firstTime} % Declare a new variable of type boolean
- setboolean{firstTime}{true} % Set it to true
- newcounter{num}
- newcommand{soal}[2]{
- ifthenelse{boolean{firstTime}}{ % If first time, add 0 + (passed number)
- ADD{0}{#2}{totalMarks} % Perform the actual calculation
- setboolean{firstTime}{false} % Set the boolean variable to false
- }{ % Else, a total exists, so add passed number
- ADD{totalMarks}{#2}{totalMarks} % Perform the actual calculation
- }
- begin{tabular}{ccc}
- stepcounter{num} thenum & {#1} & totalMarks \[4pt] hline
- end{tabular}par
- }
- begin{document}
- soal{Started at two and $frac{1}{2}$}{2.50}
- soal{Added three and $frac{1}{4}$}{3.25}
- soal{Added five and $frac{3}{4}$}{5.75}par~\[2ex]
- Now, for the total marks: totalMarks
- end{document}
- documentclass{article}
- newcounter{num}
- newcounter{total}
- newcommand{soal}[2]{
- begin{tabular}{ccc}
- stepcounter{num} thenum & {#1} & addtocounter{total}{#2} thetotal \[4pt] hline
- end{tabular}par
- }
- begin{document}
- soal{Started at two}{2}
- soal{Added three}{3}
- soal{Added five}{5}
- end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement