Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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
\let\then\iftrue
{\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\Ifbl@nk#1#2@#3#4!{\ifx#3#4}
\long\gdef\ifnull#1\then{\IfN@LL#1* {#1}!}% if null
\long\gdef\IfN@LL#1 #2!{\ifblank{#2}\then}
}
\setcounter{tocdepth}{0}
%\setlength{\parskip}{\medskipamount}  % a little space before a \par
\setlength{\parindent}{0pt}       % don't indent first lines of paragraphs
\renewcommand{\arraystretch}{1.2}
%
\newenvironment{paper}[1]{\ifgiven{#1}\then\papernum{#1}\fi\maketitle}%
{\label{last@quest}%
\@recordmarks{\arabic{question}}{\arabic{qmarkcnt}}\gentoctable}
%
\long\def\instructions#1{\long\def\@instructions{#1}}\def\@instructions{}
\def\papernum#1{\def\@papernum{#1}}\def\@papernum{}
\def\course#1{\def\@course{#1}}\def\@course{}
\def\totalmarks#1{\def\@totalmarks{#1}}\def\@totalmarks{}
\def\totaltime#1{\def\@totaltime{#1}}\def\@totaltime{}
\def\nocalculator{\def\@calcu{NOT }}\def\@calcu{}
%
\def\maketitle{\par
\begingroup
\global\@topnum\z@ \@maketitle 
\endgroup
\let\maketitle\relax
\let\@maketitle\relax
\gdef\@title{}\gdef\@course{}\gdef\@papernum{}\gdef\@instructions{}
\gdef\@totalmarks{}\gdef\@totaltime{}\gdef\@calcu{}
% \let\thanks\relax
}
%
\def\@maketitle{\newpage
\null
\begin{center}\Large
  Uni
  \bigskip
  CS \@course\\[\baselineskip]
  {\bf \@title}
  \ifx\@empty\@papernum
  \else
    \\[.5\baselineskip]{\bf Paper \@papernum} 
  \fi\\
\end{center}
\rule{\textwidth}{1pt}
\@instructions\par
\begin{minipage}[t]{.5\textwidth}
\begin{tabbing}
{\bf Marks:}x \= \kill
{\bf Marks:}\>\@totalmarks \\[\baselineskip]
{\bf Time:} \>\@totaltime
\end{tabbing}
\end{minipage}
\hfill
\begin{minipage}[t]{.5\textwidth}\raggedleft
\begin{itemize} \itemsep 0pt
\item Approximate marks per question are shown in brackets
\item The use of calculators is \@calcu permitted
\end{itemize}
\end{minipage}
\rule{\textwidth}{1pt}
}

\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
    \fi
  { \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.
\newcounter{question}
\newcounter{qmarkcnt}[question]
\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
  \@recordmarks{\arabic{question}}{\arabic{qmarkcnt}}
  \@afterindentfalse          % Suppresses indent in first paragraph.
  \secdef\@question\@squestion}
\def\@question[#1]#2{\@@quest{#2}}
% Heading for \question* command
\def\@squestion#1{\@@quest{#1}}
\def\@@quest#1{%
  \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.
%
\def\qmarks#1{\@ifundefined{q@#1}{??\@warning
  {Total marks for Question `#1' on page \thepage \space
    undefined}}{\edef\@tempa{\@nameuse{q@#1}}\@tempa}}
%
\def\@recordmarks#1#2{\@bsphack\ifnum #1 >\z@\if@filesw {%
\def\protect{\noexpand\noexpand\noexpand}%
\xdef\@gtempa{\write\@auxout{\string\newqmarks{#1}{#2}}}}\@gtempa
%\ifnum #1 >\lastquestion\lastquestion=#1\fi
\fi\fi\@esphack}
% 
% #1 = question number; #2 = total marks
\def\newqmarks#1#2{\@ifundefined{q@#1}{}{\@warning
  {Question `#1' total marks multiply defined}}\global\@namedef{q@#1}{#2}}
%

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

\def\labelenumi{\alph{enumi})}
\def\theenumi{(\alph{enumi})}

\def\labelenumii{\theenumii)}
\def\theenumii{\roman{enumii}}
\def\p@enumii{\theenumi}

\def\labelenumiii{\theenumiii.}
\def\theenumiii{\Alph{enumiii}}
\def\p@enumiii{\theenumi\theenumii.}

\def\labelenumiv{\theenumiv.}
\def\theenumiv{\arabic{enumi}}
\def\p@enumiv{\p@enumiii\theenumiii.}
\newcount\lincnt

\newcommand{\mrks}[1]{\mbox{}\nobreak\hfill\nobreak[#1]%
\addtocounter{qmarkcnt}{#1}}
\newcommand{\linemarks}[1]{\mbox{}\nobreak\hrulefill\ \nobreak[#1]%
\addtocounter{qmarkcnt}{#1}}
\newcommand{\lines}[1]{\par\mbox{}\hrulefill\mbox{}\lincnt=1
\loop\ifnum\lincnt<#1 \advance\lincnt by 1
\\[.5\baselineskip]\mbox{}\hrulefill\mbox{}\repeat\\\mbox{}}
\newcommand{\forcemarks}[1]{\setcounter{qmarkcnt}{#1}}

\def\tableofcontents{%\begin{center}
% {\bf NAME: \fbox{\rule[-.2ex]{0pt}{2ex}\hspace*{9cm}}\hfill STUDENTNO:
%\framebox[3cm]{\rule[-.2ex]{0pt}{2ex}}}\\[.5\baselineskip]
%
{\bf NAME:} \raisebox{2.8ex}{\makebox[0pt][l]{Surname}}%
\fbox{\rule[-.2ex]{0pt}{2ex}\hspace*{9cm}}%
\raisebox{2.8ex}{\makebox[0pt][r]{Initials}}\\[.5ex]
{\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]
\begin{center}
\@starttoc{toc}\addtocontents{toc}{
\protect\begin{tabular}{|rr|l|l||rr|l|l|}
\protect\hline\protect\multicolumn{8}{|c|}{\bf Mark Allocation}\protect\\
\protect\hline\protect\hline
Quest & Marks & Internal & External &
Quest & Marks & Internal & External \protect\\\protect\hline}
\end{center}\clearpage}

\def\gentoctable{\@ifundefined{tf@toc}{}{%
\@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\@ifundefined{q@\number\lincnt}{[??]}%
{[\protect\@nameuse{q@\number\lincnt}]} & & & 
\number\@tempcnta & 
\protect\@ifundefined{q@\number\@tempcnta}{}%
{[\protect\@nameuse{q@\number\@tempcnta}]}
& & \protect\\\protect\hline}%
\repeat%
\@tempcnta=\c@question\advance\@tempcnta by 1\divide\@tempcnta by 2
\ifnum\lincnt <\@tempcnta%
\addtocontents{toc}{
\number\@tempcnta & 
\protect\@ifundefined{q@\number\@tempcnta}{[??]}%
{[\protect\@nameuse{q@\number\@tempcnta}]} &&& &&&
\protect\\\protect\hline}%
\fi%
\addtocontents{toc}{
\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{2}{|r|}{\protect\rule{0pt}{4ex}}
\protect\\\protect\cline{7-8}\protect\hline
\protect\multicolumn{4}{|l||}{\bf Internal Examiner:\protect\rule{0pt}{4ex}}& 
\protect\multicolumn{4}{l|}{\bf External Examiner:}
\protect\\\protect\hline
\protect\end{tabular}}%
}}%
%
% Change \enddocument so it checks the \q@i values for changes similar to
% what is done with references.
%
\def\enddocument{%
\@checkend{document}\clearpage\begingroup%
\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}

mwe:

    \documentclass[A4paper,test,11pt]{article}
\usepackage{test}

\begin{document}
\title{test}

\begin{paper}{}

\question{}
\begin{enumerate}
\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

\end{enumerate}


\end{paper}
\end{document}

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.

share|improve this question
    
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
add comment

1 Answer

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

\documentclass{article}

\makeatletter

\newdimen\mrkscnt

\newenvironment{qn}
{\bigskip\mrkscnt\z@}
{\par Total: \strip@pt\mrkscnt}

\newcommand{\mrks}[1]{\par\mbox{}\nobreak\hfill\nobreak[#1]%
 \advance\mrkscnt#1\p@
}



\makeatother

\begin{document}

\begin{qn}
\mrks{1}
\mrks{3.5}
\mrks{2}
\end{qn}

\begin{qn}
\mrks{1.25}
\mrks{3.5}
\mrks{10}
\end{qn}

\end{document}
share|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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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