I would like to be able to add half marks to my questions, but I don't know how to handle these with\stepcounter. Below is part of my style file, please could you help? I essentially want to say \mrks{0.5}, and have to those added to the total total marks printed at the top of the question define by my \question{} command.

   \typeout{ exam paper style -- Version 06/06/14}

%  \ifnull  --- checks if parameter is null (spaces are NOT null)
%  \ifblank --- checks if parameter is blank (i.e. null or spaces)
%  \ifgiven --- checks if parameter is not blank: like \ifblank\else
%     use \ifgiven{#1}\then   ...  \else  ...  \fi   etc
{\catcode`\!=8 % funny catcode so ! will be a delimiter
\long\gdef\ifgiven#1\then{\Ifbl@nk#1@@@\empty!}% negative of \ifblank
\long\gdef\ifblank#1\then{\Ifbl@nk#1@@..!}% if null or spaces
\long\gdef\ifnull#1\then{\IfN@LL#1* {#1}!}% if null
\long\gdef\IfN@LL#1 #2!{\ifblank{#2}\then}
%\setlength{\parskip}{\medskipamount}  % a little space before a \par
\setlength{\parindent}{0pt}       % don't indent first lines of paragraphs
\def\nocalculator{\def\@calcu{NOT }}\def\@calcu{}
\global\@topnum\z@ \@maketitle 
% \let\thanks\relax
  CS \@course\\[\baselineskip]
  {\bf \@title}
    \\[.5\baselineskip]{\bf Paper \@papernum} 
{\bf Marks:}x \= \kill
{\bf Marks:}\>\@totalmarks \\[\baselineskip]
{\bf Time:} \>\@totaltime
\begin{itemize} \itemsep 0pt
\item Approximate marks per question are shown in brackets
\item The use of calculators is \@calcu permitted

\def\section{\par            % New paragraph
\ifnum \c@section >\z@ \addvspace{3ex}\hrule height1pt \fi
  \addvspace{4ex}           % Adds vertical space above title.
  \@afterindentfalse        % Suppresses indent in first paragraph.  Change
  \secdef\@section\@ssection}     % to \@afterindenttrue to have indent.

\def\@section[#1]#2{\ifnum \c@secnumdepth >\m@ne    % IF secnumdepth -1
    \refstepcounter{section}                    %  THEN step section counter
  { \parindent \z@ \centering
    \large \bf Section           % Print 'Part'
      \ifnum \c@secnumdepth >\m@ne   % IF secnumdepth -1
      \thesection\@.                 %   THEN  print number
      \fi                            % FI
    #2\markboth{}{}\par }          % Print title and set heading marks null.
    \nobreak                       % TeX penalty to prevent page break.
    \vskip 2ex                     % Space between title and text.
  \@afterheading                  % Routine called after part and
    }                              %     section heading.
% Heading for \section* command
\def\@ssection#1{{\parindent \z@ \centering
    \large\bf Section: #1 \par}              % Title.
    \nobreak                        % TeX penalty to prevent page break.
    \vskip 2ex                      % Space between title and text.
    \@afterheading                  % Routine called after part and
  }                                 %     section heading.
\def\questionmark#1{}  % we don't need header marks
%\def\thequestion{Question \arabic{question}}
%\def\question{\@startsection{question}{2}{\z@}{-3.25ex plus -1ex minus
% -.2ex}{1.5ex plus .2ex}{\bf}}
\def\question{\par             % New paragraph
  \addvspace{3.25ex plus 1ex minus .2ex}  % Adds vertical space before
  \@afterindentfalse          % Suppresses indent in first paragraph.
% Heading for \question* command
  \refstepcounter{question}         % step question counter
  {\bf Question \thequestion. #1    % Print 'Question n.' and title
    \hspace{2em}                     % Print total marks...
    [\qmarks{\arabic{question}} marks]
    \markboth{}{}\par}               % set heading marks null.
    \nobreak                       % TeX penalty to prevent page break.
    \vskip 1.5ex plus .2ex         % Space between title and text.
  \@afterheading                  % Routine called after part and
}                                  %     section heading.
  {Total marks for Question `#1' on page \thepage \space
\def\@recordmarks#1#2{\@bsphack\ifnum #1 >\z@\if@filesw {%
%\ifnum #1 >\lastquestion\lastquestion=#1\fi
% #1 = question number; #2 = total marks
  {Question `#1' total marks multiply defined}}\global\@namedef{q@#1}{#2}}

\leftmargini  2em
\leftmarginii \leftmarginiii
\leftmarginiii \leftmarginiv





\newcommand{\linemarks}[1]{\mbox{}\nobreak\hrulefill\ \nobreak[#1]%
\loop\ifnum\lincnt<#1 \advance\lincnt by 1

% {\bf NAME: \fbox{\rule[-.2ex]{0pt}{2ex}\hspace*{9cm}}\hfill STUDENTNO:
{\bf NAME:} \raisebox{2.8ex}{\makebox[0pt][l]{Surname}}%
{\bf STUDENT NO:} \framebox[3.5cm]{\rule[-.2ex]{0pt}{2ex}} \hfill
{\bf COURSE CODE:} \framebox[2.5cm][l]{CSC\rule[-.2ex]{0pt}{2ex}}\\[.5\baselineskip]
This paper consists of \ref{last@quest} questions and 
\pageref{last@quest} pages (including this cover page).
%   \\[1ex]
\protect\hline\protect\multicolumn{8}{|c|}{\bf Mark Allocation}\protect\\
Quest & Marks & Internal & External &
Quest & Marks & Internal & External \protect\\\protect\hline}

\@tempcnta=\c@question\advance\@tempcnta by 1\divide\@tempcnta by 2
\@tempcntb=\c@question \divide\@tempcntb by 2 \lincnt=0%
\loop\ifnum\lincnt <\@tempcntb%
\advance\lincnt by 1\advance \@tempcnta by 1
\addtocontents{toc}{\number\lincnt & 
{[\protect\@nameuse{q@\number\lincnt}]} & & & 
\number\@tempcnta & 
& & \protect\\\protect\hline}%
\@tempcnta=\c@question\advance\@tempcnta by 1\divide\@tempcnta by 2
\ifnum\lincnt <\@tempcnta%
\number\@tempcnta & 
{[\protect\@nameuse{q@\number\@tempcnta}]} &&& &&&
\protect\multicolumn{2}{|r|}{\bf Total}& & &
\protect\multicolumn{2}{r|}{\bf Total} & & \protect\\\protect\hline
\protect\multicolumn{6}{r|}{\bf Grand Total} &
\protect\rule{0pt}{4ex} &\protect\\\protect\cline{7-8}
\protect\multicolumn{6}{r|}{\bf Final Mark} & 
\protect\multicolumn{4}{|l||}{\bf Internal Examiner:\protect\rule{0pt}{4ex}}& 
\protect\multicolumn{4}{l|}{\bf External Examiner:}
% Change \enddocument so it checks the \q@i values for changes similar to
% what is done with references.
\if@filesw \immediate\closeout\@mainaux%
\def\global\@namedef##1##2{}\def\newlabel{\@testdef r}%
\def\newqmarks{\@testdef q}% <------- the only change (addition) we made
\def\bibcite{\@testdef b}\@tempswafalse \makeatletter\input \jobname.aux
\if@tempswa \@warning{Label(s) may have changed.  Rerun to get
cross-references right}\fi\fi\endgroup\deadcycles\z@\@@end}





\item A question  \lines{3} \mrks{4}

\item Another question \lines{3} \mrks{4.5} % try 4

\item Another question \lines{3} \mrks{4.5} % try 4



Edit In all honesty I did not write the style file I posted. This was written by someone else years ago whom we cannot contact. I'd really like to implement David's suggestions, but this goes beyond my understanding and experience of latex. I would be keen to learn about lower level latex coding but since I am time constrained I cannot afford this. Any suggestions more specific to the style file I have submitted would be greatly welcome.

  • Welcome to TeX.SE. While code snippets are useful in explanations, it is always best to compose a fully compilable MWE that illustrates the problem including the \documentclass and the appropriate packages so that those trying to help don't have to recreate it. – Peter Grill Mar 26 '13 at 20:03
  • 1
    What do the \DeclareGraphicsRule rule have to do with this question? If you believe that there might be an interaction then fine, but otherwise they should not be here. A MWE should be a complete document that sets up the problem, without any unrelated material. While solving problems can be fun, setting them up is not. Then, those trying to help can simply cut and paste your MWE and get started on solving the problem. – Peter Grill Mar 26 '13 at 20:21
  • in addition to the comment by @PeterGrill I'm not sure what you mean by half mark. Are you saying each problem is assigned points which can take non-integer values? – A.Ellett Mar 26 '13 at 20:29
  • You are trying to load an exam package. I'm not familiar with that. There is, however an exam class. Did you mean the class? – A.Ellett Mar 26 '13 at 20:35
  • I've added a more minimal example. I am a bit lost on how to implement David's suggestions. – user1658296 Mar 27 '13 at 13:02

Your minimal example isn't really close to being minimal so I didn't use it. TeX counters are integers, so you have a choice of either maintaining 10 times the mark and just adding the . while printing, or, as here use a length register and remove the pt at the end.

enter image description here




{\par Total: \strip@pt\mrkscnt}






| improve this answer | |
  • Thank you David. I will try to add this to \question in my sty file – user1658296 Mar 27 '13 at 12:01

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.