Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. newcounter{num}
  2. newcommand{soal}[2]{
  3. stepcounter{num} thenum & {#1} & {#2} \[4pt] hline
  4. }
  5.  
  6. documentclass{article}
  7. usepackage{calculator}
  8. usepackage{ifthen}
  9. newboolean{firstTime} % Declare a new variable of type boolean
  10. setboolean{firstTime}{true} % Set it to true
  11. newcounter{num}
  12.  
  13. newcommand{soal}[2]{
  14. ifthenelse{boolean{firstTime}}{ % If first time, add 0 + (passed number)
  15. ADD{0}{#2}{totalMarks} % Perform the actual calculation
  16. setboolean{firstTime}{false} % Set the boolean variable to false
  17. }{ % Else, a total exists, so add passed number
  18. ADD{totalMarks}{#2}{totalMarks} % Perform the actual calculation
  19. }
  20. begin{tabular}{ccc}
  21. stepcounter{num} thenum & {#1} & totalMarks \[4pt] hline
  22. end{tabular}par
  23. }
  24. begin{document}
  25. soal{Started at two and $frac{1}{2}$}{2.50}
  26. soal{Added three and $frac{1}{4}$}{3.25}
  27. soal{Added five and $frac{3}{4}$}{5.75}par~\[2ex]
  28. Now, for the total marks: totalMarks
  29. end{document}
  30.  
  31. documentclass{article}
  32. newcounter{num}
  33. newcounter{total}
  34.  
  35. newcommand{soal}[2]{
  36. begin{tabular}{ccc}
  37. stepcounter{num} thenum & {#1} & addtocounter{total}{#2} thetotal \[4pt] hline
  38. end{tabular}par
  39. }
  40. begin{document}
  41. soal{Started at two}{2}
  42. soal{Added three}{3}
  43. soal{Added five}{5}
  44. end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement