[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?
Edit:
Martin's solution gives me something like this in general:
\RequirePackage{ifthen}
\newcommand{\@babel@loaded}{0}
\AtBeginDocument{\@ifpackageloaded{babel}
{\renewcommand{\@babel@loaded}{1}}
{\renewcommand{\@babel@loaded}{0}}
}
\newcommand{\somecommandusingsemicolon}{
\ifthenelse{\@babel@loaded=1}{\shorthandoff{;}}{}
% code with semi-colon here
}
and in the specific case of tikz:
\AtBeginDocument{\@ifpackageloaded{babel}
{%
\g@addto@macro\tikz@installcommands{%
\shorthandoff{;}%
}
\g@addto@macro\tikz@uninstallcommands{%
\shorthandon{;}%
}
}
{\relax}
}


\ifthenelse{\@babel@loaded=1}{\shorthandoff{;}}{}just define a macro which is normally empty or\relaxbut defined to\shorthandoff{;}whenbabelis loaded. See also mytikzspecific solution. – Martin Scharrer Apr 19 '11 at 21:38%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\ltx@ifpackageloaded, refer to conditionals - How to implement a command that checks for loaded packages? - TeX - LaTeX Stack Exchange for details. – user202729 May 10 '23 at 02:58