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 encountered a problem that I want to compare the \CurrentOption with a string.

In the .tex file I have a code below.

\usepackage[en-ver]{cufestatletter}

Then I want to use \ifx to determine whether I use en-ver option or not. This is the code I use now.

\ifx \CurrentOption \en-ver
\chead{\cufestatlogo}
\else
\lhead{\cufestatlogo}
\fi

I have declared the option en-ver using:

\DeclareOption{en-ver}{\def\cufestatlogo
{\hspace*{-0.6in} \includegraphics[scale=0.07]{Header_En_ver.jpg}}} 

However, this \ifx code doesn't work at all.

share|improve this question
    
Welcome to TeX.SE! Sounds like an interesting question :) Do you think you could turn your snippets into a MWE It'll really help folks who wish to look at your problem. Welcome :) –  cmhughes Dec 9 '12 at 21:33

1 Answer 1

up vote 8 down vote accepted

There are several ways to test for the option en-ver:

  • Testing the effect that \cufestatlogo will be defined by the option:

    \let\cufestatlogo\relax % initialization
    \DeclareOption{en-ver}{\def\cufestatlogo{...}}
    ...
    \ifx\cufestatlogo\relax
      % option en-ver not used
    \else
      % option en-ver used
    \fi
    
  • Adding a switch:

    \newif\ifcufestatlogo
    \DeclareOption{en-ver}{%
      \def\cufestatlogo{...}%
      \cufestatlogotrue
    }%
    ...
    \ifcufestatlogo
      % option en-ver used
    \else
      % option en-ver not used
    \fi
    
  • LaTeX's \@ifpackagewith{<package name>}{<option list>}{<then>}{<else>}:

    \@ifpackagewith{cufestatletter}{en-ver}{%
      % option en-ver used
    }{%
      % option en-ver not used
    }
    
share|improve this answer
    
Hi, Heiko, It works. Thank you. –  Xiaoxiao Sun Dec 10 '12 at 0:26

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.