I created a class which adapts the exam class to the needs of my school and added some stuff to control the class from the outside by a script to be able to create an individual exam for each student with the name and additional information printed on it. All this is controlled by an external bash script. I use something like pdflatex "\newcommand\examstudentname{somestudent} \newcommand\externalwithanswers{no}" the_exam.tex from inside the bash script to generate the exam pdf. As in the the_exam.tex file it might happen that the option [answers] was set accidentally, an exam with answers included might be created (Actually, something like that once happened at our school). To have complete control I need the script to set and unset options like [answers] of the class I inherited from (exam.cls).
Case 1: My the_exam.tex might have:
\documentclass{HTWChurExam} HTWChurExam.cls has something like:
\PassOptionsToClass{answers}{exam} This deliberately turns on [answers] for exam.cls. No problem, settled. Easy to control from outside by a script.
Case 2: My the_exam.tex might have:
\documentclass[answers]{HTWChurExam} HTWChurExam.cls has something like:
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{exam}} which will pass all options down to exam.cls. I now want to have the possibility to deliberately turn off [answers], controlled by a bash script.
I haven't found any way to accomplish this.
*.clsfile uses\DeclareOptionto define other commands, or set flags true or false. Look at the*.clscode, to see what is defined and set. The actual effect may not happen until later, perhaps when the document body begins. If that is true, can you re-define the commands, or re-set the flags,\AtBeginDocument?\PassOptionsToClass{noanswers}{exam}. 2. Have the script run pdflatex, or equivalent, usingpdflatex -jobname=myexam "\PassOptionsToClass{noanswers}{exam}\input{realexam}". In both cases you probably want have your script then copy the pdf to the expected filename.