Is there a way to apply some options to a package which is loaded in the cls file I am using? For instance, suppose that the cls file loads graphicx, and I want to apply the option demo to it from my tex file.
Asked
Active
Viewed 2.1k times
65
bkarpuz
- 2,437
2 Answers
73
If a package is loaded, the option setting code in the package is already processed and gone. Thus in general you cannot change package options later.
\PassOptionsToPackage
But you can specify options earlier, before loading the package. Apart from a global option (with side effects for other packages) \PassOptionsToPackage can be even used before \documentclass, e.g.:
\PassOptionsToPackage{demo}{graphicx}
\documentclass{article}
\usepackage{graphicx}
\begin{document}
\includegraphics{foobar}
\end{document}
Package interface for loading options
Sometimes a package or class allows the setting of a subset of options later. For example, package hyperref provides \hypersetup.
Also some options of package graphicx (or rather for \includegraphics) can be set via:
\setkeys{Gin}{<options>}
However, the option demo is not supported this way.
Heiko Oberdiek
- 271,626
-
I guess there is no way of removing a package option that is set by the class (unless there is a package interface for loading options)? – Dec 13 '16 at 15:00
-
@jpmath In general no. – Heiko Oberdiek Dec 13 '16 at 17:30
23
Use
\PassOptionsToPackage{demo}{graphicx}
before the line with \documentclass
karlkoeller
- 124,410