# ifdraft package stops page compilation after upgrade to TexLive 2020

I've been preparing a document, which uses the ifdraft package to include a watermark. Compilation has been fine up until today before I upgraded my installation from TexLive 2019 to TexLive 2020 using the MacTex distribution. The compilation now fails with a ! Package keyval Error: 223 defined. error. I'm compiling with lualatex on the command-line and VIM ex: mode.

Initially, I put it down to the combination of packages I've used, however, I've created a sample file using only ifdraft, blindtext and draftwatermark, which likewise fails:

\documentclass[draft,a4paper]{article}
\usepackage{ifdraft, blindtext}
\ifoptiondraft{%
\usepackage{draftwatermark}
\SetWatermarkText{DRAFT}
\SetWatermarkScale{1}
\SetWatermarkColor[rgb]{0.7,0,0}
}{%
% nothing to see here
}
\begin{document}
\Blindtext
\end{document}


Compiling from VIM with :lualatex %, or the terminal, gives the output:

This is LuaHBTeX, Version 1.12.0 (TeX Live 2020)
restricted system commands enabled.
LaTeX2e <2020-02-02> patch level 5
L3 programming layer <2020-04-06>
(/usr/local/texlive/2020/texmf-dist/tex/latex/base/article.cls
Document Class: article 2019/12/20 v1.4l Standard LaTeX document class
(/usr/local/texlive/2020/texmf-dist/tex/latex/base/size12.clo))
(/usr/local/texlive/2020/texmf-dist/tex/latex/oberdiek/ifdraft.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/blindtext/blindtext.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/tools/xspace.sty))
(/usr/local/texlive/2020/texmf-dist/tex/latex/draftwatermark/draftwatermark.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/kvoptions/kvoptions.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2020/texmf-dist/tex/generic/ltxcmds/ltxcmds.sty)
(/usr/local/texlive/2020/texmf-dist/tex/generic/kvsetkeys/kvsetkeys.sty))
(/usr/local/texlive/2020/texmf-dist/tex/latex/everypage/everypage.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/local/texlive/2020/texmf-dist/tex/latex/graphics-cfg/graphics.cfg)
(/usr/local/texlive/2020/texmf-dist/tex/latex/graphics-def/luatex.def)))
(/usr/local/texlive/2020/texmf-dist/tex/latex/graphics/color.sty
(/usr/local/texlive/2020/texmf-dist/tex/latex/graphics-cfg/color.cfg)))

! Package keyval Error: 223 undefined.

See the keyval package documentation for explanation.
Type  H <return>  for immediate help.
...
l.10 }


I've tried including a package specification in the "else/final" clause so it wasn't empty in case that was the fault, but when draft is included in documentclass, the above error occurs without fail. The closing brace is highlighted each time.

Perhaps someone could give me a pointer where I should be looking. I'm at a bit of loss where to look.

• the error is not from ifdraft but from \SetWatermarkColor[rgb]{0.7,0,0}. Apr 27 '20 at 15:02
• Use \definecolor{wmc}{rgb}{0.7,0,0}\SetWatermarkColor{wmc} instead of \SetWatermarkColor[rgb]{0.7,0,0} Apr 27 '20 at 15:10
• The error is not specific to luatex Apr 27 '20 at 15:13
• the setting of colors with a specification is broken, there is a brace pair missing and the colors are not correctly expanded later. Make a bug report. Apr 27 '20 at 15:16
• Your help narrowing it down to \SetWatermarkColor, I realised changing the colour model to gray worked. The problem definitely lies with the rgb model. Apr 27 '20 at 21:07

There is a bug in draftwatermark, when it passes the colorspec option without any protection against interpreting commas in the color specification.

You can work around it by loading xcolor and bracing the color specification.

\documentclass[draft,a4paper]{article}
\usepackage{ifdraft, blindtext,xcolor}
\ifoptiondraft{%
\usepackage{draftwatermark}
\SetWatermarkText{DRAFT}
\SetWatermarkScale{1}
\SetWatermarkColor[rgb]{{0.7,0,0}}
}{%
% nothing to see here
}
\begin{document}
\Blindtext
\end{document}

• Nice! Thank you @egreg. Why does the additional bracing work? Apr 27 '20 at 20:49
• \SetWatermarkColor passes another macro the option colorspec=#2, which in your case becomes colorspec=0.7,0,0 and the 0 becomes an option, whence the strange error. Apr 27 '20 at 21:06