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

[french]{babel} (aka frenchb) is incompatible with some other packages, such as tikz, since it tries to insert \thinspace before semi-colons.

In order to make these two play nice, you have to call \shorthandoff{;} in the document.

Now I have a package that uses tikz and I would like to locally disable the semi-colon for babel, instead of disabling it for the whole document. I could hack the .sty of the package to do that, knowing that I'm using frenchb, but I would rather make something clean and portable.

Is there a way in my package that I can test if frenchb is loaded and disable semi-colon management with babel locally, so the package doesn't have to be hacked?


Martin's solution gives me something like this in general:

  % code with semi-colon here

and in the specific case of tikz:

share|improve this question
Related (just for classes instead for packages): Which documentclass is being used?. – Martin Scharrer Apr 19 '11 at 21:13
Instead of \ifthenelse{\@babel@loaded=1}{\shorthandoff{;}}{} just define a macro which is normally empty or \relax but defined to \shorthandoff{;} when babel is loaded. See also my tikz specific solution. – Martin Scharrer Apr 19 '11 at 21:38
@Martin: Great, I updated my edit to reflect that. – ℝaphink Apr 19 '11 at 21:45
make sure to mind unwanted spaces, i.e. add % at the end of the line if required. Also {\relax} doesn't really make sense, {} is just fine. – Martin Scharrer Apr 19 '11 at 21:48
OK, thanks you. – ℝaphink Apr 19 '11 at 21:53
up vote 44 down vote accepted

You can use the internal LaTeX macro \@ifpackageloaded to test if a package was loaded:


There are also:

\@ifpackagelater{<name>}{<date YYYY/MM/DD>}{<true>}{<false>}

For further macro see the document linked in Documentation reference for LaTeX internal commands?.

In the case of tikz it would be best to add your code to the macros \tikz@installcommands and \tikz@uninstallcommands. The first is executed at the begin of a tikzpicture and enables all the tikz commands only defined there and the latter is executed at the begin of node content and changes the definitions back to there normal state. This way you can have French text inside the nodes.

You can add code to the macros using:


I'm just guessing here that \shorthandon is the opposite of \shorthandoff.

share|improve this answer
@Martin: \@ifclassloaded seems to be only usable in preamble. Is that right? – ℝaphink Apr 19 '11 at 21:20
@Raphink: Yes, they are marked as \@onlypreamble. You would need to test for the package in question at the end of the preamble, e.g. using \AtBeginDocument{...}, and set a global flag for your document macros. – Martin Scharrer Apr 19 '11 at 21:24
@Martin: Right. I would like to disable semi-colon management very locally, in a given macro. If I do a \AtBeginDocument, it will still affect the whole scope. – ℝaphink Apr 19 '11 at 21:25
@Raphink: Right, that's why I wrote "set a global flag for your document macros" not "change your settings". You then use that flag locally. – Martin Scharrer Apr 19 '11 at 21:30
@Martin: I edited the question to make an example with your proposal. Is that correct? – ℝaphink Apr 19 '11 at 21:33

Your Answer


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.