summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/chemformula-ru/chemformula-ru.sty
blob: f1df3002c11c86ee78e215e5a4e4097efb396728 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
%%  The chemformula-ru package eliminates an incompatibility 
%%  between the chemformula package and Russian settings (russian.ldf) of the babel package.
%%
%%  Copyright (c) 2024 by Alexey Kuznetsov (mailtokuznetsov at gmail.com)
%%
%%  This file may be distributed and/or modified under the
%%  conditions of the LaTeX Project Public License, either version 1.3c
%%  of this license or (at your option) any later version.
%%  The latest version of this license is in
%%     http://www.latex-project.org/lppl.txt
%%  and version 1.3c or later is part of all distributions of LaTeX
%%  version 2008/05/04 or later.
%%

\ProvidesPackage{chemformula-ru}[2024-03-01 Using chemformula package with babel-russian]

\DeclareOption{cosh2ch}{\def\cosh@ch{\DeclareRobustCommand\cosh{\mathop{\operator@font ch}\nolimits}}}
\DeclareOption{ch2Ch}{\def\ch@Ch{\DeclareRobustCommand\Ch{\mathop{\operator@font ch}\nolimits}}}
\ProcessOptions\relax

\BeforeBeginEnvironment{document}{
	\IfPackageLoadedTF{chemformula}{ 
		\IfPackageLoadedWithOptionsTF{babel}{russian}{
			\let\@Chem@Formula\ch \let\ch\undefined
			\AtBeginDocument{ \let\ch\@Chem@Formula 
				\@ifundefined{cosh@ch}{\relax}{\cosh@ch}
				\@ifundefined{ch@Ch}{\relax}{\ch@Ch}
			} 
		} { \relax } 
	} { \relax }
}
\endinput