TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know that there are lots of similar question, but none of those have helped me so far - and I did google a lot. So my question is: I have a document class (emulateapj) which accepts a few options.

In my document, I want to have a conditional test which checks if some option (for example onecolumn) is set, and if so, to do a few things like changing font size or line separation.

Something like

\IfSubStr{@classoptionslist}{onecolumn}{true}{false}%

Just gives me always false.

share|improve this question
2  
Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. It will be much easier for us to reproduce your situation and find out what the issue is when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – Marco Daniel Apr 23 '13 at 16:35
    
Is the option defined as a bool? – Marco Daniel Apr 23 '13 at 16:36

The kernel provides \@ifclasswith:

\documentclass[onecolumn]{emulateapj}

\makeatletter
\@ifclasswith{emulateapj}{onecolumn}{\typeout{ONECOLUMN}}{\typeout{NO ONECOLUMN}}
\@ifclasswith{emulateapj}{revtex4}{\typeout{REVTEX4}}{\typeout{NO REVTEX4}}

\makeatother

The output on the terminal is

ONECOLUMN
NO REVTEX4

The \@ifclasswith command is only available before \begin{document}, so if you want to set up your own conditional you have to do it in the preamble:

\makeatletter
\newif\ifhbonecolumn
\@ifclasswith{emulateapj}{onecolumn}{\hbonecolumntrue}{\hbonecolumnfalse}
\makeatother

\newcommand{\foo}{\ifhbonecolumn fooone\else footwo\fi}
share|improve this answer
    
This is only one option if you use no keyval package. – Marco Daniel Apr 23 '13 at 18:10
    
Thanks a lot, that did the trick! – honeybee Apr 23 '13 at 18:45
    
Great suggestion,\@ifclasswith. clsguide doesn't say anything about it, where is it mentioned? – Arch Stanton Jan 12 at 14:10
    
@ArchStanton In source2e.pdf – egreg Jan 12 at 15:06
    
Thank you egreg! – Arch Stanton Jan 12 at 15:46

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.