[OS X TeX] Test whether an option has loaded

David Craig dac at panix.com
Fri Mar 2 18:45:28 CET 2012

On Mar 2, 2012, at 9:47 AM, Chris Goedde wrote:

> On Mar 2, 2012, at 1:27 AM, David Craig wrote:
>> This actually works whether or not I include the backslash.    What function does it serve?
> Are you sure you can actually fall through both branches using @classoptionslist and not \@classoptionslist? I don't see that (using my version); it only ever falls through the non-preprint case. Of course it 'works' in the sense that there's no error.
> I'm pretty sure that \@classoptionslist is a command, so the backslash is necessary. Otherwise you're just searching the string '@classoptionslist' for the string 'preprint', and that always fails. At least, if I google '@classoptionslist', all the examples I find are using it as a command, with the backslash.

Well ... I was quite sure when I wrote that email.  Oops [:-)]  However, now I agree that it does not work without the backslash -- which is comforting, because that makes sense to me within the context of LaTeX.   

The stackexchange post from which I learned about the existence of \@classoptionslist is in fact missing the leading backslash early in the post.   On another reading I see it re-appears further down the post, which I had not noticed.  So there were several reasons my initial attempts were not working.

To summarize this thread, appended is a minimal working example using both the method I tried originally, and Chris' suggestion using versions.   Thanks very much for the guidance!   This is new territory for me insofar as LaTeX is concerned, and it's going to be very useful.

David Craig


%% Minimal working example of alternative structures for executing 
%% different code depending on which class options are set
%% CAVEAT EMPTOR: Some packages deliberately alter the value of
%% \@classoptionslist!



% Solution using versions package:
% Solution using switch:
\newcommand{\pp}{1} % Defaults to preprint code option if something goes wrong


This is the solution using the ``versions'' package:

This is the preprint version text.

This is the final version text.


This is the version using a switch:

Print this if \textbackslash{pp}=1; the value of \textbackslash{pp} is \pp.
Print this if \textbackslash{pp}=0; the value of \textbackslash{pp} is \pp.
} %


More information about the macostex-archives mailing list