1

The following the output i get from my MWE given below:

enter image description here

Note that, I have defined a command \qfrom to add the source of the question in each case. It will be empty when the source of the question is unknown.

How to make this work like the following output?

enter image description here

or the qfrom can be in the left margin. enter image description here

MWE

\documentclass{exam}
\pointname{}
\pointsinrightmargin

\newcommand{\qfrom}[1]{\hfill{[#1]}}
\usepackage{geometry}
\geometry{
paper = a4paper,
outer = 3in
}


\begin{document}
  \begin{questions}
    \question[10]
    Why is there air?

    \question[15] \qfrom{JAM2018}
    How much wood would a woodchuck chuck if a woodchuck could chuck
    wood?

\qformat{\thequestion. \textbf{[\thequestiontitle]}\hfill}

    \titledquestion{Title of the Quesiton}[10] \qfrom{NEST2015}
    Compute $\displaystyle\int_0^1 x^2 \, dx$. 

  \end{questions}

\end{document}

PS: I need titled question also for some reason, so i didnt want to format that.

  • Hi @David, it looks like the MWE is missing from your code. Can you add it please? – Tom Jul 29 '18 at 11:55
  • @Tom Sorry...Added the mwe now... – David Jul 29 '18 at 13:17
1

Here is an example that tries to solve your question. First of all is that \qform must be called before the actual question. It saves its parameter to a macro called \qfromsource. The macro is used later on.

Next, we redefine the \droppoints macro from the exam class to prints the macro \qfromsource together with the points assigned to the question.

Before starting the questions, \qfromat has to be called with \droppoints in it. See code.

\documentclass{exam}
\pointname{}
\pointsinrightmargin

\newcommand{\qfrom}[1]{\global\def\qfromsource{#1}}

\usepackage{geometry}
\geometry{
paper = a4paper,
outer = 3in,
}

\makeatletter
\def\droppoints{%
  \leavevmode\unskip\nobreak\hfill
  \rlap{\hskip\rightmargin  % Defined by the list environment
        \hskip\@rightmargin % Defined by exam.cls
        \hskip-\rightpointsmargin
        \llap{[\qfromsource] (\thepoints)}%
  }% rlap
  \par
}
\makeatother


\begin{document}
  \begin{questions}
    \qformat{\thequestion. \textbf{[\thequestiontitle]}\droppoints}

    \qfrom{JAM2018}
    \titledquestion{Some physics}[5]
    Why is there air?


    \qfrom{JAM2018}
    \titledquestion{Question for dyslectics}[15]
    How much wood would a woodchuck chuck if a woodchuck could chuck
    wood?


    \qfrom{NEST2015}
    \titledquestion{Simple integration}[10]
    Compute $\displaystyle\int_0^1 x^2 \, dx$. 

  \end{questions}

\end{document}

enter image description here

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.