3

This is my first posting and I would like to thank you in advance for any suggestions. I am typing all my Math papers (quizzes, tests, exams etc) in Latex and I have this problem that I cannot find any decent solution.

Here is a minimal working example. I would like to have the grading table at the very beginning. However, I don't know how to display the final value of a counters at the beginning of the document. I followed some suggestions using totcount package with no success.

Thanks a lot, Veronica

\documentclass[letterpaper,11pt]{exam}
\usepackage{calc}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcounter{pointKnowledge}
\newcounter{pointApplication}
\newcounter{pointThinking}
\newcounter{pointCommunication}

\def\K#1{{\sf \hfill [K/U /#1]}\addtocounter{pointKnowledge}{#1}}
\def\A#1{{\sf \hfill [A /#1]}\addtocounter{pointApplication}{#1}}
\def\T#1{{\sf \hfill [T /#1]}\addtocounter{pointThinking}{#1}}
\def\C#1{{\sf \hfill [C /#1]}\addtocounter{pointCommunication}{#1}}

\def\resetPoints{\setcounter{pointKnowledge}{0}}
\def\resetPoints{\setcounter{pointApplication}{0}}
\def\resetPoints{\setcounter{pointThinking}{0}}
\def\resetPoints{\setcounter{pointCommunication}{0}}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}

I WOULD LIKE THE GRADING TABLE HERE RATHER THEN AT THE END.\\

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
BEGINNING GRADING TABLE\\

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\vspace{0.2cm}
\begin{tabular}{ |r |r |r |r| r |}  \hline
  Knowledge/Understanding  &    Application     & Communication  & Thinking         & \hspace{0.5cm} Total \hspace{0.5cm} \\ \hline
 /         &   /&    /      &  / &  / \\ [0.25cm] \hline
\end{tabular}


\begin{questions}
\question Question 1 knowledge  \K{1}
\question Question 2 knowledge  \K{5}
\question Question 3 application  \A{2}
\question Question 4 application  \A{5}
\question Question 5 thinking  \T{7}
\question Question 6 thinking  \T{2}
\question Question 6 communication  \C{2}
\question Question 6 communication  \C{3}
\end{questions}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
END GRADING TABLE\\
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcounter{FinalMark}
\setcounter{FinalMark}{\value{pointKnowledge}+\value{pointApplication}+\value{pointThinking}+\value{pointCommunication}}

\begin{tabular}{ |r |r |r |r| r |}  \hline
Knowledge/Understanding  &  Application     & Communication  & Thinking         & \hspace{0.5cm} Total \hspace{0.5cm} \\ \hline
    /\the\value{pointKnowledge}            &   /\the\value{pointApplication}&    /\the\value{pointCommunication}     &  /\the\value{pointThinking} &  /\the\value{FinalMark} \\ [0.25cm] \hline
\end{tabular}

\end{document}
  • Try 1. \begin{tabular}[t!] 2. \usepackage{totcount} \newtotcounter{mycount} \begin{document} \total{mycount} .... your document/ tables, .... \setcounter{mycount}{\the\value{FinalMark}} \end{document}(solution from here worked fine) – Bobyandbob Jul 22 '17 at 16:36

2 Answers2

2

Thank you everyone for your suggestions! Thank you Harald, I used the idea suggested and it worked. I struggled to have the total done, but the problem solved by now. Here is the full solution to my own question:

Veronica

\documentclass[answers,12pt,addpoints]{exam}
\usepackage{calc}
\newcounter{Know}
\def\K#1{{\sf \hfill [K/U /#1]}\addtocounter{Know}{#1}}
\def\resetPoints{\setcounter{Know}{0}}
\newcounter{Appl}
\def\A#1{{\sf \hfill [A /#1]}\addtocounter{Appl}{#1}}
\def\resetPoints{\setcounter{Appl}{0}}
\newcounter{Comm}
\def\C#1{{\sf \hfill [C /#1]}\addtocounter{Comm}{#1}}
\def\resetPoints{\setcounter{Comm}{0}}
\newcounter{Think}
\def\T#1{{\sf \hfill [T /#1]}\addtocounter{Think}{#1}}
\def\resetPoints{\setcounter{Think}{0}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\begin{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\noindent
\ref{Know} Knowledge points\\
\ref{Appl} Application points\\
\ref{Comm} Communication points\\
\ref{Think} Thinking points\\
\ref{Total}\textbf{ Total marks}\\
\begin{questions}
\question question  \K{1}
\question question \K{2}
\question question \A{4}
\question question \A{10}
\question question \C{5}
\question question \C{6}
\question question \T{7}
\question question \T{10}
\end{questions}
\addtocounter{Know}{-1}\refstepcounter{Know} 
\label{Know}
\addtocounter{Appl}{-1}\refstepcounter{Appl}
\label{Appl}
\addtocounter{Comm}{-1}\refstepcounter{Comm} 
\label{Comm}
\addtocounter{Think}{-1}\refstepcounter{Think} 
\label{Think}
\newcounter{Total}
\setcounter{Total}{\value{Know}+\value{Appl}+\value{Think}++\value{Comm}}
\addtocounter{Total}{-1}\refstepcounter{Total}
\label{Total}
\end{document}
0

it is also possible to use a reference to the counters in the beginning of your grading. Such as described in "Die TeXnische Komödie" from 4-2013.

\textbf{Übungsaufgaben zu Brüchen}

\emph{Gesamtpunktzahl: \ref{points} Punkte} 
\newcounter{exnumber}\setcounter{exnumber}{0} 
\newcounter{points} \setcounter{points}{0} 
\newcommand\exercise[1]{\vspace{2ex}%

\addtocounter{points}{#1}%
\stepcounter{exnumber}%

\textbf{Aufgabe \arabic{exnumber}} (#1 \ifthenelse{#1 > 1}{Punkte}{ ↪Punkt}):} 

\exercise{2} Wandeln Sie in einen Bruch um: $0.\overline{545\,26}$
\exercise{1} Weshalb ist $\frac{12}{77}$ nicht als abbrechende Dezimalzahl ↪darstellbar?

\addtocounter{points}{-1}\refstepcounter{points} 

\label{points}
  • 1
    Be care of the two original questions. Please make your code compilable then its easier to test your solution. – Bobyandbob Jul 23 '17 at 19:04