2

Suppose, I am writing some handouts for students to prepare SAT (actually, it is some big exam in our country, not SAT). I have several .tex files, for example, polynomial.tex, conic sections.tex, triangular functions.tex, each corresponding to a chapter. At the same time, there have been 10 years or more tests of "SAT". And I think I should create several files like below

  1. 2018SATquestions.tex
  2. 2017SATquestions.tex
  3. 2016SATquestions.tex
  4. ...

And for example in 2018SATquestions.tex, I wish the document can be somehow structured like this: (of course it cannot be compiled alone)

true or false
\item Can a polynomial be degree $0$?
\item Is $\tan x'=\sec x$?
\item Is $x^2+2y^2=4$ a circle?
...

Fill in blanks
\item How many real roots of $f(x)=x^5+x^3-1$? \rule[..][..]
\item $\sin(120^\circ)=$\rule[..][..]
\item The radius of $x^2+y^2=16$ is \rule[..][..].
...

Now, in my polynomial.tex, when I wish to include the SAT historical question, I can simply just use commands like \sat{2018}{torf}{1} or \sat{2018TF1} or \sat{2018}[tf][1], ... whatever. And in triangular functions.tex, I can simply just using commands like \sat{2018}{finb}{2}, etc.

Then how can I do this? Is there any useful package for such need? Or is there another clever way to maintain the tests? PS: I'm also afriad that the \input{...} (or something similar) command will include the whole SAT file, making the compilation speed down, even if I just want to include only one or two questions from some 201xSATquestions.tex. Can such problem be avoided?

2

Definitely not sure if this is a good solution for a great number of questions, but at least it works. The memory package allows you to define a structure-like variable and get its contents later. I used the exam class which allows for simple questions, see the documentation for more options. I also took the liberty of creating a \blank command with an optional width argument. The exam class already has a \fillin[correct anwser][optional width] command.

MWE:

\documentclass{exam}

\usepackage{filecontents}
\usepackage{memory}

%\newcommand{\blank}[1][1cm]{\rule[-2pt]{#1}{0.4pt}} % Not needed

\begin{filecontents*}{SAT2018questions}
\newdata*{SAT}
\SAT[2018-1]={
\question[6]
True or false
\begin{parts}
    \part Can a polynomial be degree $0$?
    \part Is $\tan x'=\sec x$?
    \part Is $x^2+2y^2=4$ a circle?
\end{parts}
}
\SAT[2018-2]={
\question[15]
Fill in blanks
\begin{parts}
    \part How many real roots of $f(x)=x^5+x^3-1$? \fillin[][15pt]
    \part $\sin(120^\circ)=$ \fillin
    \part The radius of $x^2+y^2=16$ is \fillin[][3cm] 
\end{parts}
}
\end{filecontents*}

\input{SAT2018questions}

\begin{document}
    \begin{questions}
        \SAT[2018-1]
        \SAT[2018-2]
    \end{questions}
\end{document}

The result looks like:

enter image description here

  • Thanks a lot. It looks great. By the way, does it suppress (avoid) the compilation on the part the user didn't include? – Eric Jun 21 '18 at 12:38
  • 1
    The parts not included will not be typeset, but I think they will have to be processed. I'm unsure if this takes the same amount of computation. Maybe there is a solution that really suppresses those parts, you should leave the question open I think. – Max Jun 21 '18 at 12:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.