1

I'd like to create an exam from several .tex files. I'd like the master exam .tex file to include (or input, etc) a file for each question. I'd like each question to list the number of points that it's worth.

Using the exams package one can pass the points as a parameter into the \question switch (or is \question a command, or an environment, or something else?), but that means that the thing that shows the points (the \question) will be in a different file than the rest of the exam.

Is there a way to pass additional parameters to \input (or \include, etc)?

I found this other answer here on StackExchange, but the only answer to that question is (basically) "Here's how to solve that particular problem by avoiding the need for parameters" (which is clever, but doesn't answer my question)

Note: There's going to be a bunch of questions so I can't put the point value into a separate file for the questions to include (like the other answer did)

Here's a quick example that demonstrates how to pass info via a macro / new command (as mentioned by John Kormylo in the comments)

File that does the including (that wants to pass info to the other file:

\documentclass[addpoints, 12pt]{exam}

\newcommand{\theMacro}{25}

\begin{document}

Using it here to show that I defined the macro right: \begin{textbf}
    \theMacro
\end{textbf}

\include{IncludedDocThatUsesMacro}

\end{document}

IncludedDocThatUsesMacro.tex, which is the file that will be included (it wants to use the parameter (but will use a macro instead)

\begin{centering}
    Text that works
    \theMacro
\end{centering}
  • 1
    The short answer is no. OTOH there are work arounds. Basically you store the values in macros which are expanded in the file being inputted. – John Kormylo Sep 04 '19 at 23:42
  • I tried that on a small sample and it worked. Will edit answer in case anyone else reads this. Thanks! – MikeTheTall Sep 05 '19 at 00:20
  • 1
    Did you look at the answer by Steven B. Seglates In the linked stack? Because It allows you to use parameters eg+ \myinput{some.tex}{PARAM=blah, PARAM2=blah2,...} – Pliny Jan 18 '20 at 20:51

0 Answers0