I'm working on a customised report class, aimed at technical documentation in our company. Among other bells and whistles, I'd like to use the "lmodern" package with the "lighttt" option preferably. The problem with this arises from the fact that we're using this class with the


not only under modern OS, like an Ubuntu 16.04, but also under SLES11sp2. The latter uses "lmodern 2007/01/14 v1.3", which doesn't have the "lighttt" option yet. So I get an error and the processing stops...

I also tried


but again, an error is reported.

What would be the canonical way in LaTeX to say "Please use the package lmodern with the lighttt option. But if it's not available, loading the bare lmodern package is fine."?

In pseudo code this could potentially look like:

  \usepackage[lighttt]{lmodern}}{% preferred
  \usepackage{lmodern}}% fallback

Google searches for "latex load package optionally" and "latex check whether package provides an option" didn't really bring up any useful results.

Some version numbers for the SLES11sp2 system:

pdfTeX, Version 3.141592-1.40.3 (Web2C 7.5.6)
LaTeX2e <2005/12/01>

And no, updating the system is not an option. ;) ...and wouldn't answer the actual question anyway.

  • Yes, I know...but I don't want to error out. I want the document to be processed successfully, but with a restricted set of options or none at all. I want to provide kind of a "fallback" mechanism, such that the document can still get rendered successfully. It's okay if parts of the text look different then. – dirkbaechle Aug 25 '17 at 11:54
  • I'm not sure why you're using such an old system, and can't even update the packages, but I think we can take that as a fact. I wonder if we could test for the package version without loading it. – Chris H Aug 25 '17 at 11:57
  • Potentially related: tex.stackexchange.com/questions/13304/… – Chris H Aug 25 '17 at 11:59
  • @campa I retagged the question based on your suggestion. – dirkbaechle Aug 25 '17 at 12:23
  • You could add the option to the \@classoptionslist see tex.stackexchange.com/questions/147243/… – Ulrike Fischer Aug 25 '17 at 12:49

I only see the solution to check texliveversion and load the packages

An example:

\def\gettexliveversion#1(#2 #3 #4#5#6#7#8)#9\relax{#4#5#6#7}

\ifnum\texliveversion >2010


text  \color{Red} sfgsd


If you know the texlive version probably you know if the option you are "passing" is valid...

The code can be changed to read month and day too...

But you have to know which version of package is used in texlive versions.

Source: Getting Texlive version in pdflatex?

|improve this answer|||||

Following the advice by @UlrikeFischer this is the solution that I came up with and that I'm using successfully at the moment:

% Adding the lighttt option to the global list of class options
% Now we can pull in the lmodern package, it will skip the `lighttt` option if
% it is unknown...
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.