{"id":911,"date":"2016-08-11T14:14:09","date_gmt":"2016-08-11T19:14:09","guid":{"rendered":"http:\/\/www.hargaden.com\/enda\/?p=911"},"modified":"2021-04-15T17:05:27","modified_gmt":"2021-04-15T17:05:27","slug":"latex-problem-sets-with-hidden-answers","status":"publish","type":"post","link":"https:\/\/hargaden.com\/enda\/latex-problem-sets-with-hidden-answers\/","title":{"rendered":"LaTeX problem sets with hidden answers"},"content":{"rendered":"<p>I like being able to hide content in documents, for example including but not revealing the answers in a problem set. That makes it very easy to then produce the problem set solutions, simply by revealing the answers. I made this easier with a \\hide{} command, that can be &#8220;turned off&#8221; so the answers are revealed.<\/p>\n<p>This is the basic code I use for producing problem sets. The only change needed to convert a problem set into a solution set is to redefine the \\showanswers variable to equal 1 rather than 0.<\/p>\n<pre><code>\\documentclass{article}\n% Set this =0 to hide, =1 to show\n\\def\\showanswers{0}\n\n\\newcommand{\\hide}[1]{\n\\ifnum\\showanswers=1\n\n#1 \\vspace{\\baselineskip}\n\\fi\n\n\\ifnum\\showanswers=0\n\n\\vspace{2\\baselineskip} \\hspace{2cm}\n\\fi\n}\n\n\\begin{document}\n\n\\begin{enumerate}\n\\item This is question 1.\n\\hide{Here is a hidden solution.}\n\n\n\\item What is the answer to question 2?\n\\hide{The answer is here.}\n\\end{enumerate}\n\n\\end{document}<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I like being able to hide content in documents, for example including but not revealing the answers in a problem set. That makes it very easy to then produce the problem set solutions, simply by&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8,11],"tags":[],"class_list":["post-911","post","type-post","status-publish","format-standard","hentry","category-latex","category-teaching"],"_links":{"self":[{"href":"https:\/\/hargaden.com\/enda\/wp-json\/wp\/v2\/posts\/911","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hargaden.com\/enda\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hargaden.com\/enda\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hargaden.com\/enda\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/hargaden.com\/enda\/wp-json\/wp\/v2\/comments?post=911"}],"version-history":[{"count":1,"href":"https:\/\/hargaden.com\/enda\/wp-json\/wp\/v2\/posts\/911\/revisions"}],"predecessor-version":[{"id":1167,"href":"https:\/\/hargaden.com\/enda\/wp-json\/wp\/v2\/posts\/911\/revisions\/1167"}],"wp:attachment":[{"href":"https:\/\/hargaden.com\/enda\/wp-json\/wp\/v2\/media?parent=911"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hargaden.com\/enda\/wp-json\/wp\/v2\/categories?post=911"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hargaden.com\/enda\/wp-json\/wp\/v2\/tags?post=911"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}