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 get the following error in my .dtx file:

) (./test.dtx
! Undefined control sequence.
l.35 % \rowcolors
{1}{colorrow}{colorbody}

which I do not understand since xcolor and colortbl are loaded and all other xcolor commands work.

This is the code of the .dtx file for testing:

% \iffalse
%<*driver>
\ProvidesFile{test.dtx}
%</driver>
%<package>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{test}
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{test}
\EnableCrossrefs
\CodelineIndex
\RecordChanges
%
\RequirePackage{colortbl}
\RequirePackage{xcolor}
%
\listfiles
\begin{document}
  \DocInput{test.dtx}
  \PrintChanges
  \PrintIndex
\end{document}
%</driver>
% \fi
%
% \GetFileInfo{test.dtx}
%
% \colorlet{colorbody}{white!100}
% \colorlet{colorsubhead}{gray!30}
% \colorlet{colorhead}{gray!25}
% \colorlet{colorrow}{gray!15.0}
%
% \rowcolors{1}{colorrow}{colorbody}
% \begin{tabular}{*{2}{p{0.45\textwidth}}}
%  content  & content \tabularnewline
%  content  & content \tabularnewline
%  content  & content \tabularnewline
% \end{tabular}
% 
% \StopEventually{}
% \clearpage
% \section{Implementation}
%
% \iffalse
%<*test.sty>
% \fi
%
% \subsection{Setup and packages}           
%
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}[1994/12/01]
\ProvidesPackage{test}
%    \end{macrocode}
% 
%    \begin{macrocode}
\RequirePackage{array}
\RequirePackage{colortbl} 
\RequirePackage{xcolor}
%    \end{macrocode}
%
% \iffalse
%</test.sty>
% \fi
%
% \Finale
\endinput
share|improve this question
1  
Read my comments in your previous question: tex.stackexchange.com/questions/35156/…. You must use the [table]-Option when loading xcolor. –  Ulrike Fischer Nov 18 '11 at 15:29

1 Answer 1

up vote 3 down vote accepted

You should replace

\RequirePackage{colortbl}
\RequirePackage{xcolor}

at line 16+17 by

\usepackage[table]{xcolor}

because package loading at the document preamble should be done using \usepackage instead of \RequirePackage, and at line 59+60 by

\RequirePackage[table]{xcolor}

because loading both packages on your own is not the same. Section 2.12, "Color in table", of xcolor manual recommends using the option because:

These commands require the table option.

"These commands" are \rowcolors, \rowcolors*, \showrowcolors, \hiderowcolors, and \rownum (which is not a command but a TeX counter).

share|improve this answer
    
The reason why I load them separately is shown here: tex.stackexchange.com/questions/35156/…. If I load the package with options I risk option clash problems. –  Matthias Pospiech Nov 18 '11 at 18:28
    
Nevertheless it is better, that the user gets information about a problem instead of having a problem without information. I'd add something like \@ifpackageloaded{xcolor}{\@ifundefined{\rowcolors}{\PackageError{test}{xcolor must not be loaded before test without option table}{You've already …}}{}}{} before \RequirePackage[table]{xcolor} at test.sty, to give the user more information about the problem and to suggest a solution. –  Schweinebacke Nov 19 '11 at 7:38
    
I do that already. –  Matthias Pospiech Nov 19 '11 at 15:18

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.