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 have read the docs and the tutorial about kvoptions and xkeyval but I can not get my xkeyval example to compile.

This is the error:

! LaTeX Error: Missing \begin{document}.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
....
l.10 \define@choicekey*{test}[war
ning]{errorlevel}{info,warning,error}{}

which I get with this code:

\documentclass{scrbook}
\usepackage{filecontents}    

% Test using xkeyval
\begin{filecontents}{options.sty}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{options}
\RequirePackage{xkeyval}
%
\define@choicekey*{test}[warning]{errorlevel}{info,warning,error}{}
\setkeys{test}{errorlevel=info}
\ProcessOptionsX

\providecommand\printerrorlevel{%
Errorlevel is: \KV@test@errorlevel%
}
\end{filecontents}

\usepackage[errorlevel=error]{options}

\begin{document}
\printerrorlevel
\end{document}

what am I doing wrong?

(posted also on de.comp.text.tex, but with no answer)

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

According to the syntax

\define@choicekey*[pre]{fam}{key}[bin]{al}[dft]{func}

check delimiters, the first argument is optional, the second argument cannot be in brackets. For example:

\define@choicekey*{warning}{errorlevel}{info,warning,error}{}

Also consider specifying the family for \ProcessOptionsX, such as

\ProcessOptionsX<warning>
share|improve this answer
add comment

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.