Skip to content

Instantly share code, notes, and snippets.

@benzea
Created August 13, 2013 15:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benzea/6222666 to your computer and use it in GitHub Desktop.
Save benzea/6222666 to your computer and use it in GitHub Desktop.
SDAPS class patch to enable row coloring. With the issue that checkboxes move slightly (0.0001pt or so) which changes the survey ID.
diff --git a/tex/sdaps.cls b/tex/sdaps.cls
index 89abf1e..602b1c8 100644
--- a/tex/sdaps.cls
+++ b/tex/sdaps.cls
@@ -120,7 +120,7 @@
\RequirePackage[T1]{fontenc}
% color
-\RequirePackage{color}
+\RequirePackage{xcolor}
% Symbols (boxes)
\RequirePackage{amssymb}
@@ -191,6 +191,37 @@
% Code 128 implementation in plain TeX
\include{code128}
+% Load Row coloring code (this requires a workaround)
+\AtBeginDocument{%
+ % The default value of the defines, simply do not do anything about
+ % row coloring.
+ \def\@sdaps@rowcolor#1{\relax}%
+ \def\@sdaps@rowcolors#1#2#3{\relax}%
+ \def\@sdaps@showrowcolors{\relax}%
+ \def\@sdaps@hiderowcolors{\relax}%
+ \def\@sdaps@multicol@fill@workaround{\relax}%
+ %
+ \@ifpackageloaded{colortbl}{%
+ % Is the rowcolors command defined?
+ % If yes, enable all the rowcolor usage in SDAPS.
+ \ifx\rowcolors\@undefined%
+ \else%
+ % Use the rowcolors command
+ \let\@sdaps@rowcolor\rowcolor%
+ \let\@sdaps@rowcolors\rowcolors%
+ \let\@sdaps@showrowcolors\showrowcolors%
+ \let\@sdaps@hiderowcolors\hiderowcolors%
+ \fi
+ % This is a nasty little workaround. colortbl does not support fills
+ % inside multicolumn cells. However, adding corresponding skip *after*
+ % the \multicolumn command works around this issue.
+ \def\@sdaps@multicol@fill@workaround{\hskip 0pt plus -1fill}%
+ }{%
+ % Nothing to do
+ }%
+}
+
+
% http://www.tex.ac.uk/cgi-bin/texfaq2html?label=isitanum
\def\IsPositive#1{%
TT\fi
@@ -679,6 +710,10 @@
\definecolor{sectionbgcolor}{gray}{0.8}
\definecolor{sectionfgcolor}{gray}{0.0}
+\definecolor{choicegroupheadcolor}{gray}{1.0}
+\definecolor{groupevenrowcolor}{gray}{1.0}
+\definecolor{groupoddrowcolor}{gray}{1.0}
+
% Execute sdaps.opt file to allow SDAPS to override any options
\InputIfFileExists{sdaps.opt}{}{}
@@ -942,7 +977,8 @@
\question{#1}%
\protectedimmediatewrite\sdapsoutfile{QObject-Head=\arabic{section}.\arabic{subsection}. #1} %
\setcounter{choicegroupnumchoices}{0} %
- \global\def\@sdaps@choicegroup@start{\tabularx{\linewidth}{X*{\thechoicegroupnumchoices}{c}}} %
+ \@sdaps@rowcolors{1}{groupevenrowcolor}{groupoddrowcolor}%
+ \global\def\@sdaps@choicegroup@start{\tabularx{\linewidth}{X*{\thechoicegroupnumchoices}{c}}\@sdaps@rowcolor{choicegroupheadcolor}} %
\global\def\@sdaps@choicegroup@boxes{} %
}{%
\ifnum\thechoicegroupnumchoices>-1 %
@@ -960,6 +996,7 @@
\ifnum\thechoicegroupnumchoices>0
% Move to the next line (as it is not part of the @start macro)
\\ %
+ % Enable row colors
\setcounter{choicegroupnumchoices}{-1} %
\fi %
\protectedimmediatewrite\sdapsoutfile{QObject-Choice=#1}%
@@ -1002,6 +1039,7 @@
\protectedimmediatewrite\sdapsoutfile{QObject-Head=\arabic{section}.\arabic{subsection}. #1}%
\@sdaps@markenvactivetrue%
\@sdaps@generatemarkboxes%
+ \@sdaps@rowcolors{1}{groupoddrowcolor}{groupevenrowcolor}%
\tabularx{\linewidth}{Xr*{\themarkcheckboxcount}{c}l}
}{%
\@sdaps@markenvactivefalse%
@@ -1149,7 +1187,7 @@
\fi%
\addtocounter{textboxnum}{1}%
\endgroup%
- }%
+ }\@sdaps@multicol@fill@workaround%
\ifthenelse{\thechoiceitems>\themaxchoiceitems}{%
\setcounter{choiceitems}{1}%
\\%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment