1

I have the ISBN stored in two commands (depending of a class option)

\theisbne
\theisbnp

The boolean options of the class are defined using xifthen

\RequirePackage{xifthen}
\newboolean{@sbmcpm@print}
\setboolean{@sbmcpm@print}{true}
\DeclareOption{ebook}{\setboolean{@sbmcpm@print}{false}}
\DeclareOption{print}{\setboolean{@sbmcpm@print}{true}}

I get the selected ISBN by the command

\newcommand{\getisbn}{%
  \ifthenelse{\boolean{@sbmcpm@print}}{\theisbnp}{\theisbne}%
}

If I use \psbarcode directly with \theisbne it compiles without error.

 \psbarcode{\theisbne}{includetext guardwhitespace}{isbn}

But if I use \getisbn

\psbarcode{\getisbn}{includetext guardwhitespace}{isbn}

I got the following error:

! Argument of \pst@@object has an extra }.
<inserted text> 
                \par 
l.33 ...etisbn}{includetext guardwhitespace}{isbn}

Any idea where to look?

MWE

\documentclass{article}

\usepackage{xifthen}
\usepackage{pst-barcode}

\newboolean{@sbmcpm@print}
\setboolean{@sbmcpm@print}{true}

\newcommand{\theisbne}{978-85-8337-040-6}%
\newcommand{\theisbnp}{978-85-85818-86-9}%


%%% Commands depending the options
\newcommand{\getisbn}{%
  \ifthenelse{\boolean{@sbmcpm@print}}{\theisbnp}{\theisbne}%
}

\begin{document}

\psbarcode{\getisbn}{includetext guardwhitespace}{isbn}
%\psbarcode{\theisbne}{includetext guardwhitespace}{isbn}


\end{document}
Werner
  • 603,163
TeXtnik
  • 5,853

1 Answers1

1

Your use of @ without \makeatletter is problematic (in general). Also, the conditional for selecting between the possible bar ISBNs is not expandable. Instead, I've used traditional \if-statements to condition below:

enter image description here

\documentclass{article}

\usepackage{pst-barcode}

\makeatletter
\newif\if@sbmcpm@print
\@sbmcpm@printtrue

%%% Commands depending the options
\newcommand{\getisbn}{%
  \if@sbmcpm@print\theisbnp\else\theisbne\fi
}
\makeatother

\newcommand{\theisbne}{978-85-8337-040-6}%
\newcommand{\theisbnp}{978-85-85818-86-9}%

\begin{document}

\psbarcode{\getisbn}{includetext guardwhitespace}{isbn}

\end{document}

Here is an expandable etoolbox equivalent:

\usepackage{etoolbox}
\makeatletter
\newbool{@sbmcpm@print}
\setbool{@sbmcpm@print}{true}

%%% Commands depending the options
\newcommand{\getisbn}{%
  \ifbool{@sbmcpm@print}{\theisbnp}{\theisbne}%
}
\makeatother
Werner
  • 603,163
  • Thanks. The problem is the second. The original definition was in a cls file and I copu&paste to the MWE. – TeXtnik Oct 24 '15 at 21:49