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'd like to write a command that checks the given arguments and throws an error if they are not in a range.

I'm imagining this would look something like this:

\usepackage{xifthen}

\newcommand{\wb}[2][]{\ifthenelse{{#2} > 0 \AND {#2} < 7}
    {\includegraphics[{#1}]{wong-baker/{#2}.eps}}}
    {%throw error here}
}

How can I check parameters in newcommand?

share|improve this question

1 Answer 1

up vote 10 down vote accepted
\PackageError{mypackage}{dont do that}{extra help}

see section 4.9 of texdoc clsguide

share|improve this answer
1  
Does this also work for a quick command which is not inside any package? –  ipavlic Jun 9 at 12:19
1  
@ipavlic yes you can put anything you like in the mypackage argument it doesn't have to be really the name of a package. –  David Carlisle Jun 9 at 12:20

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.