Many packages come with switches, to be defined in the preamble. Is it possible to hit such a switch also in the body of the document?

Example: Can I switch from the functionality of


to that of


within one section or figure caption?

Edit: babel is just one example for which I have a good idea about what the switches actually do, but the question is meant to be more general. By the way, is there a generic name for these switches that could be used, e.g., to search the documentation of a package? Or a term for cases when both options can be used in parallel (like in babel) or not?

3 Answers 3


babel is perhaps not the best example, because you could state both options and switch by \selectlanguage:


Many packages provide their own way to change options aka switches: hyperref uses \hypersetup, caption uses \captionsetup, even classes offer such late configuration like KOMA-Script classes by \KOMAoption and \KOMAoptions.

  • With hindsight, I agree that babel was not the best example - it is just one of the packages that I am a bit familiar with, which helped in phrasing the question (which I have edited by now to reflect its more general nature). Special thanks for pointing out that classes do it too! Aug 5, 2010 at 22:23

If you specifically mean babel, then you load the package with both languages


then switch with \selectlanguage{russian} (In the example, french will be the main language.) See the babel documentation for more detail.

(Other packages with load time options also provide methods to alter settings, but this is package-dependent.)

  • I had hoped (dreamed?) there were a package-independent function but thanks for putting me back into reality. I am not specifically after babel and have clarified this in my question. Aug 5, 2010 at 22:16
  • 1
    Nope- it usually requires the package author to provide a command like \pkgnamesetup{key=value} that will toggle the options. Most do, some dont, and everyone needs to use a different name to avoid clashes.
    – Sharpie
    Aug 5, 2010 at 22:50
  • 1
    It all depends what the load-time options do. Some simply set 'dynamic' values, and can therefore be altered during the run. Others make once-only changes to behaviour. For example, if you have stuff that needs to happen in the preamble then the option would not make sense in the document body.
    – Joseph Wright
    Aug 6, 2010 at 5:43

For Babel, you have the command \selectlanguage that does exactly that. Obviously, you need such a thing to switch language inside a document body, because it wouldn't make sense to select all the languages at the same time! As you probably know, the convention in Babel is that the last language in the list of option is activated at \begin{document}; hence a command like \usepackage[french,russian]{babel} will declare the document to be in Russian by default, and use the settings of russian.ldf.

Generally speaking, any package you use should provide such switches because that's exactly what you need, as a user. If the functionality of the package implies that you can switch between different options, the developer has probably foreseen such use, and it should be mentioned in the documentation.

But you can't load a package mid-document (\usepackage forbids that). This is a technical limitation that has its justification from the point of view of an interface designer. It is a guarantee to both the user and the developer: if someone writes a package for LaTeX, he knows that it will be loaded before \begin{document}, and hence before any text will be output to the page; this means he will be able to make implementation choices depending on this (that might fail if this condition wasn't true). If you were, as a user, to modify \usepackage's behaviour so that it could be invoked after the preamble—it shouldn't be too hard, by tweaking the LaTeX sources—, and you used that new possibility, you could unknowingly be in a situation that hasn't been foreseen at all by the developer, because it's impossible given the way LaTeX is currently written (and this is a design choice, not a technical problem). Hence you, the user, depend on the user interface the package developer has programmed for you; just like the package developer depends on the programming interface the LaTeX core provides.

Of course, loading a package mid-document (with or without different switches) could be completely harmless in many cases, but this is not something you can rely on; the only guarantee the user has are the switches the package developer has provided himself.

Sorry I can't think of any concrete example right now.

  • Thank you too. Yes, noticing that the last language is used in babel was easy. But I was after a package-independent approach and have clarified that in the question. Aug 5, 2010 at 22:20
  • I've seen your edit, and edited my answer accordingly. Aug 5, 2010 at 23:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .