I am trying to create my first class, which is basically just my ordinary preamble with a set of options. These options are handled by xkeyval
using the following syntax:
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{myclass}[2013/07/19]
\RequirePackage{xkeyval}
\DeclareOptionX{firstoption}[]{\newcommand\myclass@firstoption{#1}}
\DeclareOptionX{secondoption}[]{\newcommand\myclass@secondoption{#1}}
\presetkeys{myclass.cls}{}{firstoption, secondoption} %sets all keys to their default values
%unless set by the user
\ProcessOptionsX\relax
\LoadClass{memoir}
\RequirePackage{etoolbox}
\title{\ifblank{\myclass@firstoption}{% check if firstoption is blank
%do nothing
}{%
\myclass@firstoption: %
}%
\myclass@secondoption%
}
The last piece of code is supposed to output firstoption: secondoption
if firstoption
is not blank, but only secondoption
in case of the opposite.
However, for strange reasons, the colon always appears, independently of whether or not firstoption
is set.
Best Answer
The right test to use is
\ifdefempty