10

I've a .tex file with \question \part and \subpart (sample .tex file pasted in this question).

I need all points in the right margin; currently for \question it's not coming in the margin.

Also I want to replace default Question number with something like : "Q.1" (currently it's showing only "1")

Can you please help to solve both issues mentioned above?

\documentclass[addpoints,answers,10pt]{exam}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{nonfloat}
\usepackage{caption}
\usepackage{amsmath,amssymb}
\usepackage{lmodern}
\usepackage{textcomp}
\usepackage{ifpdf}
\usepackage[export]{adjustbox}
\marksnotpoints
\bracketedpoints
\pointsdroppedatright
\pointsinrightmargin
\pagestyle{headandfoot}
\headrule
\footrule
\renewcommand{\thepartno}{\Alph{partno}}
\newcolumntype{b}{X}
\newcolumntype{s}{>{\hsize=.1\hsize}X}
\begin{document}
\begin{questions}
\question{\textbf{ Solve ANY ONE}}[4]  \begin{parts}
\part[2]
 Prepare a speech, to be belivered at your school, on the topic "Health is Wealth", on the occasion of world Health Day .
\part[2]
Solve Any TWO
\begin{subparts}
\subpart[1]  \rule{1cm}{0.4pt}  was known as peace-loving and cultured city-state. (Marathon, Athens, Sparta)
\subpart[1] The first tool made by man was  \rule{1cm}{0.4pt}  . (Hand axe, a Spear, an Adaze)
\subpart[1] Lord Buddha preached in  \rule{1cm}{0.4pt}  language. (Hindi, Pali, Sanskrit)
\end{subparts}
\end{parts}
\end{questions}
\end{document}
3
  • 1
    1st question: you have to write \question[4]{\textbf{ Solve ANY ONE}} and not \question{\textbf{ Solve ANY ONE}}[4]. Aug 25, 2013 at 17:56
  • On www-math.mit.edu/~psh/exam/examdoc.pdf page 31 they explain how you should do this. I tried but still have problems with the alignment. code is like this in the preamble: \qformat{Question \thequestion \hfill} Aug 25, 2013 at 18:07
  • Thank You ; First question is resolved after implementing your solution.
    – Pawan Mude
    Aug 25, 2013 at 18:10

2 Answers 2

9
  1. You are misusing \question; the syntax is \question[<points>], so you should use

    \question[4] 
    \textbf{ Solve ANY ONE}
    
  2. To change only the label used for numbering questions, redefine \questionlabel:

    \renewcommand\questionlabel{Q.\thequestion.}
    

    To change the representation for the counter altogether, redefine \thequestion:

    \renewcommand\thequestion{Q.\arabic{question}}
    

The complete code:

\documentclass[addpoints,answers,10pt]{exam}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{nonfloat}
\usepackage{caption}
\usepackage{amsmath,amssymb}
\usepackage{lmodern}
\usepackage{textcomp}
\usepackage{ifpdf}
\usepackage[export]{adjustbox}
\marksnotpoints
\bracketedpoints
\pointsdroppedatright
\pointsinrightmargin
\pagestyle{headandfoot}
\headrule
\footrule
\renewcommand{\thepartno}{\Alph{partno}}
\newcolumntype{b}{X}
\newcolumntype{s}{>{\hsize=.1\hsize}X}

\renewcommand\questionlabel{\llap{Q.}\thequestion.}

\begin{document}
\begin{questions}
\question[4]
\textbf{Solve ANY ONE}
\begin{parts}
\part[2]
 Prepare a speech, to be belivered at your school, on the topic "Health is Wealth", on the occasion of world Health Day .
\part[2]
Solve Any TWO
\begin{subparts}
\subpart[1]  \rule{1cm}{0.4pt}  was known as peace-loving and cultured city-state. (Marathon, Athens, Sparta)
\subpart[1] The first tool made by man was  \rule{1cm}{0.4pt}  . (Hand axe, a Spear, an Adaze)
\subpart[1] Lord Buddha preached in  \rule{1cm}{0.4pt}  language. (Hindi, Pali, Sanskrit)
\end{subparts}
\end{parts}
\end{questions}
\end{document}

enter image description here

1
  • 1
    @karlkoeller thanks. I've deleted the spurious code. Aug 25, 2013 at 23:30
7

Although Gonzalo has answered your question already, I just wanted to point out that you are not only misusing \question, but also misunderstanding (or misusing) the concept of points.

It seems to me that you want your question worth 4 points, but you are declaring it worth 11 points.

Infact, if you put a command \droptotalpoints after your question, you will see "Total for Question 1: 11" which is not correct.

The right way is to put \noaddpoints when the points number serves only as an information and restore the meaning with \addpoints when needed.

Below is an example that shows this concept. The first question is your original one with the uncorrect number of points and the second question the modified one which uses the correct number.

\documentclass[addpoints,answers,10pt]{exam}
\usepackage[T1]{fontenc}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{nonfloat}
\usepackage{caption}
\usepackage{amsmath,amssymb}
\usepackage{lmodern}
\usepackage{textcomp}
\usepackage{ifpdf}
\usepackage[export]{adjustbox}
\marksnotpoints
\bracketedpoints
\pointsdroppedatright
\pointsinrightmargin
\pagestyle{headandfoot}
\headrule
\footrule
\renewcommand{\thepartno}{\Alph{partno}}
\newcolumntype{b}{X}
\newcolumntype{s}{>{\hsize=.1\hsize}X}

\renewcommand\questionlabel{\llap{Q.}\thequestion.}

\begin{document}

\begin{questions}

\question[4]
\textbf{Solve ANY ONE}
\begin{parts}
\part[2]
 Prepare a speech, to be belivered at your school, on the topic "Health is Wealth", on the occasion of world Health Day .
\part[2]
Solve Any TWO
\begin{subparts}
\subpart[1]  \rule{1cm}{0.4pt}  was known as peace-loving and cultured city-state. (Marathon, Athens, Sparta)
\subpart[1] The first tool made by man was  \rule{1cm}{0.4pt}  . (Hand axe, a Spear, an Adaze)
\subpart[1] Lord Buddha preached in  \rule{1cm}{0.4pt}  language. (Hindi, Pali, Sanskrit)
\end{subparts}
\end{parts}

\droptotalpoints

\noaddpoints
\question[4]
\textbf{Solve ANY ONE}
\begin{parts}
\addpoints
\part[2]
 Prepare a speech, to be belivered at your school, on the topic "Health is Wealth", on the occasion of world Health Day .
\part[2]
Solve Any TWO
\begin{subparts}
\noaddpoints
\subpart[1]  \rule{1cm}{0.4pt}  was known as peace-loving and cultured city-state. (Marathon, Athens, Sparta)
\subpart[1] The first tool made by man was  \rule{1cm}{0.4pt}  . (Hand axe, a Spear, an Adaze)
\subpart[1] Lord Buddha preached in  \rule{1cm}{0.4pt}  language. (Hindi, Pali, Sanskrit)
\end{subparts}
\end{parts}

\droptotalpoints

\end{questions}


\end{document}

Output

enter image description here

I apologize if you've read this answer and you were not interested in such things...

3
  • Thank you for precise and concise explanation of the points concept. This is one of the best post to get clarification.
    – Pawan Mude
    Aug 26, 2013 at 6:50
  • @PawanMude You're welcome. Aug 26, 2013 at 6:52
  • How to make the new question label (i.e. \llap{Q.}\thequestion.) left-aligned with the text or the question body without going through the left margin?
    – Diaa
    Sep 2, 2018 at 16:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .