I am a teacher and I need to use for all of my exams a table converting intervals of so called "value points" to points comprised between 0 and 20. I use the following table:
\documentclass[addpoints,12pt]{exam}
\newcolumntype{?}[1]{!{\vrule width #1}} % to have bold vertical line in tabular
\usepackage{makecell} % to be able to use \\ linebreaks in tabular
\begin{document}
\setlength\tabcolsep{0.25em}
{\renewcommand{\arraystretch}{1}% for the vertical padding
\begin{tabular}{| p{1.3cm} |c | c | c | c | c | c | c | c | c | c ?{1mm} c | c | c | c | c | c | c | c | c | c | c |}
\hline
Value points & \makecell{0\\-\\3} & \makecell{4\\-\\7} & \makecell{8\\-\\11} & \makecell{12\\-\\15} & \makecell{16\\-\\19} & \makecell{20\\-\\23} & \makecell{24\\-\\27} & \makecell{28\\-\\31} & \makecell{32\\-\\35} & \makecell{36\\-\\39} &
\makecell{40\\-\\43} & \makecell{44\\-\\47} & \makecell{48\\-\\51} & \makecell{52\\-\\55} & \makecell{56\\-\\59} & \makecell{60\\-\\63} & \makecell{64\\-\\67} & \makecell{68\\-\\71} & \makecell{72\\-\\75} & \makecell{76\\-\\79} & \makecell{80\\-\\83} \\
\hline
Marks & 0& 1 & 2 & 3 & 4 & 5 & 6& 7& 8 & 9 & 10 & 11 & 12 & 13 & 14 &15 & 16 & 17 & 18 & 19 & 20 \\
\hline
\end{tabular}
}
\end{document}
These value points are different for all exams (in this example the maximum number is 83, but it may be any other number), whereas points are always between 0 and 20. So the the second line in the table should be fixed, and the number of columns also. I would like to fill the first line dynamically depending on the maximum number, so somehow every cell in the first row should be filled in a for loop. How could I achieve this?
Best Answer
With the table dimensions being fixed, you can set a number of formulae in each cell that define the range. Below I define
\lrange{<num>}
and\urange{<num>}
where you specify thel
ower andu
pper range block (from 0 to 20) andxfp
is used to figure out the corresponding lower/upper range values. The total/m
aximums
core for the test is held inside\ms
(but this could be changed to automatically pick up the total score on the test).Of course, I played around with the formatting, which you can revert to your style.