GeneralHow can I separate exercises from solutions?

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
LaTexLearner
Posts: 139
Joined: Tue Mar 10, 2015 11:06 am

How can I separate exercises from solutions?

Post by LaTexLearner »

I'm in the midst of creating introductory multiplication and division exercises, exemplified by the following, except that I would like to separate the exercises from the solutions.
PicForOnlinePost.PNG
PicForOnlinePost.PNG (55.6 KiB) Viewed 11607 times


I can almost do it now... but not quite.

I made the code below which compiles, but does not separate the exercises from the solutions. I commented out the way I thought I could separate solutions and exercises, but that did not work unless I remove \Diagram from the definition of \Solution, meaning that there is some tikZ problem with \xdef... I think.

All the pictures and files are in this Dropbox folder. https://www.dropbox.com/sh/04uujszim2jr ... 2tTBa?dl=0

[Side note: I do not know how to turn normal text into a link, so I pasted that huge URL instead...]

Sorry for the long MWE; I'm not sure what I could remove and still get the point across! If anyone needs me to comment on any of the code, I'm happy to. :)

Code: Select all

Code, edit and compile here:
\documentclass{article}
\usepackage[margin = 1.5cm, landscape]{geometry}
\usepackage{graphicx}
\usepackage{pgf}
\pgfmathsetseed{\number\pdfrandomseed}
\usepackage{pgffor}
\usepackage{tikz}
\setlength{\parindent}{0cm}
\newcommand{\InitVariables}
{ \pgfmathrandominteger{\Sets}{1}{10}
\pgfmathrandominteger{\PerSet}{1}{10}
\pgfmathsetmacro{\Total}{int(\Sets*\PerSet)}
}
\newcommand{\picturescale}{0.4}
\newcommand{\Diagram}{}
\newcommand{\ChosenPic}{}
\newcommand{\Exercise}{}
\newcommand{\Solution}{}
\newcommand{\GenOneExerciseAndSolution}
{\InitVariables
\renewcommand{\Diagram}
{\ifcase\PerSet\relax
\or \renewcommand{\ChosenPic}{SetOfOne}
\or \renewcommand{\ChosenPic}{SetOfTwo}
\or \renewcommand{\ChosenPic}{SetOfThree}
\or \renewcommand{\ChosenPic}{SetOfFour}
\or \renewcommand{\ChosenPic}{SetOfFive}
\or \renewcommand{\ChosenPic}{SetOfSix}
\or \renewcommand{\ChosenPic}{SetOfSeven}
\or \renewcommand{\ChosenPic}{SetOfEight}
\or \renewcommand{\ChosenPic}{SetOfNine}
\or \renewcommand{\ChosenPic}{SetOfTen}
\fi
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Post Reply