%%
%% This is file `PJLthm.sty',
%% generated with the docstrip utility.

%% Copyright (C) 2021 by Jinwen XU
%% 
%% This is part of the ProjLib Toolkit.
%% 
%% This work 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
%% 2005/12/01 or later.
%% 
\NeedsTeXFormat{LaTeX2e}[2020-10-01]
\ProvidesPackage{PJLthm}
    [2021/07/23 Theorem setup and configuration]
\RequirePackage{kvoptions}
\RequirePackage{etoolbox}
\SetupKeyvalOptions{%
    family = @PJLthm,
    prefix = @PJLthm@
}
\DeclareBoolOption[false]{nothms}
\DeclareBoolOption[false]{nothmnum}
\DeclareBoolOption[false]{draft}
\DeclareBoolOption[false]{fast}
\DeclareBoolOption[false]{regionalref}
\ProcessKeyvalOptions*\relax
\if@PJLthm@draft
    \@PJLthm@fasttrue
\fi
\if@PJLthm@fast
    \@PJLthm@regionalreftrue
\fi

\RequirePackage{PJLlang}
\RequirePackage{amsmath,amsthm}
\RequirePackage{aliascnt}
\PassOptionsToPackage{nameinlink}{cleveref}
\RequirePackage{cleveref}

\NewDocumentCommand{\NameTheorem}{omm}{%
    \protected@edef\PJLthm@temp{#2}%
    \expandafter\IfEndWith\expandafter{\PJLthm@temp}{*}{%
        \expandafter\StrGobbleRight\expandafter{\PJLthm@temp}{1}[\PJLthm@temp]%
    }{}%
    \IfValueTF{#1}{%
        \lowercase{\IfStrEqCase{#1}}{%
            {cn}{\def\PJL@temp@abbr{CN}}%
            {chinese}{\def\PJL@temp@abbr{CN}}%
            {schinese}{\def\PJL@temp@abbr{CN}}%
            {simplifiedchinese}{\def\PJL@temp@abbr{CN}}%
            {tc}{\def\PJL@temp@abbr{TC}}%
            {tchinese}{\def\PJL@temp@abbr{TC}}%
            {traditionalchinese}{\def\PJL@temp@abbr{TC}}%
            {jp}{\def\PJL@temp@abbr{JP}}%
            {japanese}{\def\PJL@temp@abbr{JP}}%
            {en}{\def\PJL@temp@abbr{EN}}%
            {english}{\def\PJL@temp@abbr{EN}}%
            {fr}{\def\PJL@temp@abbr{FR}}%
            {french}{\def\PJL@temp@abbr{FR}}%
            {de}{\def\PJL@temp@abbr{DE}}%
            {ngerman}{\def\PJL@temp@abbr{DE}}%
            {german}{\def\PJL@temp@abbr{DE}}%
            {it}{\def\PJL@temp@abbr{IT}}%
            {italian}{\def\PJL@temp@abbr{IT}}%
            {pt}{\def\PJL@temp@abbr{PT}}%
            {portuguese}{\def\PJL@temp@abbr{PT}}%
            {br}{\def\PJL@temp@abbr{BR}}%
            {brazilian}{\def\PJL@temp@abbr{BR}}%
            {es}{\def\PJL@temp@abbr{ES}}%
            {spanish}{\def\PJL@temp@abbr{ES}}%
            {ru}{\def\PJL@temp@abbr{RU}}%
            {russian}{\def\PJL@temp@abbr{RU}}%
        }%
        \expandafter\def\csname\PJLthm@temp name\PJL@temp@abbr\endcsname{#3}%
    }{%
        \expandafter\def\csname\PJLthm@temp nameEN\endcsname{#3}%
        \expandafter\def\csname\PJLthm@temp nameFR\endcsname{#3}%
        \expandafter\def\csname\PJLthm@temp nameDE\endcsname{#3}%
        \expandafter\def\csname\PJLthm@temp nameIT\endcsname{#3}%
        \expandafter\def\csname\PJLthm@temp namePT\endcsname{#3}%
        \expandafter\def\csname\PJLthm@temp nameBR\endcsname{#3}%
        \expandafter\def\csname\PJLthm@temp nameES\endcsname{#3}%
        \expandafter\def\csname\PJLthm@temp nameCN\endcsname{#3}%
        \expandafter\def\csname\PJLthm@temp nameTC\endcsname{#3}%
        \expandafter\def\csname\PJLthm@temp nameJP\endcsname{#3}%
        \expandafter\def\csname\PJLthm@temp nameRU\endcsname{#3}%
    }%
}

\RequirePackage{xstring}
\newcommand\PassFirstToSecond[2]{#2{#1}}%
\NewDocumentCommand{\CreateTheorem}{sm}{%
    \begingroup
    \protected@edef\PJLthm@temp{#2}%
    \expandafter\IfEndWith\expandafter{\PJLthm@temp}{*}{%
        \expandafter\StrGobbleRight\expandafter{\PJLthm@temp}{1}[\PJLthm@temp]%
        \PassFirstToSecond{*}%
    }{%
        \PassFirstToSecond{}%
    }%
    {\expandafter\PassFirstToSecond%
        \expandafter{\PJLthm@temp}{\endgroup\InnerCreateTheorem{#1}}}%
}%
\if@PJLthm@regionalref
\NewDocumentCommand{\InnerCreateTheorem}{mmmod<>d()}{%
    \IfBooleanTF{#1}{%
        \IfValueTF{#4}
            {\@firstoftwo}
            {\IfValueTF{#5}{\@firstoftwo}{\@secondoftwo}}%
    }{%
        \IfValueTF{#4}
            {\IfValueTF{#5}{\@firstoftwo}{\@secondoftwo}}{
            \@secondoftwo}
    }%
    {%
        \GenericError{}%
        {\string\CreateTheorem\space syntax error\on@line}{%
        You cannot call the starred variant with optional argument,\MessageBreak
        nor call the unstarred variant with several optional arguments.}%
        {}%
    }{%
        \IfValueTF{#6}{%
            \IfBooleanTF{#1}{%
                \ifcsmacro{#2#3}%
                {\renewenvironment{#2#3}{\begin{#6*}}{\end{#6*}}}%
                {\newenvironment{#2#3}{\begin{#6*}}{\end{#6*}}}%
            }{%
                \ifcsmacro{#2#3}%
                {\renewenvironment{#2#3}{\begin{#6}}{\end{#6}}}%
                {\newenvironment{#2#3}{\begin{#6}}{\end{#6}}}%
            }
        }{%
            \IfBooleanTF{#1}{%
                \newtheorem*{#2#3}{\csname#2name\csname\languagename ABBR\endcsname\endcsname}
            }{%
                \IfValueTF{#5}{%
                    \newtheorem{PJL#2#3}{\csname#2name\csname\languagename ABBR\endcsname\endcsname}[#5]%
                    \newaliascnt{#2#3}{PJL#2#3}%
                }{%
                    \IfValueTF{#4}{%
                            \newtheorem{PJL#2#3}[#4]{\csname#2name\csname\languagename ABBR\endcsname\endcsname}
                        }{%
                            \newtheorem{PJL#2#3}{\csname#2name\csname\languagename ABBR\endcsname\endcsname}
                            \newaliascnt{#2#3}{PJL#2#3}%
                        }%
                }%
                \crefname{PJL#2#3}%
                    {\csname#2name\csname\languagename ABBR\endcsname\endcsname}%
                    {\csname#2name\csname\languagename ABBR\endcsname\endcsname}%
                \Crefname{PJL#2#3}%
                    {\csname#2name\csname\languagename ABBR\endcsname\endcsname}%
                    {\csname#2name\csname\languagename ABBR\endcsname\endcsname}%
                \NewDocumentEnvironment{#2#3}{}
                    {\begin{PJL#2#3}}
                    {\end{PJL#2#3}}
            }%
        }%
    }%
}%
\else
\NewDocumentCommand{\InnerCreateTheorem}{mmmod<>d()}{%
    \IfBooleanTF{#1}{%
        \IfValueTF{#4}
            {\@firstoftwo}
            {\IfValueTF{#5}{\@firstoftwo}{\@secondoftwo}}%
    }{%
        \IfValueTF{#4}
            {\IfValueTF{#5}{\@firstoftwo}{\@secondoftwo}}{
            \@secondoftwo}
    }%
    {%
        \GenericError{}%
        {\string\CreateTheorem\space syntax error\on@line}{%
        You cannot call the starred variant with optional argument,\MessageBreak
        nor call the unstarred variant with several optional arguments.}%
        {%
            Allowed usage:\MessageBreak\MessageBreak
            \CreateTheorem*{(name of environment)}\MessageBreak
            \CreateTheorem{(name of environment)}\MessageBreak
            \CreateTheorem{(name of environment)}[(numbered like)]\MessageBreak
            \CreateTheorem{(name of environment)}<(numbered within)>\MessageBreak
            \CreateTheorem{(name of environment)}((existed environment))\MessageBreak
        }%
    }{%
        \IfValueTF{#6}{%
            \IfBooleanTF{#1}{%
                \ifcsmacro{#2#3}%
                {\renewenvironment{#2#3}{\begin{#6*}}{\end{#6*}}}%
                {\newenvironment{#2#3}{\begin{#6*}}{\end{#6*}}}%
            }{%
                \ifcsmacro{#2#3}%
                {\renewenvironment{#2#3}{\begin{#6}}{\end{#6}}}%
                {\newenvironment{#2#3}{\begin{#6}}{\end{#6}}}%
            }
        }{%
            \IfBooleanTF{#1}{%
                \if@PJLlang@enable@EN\expandafter\PassFirstToSecond\expandafter{\csname#2nameEN\endcsname}{\newtheorem*{#2EN#3}}\fi%
                \if@PJLlang@enable@FR\expandafter\PassFirstToSecond\expandafter{\csname#2nameFR\endcsname}{\newtheorem*{#2FR#3}}\fi%
                \if@PJLlang@enable@DE\expandafter\PassFirstToSecond\expandafter{\csname#2nameDE\endcsname}{\newtheorem*{#2DE#3}}\fi%
                \if@PJLlang@enable@IT\expandafter\PassFirstToSecond\expandafter{\csname#2nameIT\endcsname}{\newtheorem*{#2IT#3}}\fi%
                \if@PJLlang@enable@PT\expandafter\PassFirstToSecond\expandafter{\csname#2namePT\endcsname}{\newtheorem*{#2PT#3}}\fi%
                \if@PJLlang@enable@BR\expandafter\PassFirstToSecond\expandafter{\csname#2nameBR\endcsname}{\newtheorem*{#2BR#3}}\fi%
                \if@PJLlang@enable@ES\expandafter\PassFirstToSecond\expandafter{\csname#2nameES\endcsname}{\newtheorem*{#2ES#3}}\fi%
                \if@PJLlang@enable@CN\expandafter\PassFirstToSecond\expandafter{\csname#2nameCN\endcsname}{\newtheorem*{#2CN#3}}\fi%
                \if@PJLlang@enable@TC\expandafter\PassFirstToSecond\expandafter{\csname#2nameTC\endcsname}{\newtheorem*{#2TC#3}}\fi%
                \if@PJLlang@enable@JP\expandafter\PassFirstToSecond\expandafter{\csname#2nameJP\endcsname}{\newtheorem*{#2JP#3}}\fi%
                \if@PJLlang@enable@RU\expandafter\PassFirstToSecond\expandafter{\csname#2nameRU\endcsname}{\newtheorem*{#2RU#3}}\fi%
            }{%
                \IfValueTF{#5}{%
                    \newcounter{#2#3}[{#5}]%
                    \expandafter\renewcommand\expandafter*%
                        \csname the#2#3\expandafter\endcsname%
                        \expandafter{\csname the#5\endcsname.\arabic{#2#3}}%
                }{%
                    \IfValueTF{#4}
                        {\newaliascnt{#2#3}{#4}}
                        {\newcounter{#2#3}}%
                }%
                %---------------------------------------------------------------
                \if@PJLlang@enable@EN\CreateTheoremNumberedLikeAliasCounter{#2}{EN}{#3}\fi%
                \if@PJLlang@enable@FR\CreateTheoremNumberedLikeAliasCounter{#2}{FR}{#3}\fi%
                \if@PJLlang@enable@DE\CreateTheoremNumberedLikeAliasCounter{#2}{DE}{#3}\fi%
                \if@PJLlang@enable@IT\CreateTheoremNumberedLikeAliasCounter{#2}{IT}{#3}\fi%
                \if@PJLlang@enable@PT\CreateTheoremNumberedLikeAliasCounter{#2}{PT}{#3}\fi%
                \if@PJLlang@enable@BR\CreateTheoremNumberedLikeAliasCounter{#2}{BR}{#3}\fi%
                \if@PJLlang@enable@ES\CreateTheoremNumberedLikeAliasCounter{#2}{ES}{#3}\fi%
                \if@PJLlang@enable@CN\CreateTheoremNumberedLikeAliasCounter{#2}{CN}{#3}\fi%
                \if@PJLlang@enable@TC\CreateTheoremNumberedLikeAliasCounter{#2}{TC}{#3}\fi%
                \if@PJLlang@enable@JP\CreateTheoremNumberedLikeAliasCounter{#2}{JP}{#3}\fi%
                \if@PJLlang@enable@RU\CreateTheoremNumberedLikeAliasCounter{#2}{RU}{#3}\fi%
                %---------------------------------------------------------------
            }%
            \NewDocumentEnvironment{#2#3}{}
                {\csname#2\csname\languagename ABBR\endcsname#3\endcsname}%
                {\csname end#2\csname\languagename ABBR\endcsname#3\endcsname}%
        }%
    }%
}%
\NewDocumentCommand{\CreateTheoremNumberedLikeAliasCounter}{mmm}{%
    \newaliascnt{#1#2#3}{#1#3}%
    \expandafter\PassFirstToSecond\expandafter{\csname#1name#2\endcsname}{\newtheorem{#1#2#3}[{#1#2#3}]}%
    \aliascntresetthe{#1#2#3}%
    \expandafter\PassFirstToSecond\expandafter{\csname#1name#2\endcsname}%
    {%
        \expandafter\PassFirstToSecond\expandafter{\csname#1name#2\endcsname}%
        {\crefname{#1#2#3}}%
    }%
    \expandafter\PassFirstToSecond\expandafter{\csname#1name#2\endcsname}%
    {%
        \expandafter\PassFirstToSecond\expandafter{\csname#1name#2\endcsname}%
        {\Crefname{#1#2#3}}%
    }%
}%
\fi

\def\theoremnameEN{{Theorem}}
\def\lemmanameEN{{Lemma}}
\def\propositionnameEN{{Proposition}}
\def\corollarynameEN{{Corollary}}
\def\propertynameEN{{Property}}
\def\factnameEN{{Fact}}
\def\conjecturenameEN{{Conjecture}}
\def\definitionnameEN{{Definition}}
\def\axiomnameEN{{Axiom}}
\def\assumptionnameEN{{Assumption}}
\def\conventionnameEN{{Convention}}
\def\hypothesisnameEN{{Hypothesis}}
\def\notationnameEN{{Notation}}
\def\examplenameEN{{Example}}
\def\problemnameEN{{Problem}}
\def\questionnameEN{{Question}}
\def\exercisenameEN{{Exercise}}
\def\remarknameEN{{Remark}}
\def\observationnameEN{{Observation}}
\expandafter\def\csname definition-propositionnameEN\endcsname{\definitionnameEN-\propositionnameEN}
\expandafter\def\csname definition-theoremnameEN\endcsname{\definitionnameEN-\theoremnameEN}

\def\theoremnameFR{{Théorème}}
\def\lemmanameFR{{Lemme}}
\def\propositionnameFR{{Proposition}}
\def\corollarynameFR{{Corollaire}}
\def\propertynameFR{{Propriété}}
\def\factnameFR{{Fait}}
\def\conjecturenameFR{{Conjecture}}
\def\definitionnameFR{{Définition}}
\def\axiomnameFR{{Axiome}}
\def\assumptionnameFR{{Supposition}}
\def\conventionnameFR{{Convention}}
\def\hypothesisnameFR{{Hypothèse}}
\def\notationnameFR{{Notation}}
\def\examplenameFR{{Exemple}}
\def\problemnameFR{{Problème}}
\def\questionnameFR{{Question}}
\def\exercisenameFR{{Exercice}}
\def\remarknameFR{{Remarque}}
\def\observationnameFR{{Observation}}
\expandafter\def\csname definition-propositionnameFR\endcsname{\definitionnameFR-\propositionnameFR}
\expandafter\def\csname definition-theoremnameFR\endcsname{\definitionnameFR-\theoremnameFR}

\def\theoremnameDE{{Satz}}
\def\lemmanameDE{{Lemma}}
\def\propositionnameDE{{Proposition}}
\def\corollarynameDE{{Korollar}}
\def\propertynameDE{{Eigenschaft}}
\def\factnameDE{{Fakt}}
\def\conjecturenameDE{{Vermutung}}
\def\definitionnameDE{{Definition}}
\def\axiomnameDE{{Axiom}}
\def\assumptionnameDE{{Annahme}}
\def\conventionnameDE{{Konvention}}
\def\hypothesisnameDE{{Hypothese}}
\def\notationnameDE{{Notation}}
\def\examplenameDE{{Beispiel}}
\def\problemnameDE{{Problem}}
\def\questionnameDE{{Frage}}
\def\exercisenameDE{{Übung}}
\def\remarknameDE{{Bemerkung}}
\def\observationnameDE{{Beobachtung}}
\expandafter\def\csname definition-propositionnameDE\endcsname{\definitionnameDE-\propositionnameDE}
\expandafter\def\csname definition-theoremnameDE\endcsname{\definitionnameDE-\theoremnameDE}

\def\theoremnameIT{{Teorema}}
\def\lemmanameIT{{Lemma}}
\def\propositionnameIT{{Proposizione}}
\def\corollarynameIT{{Corollario}}
\def\propertynameIT{{Proprietà}}
\def\factnameIT{{Fatto}}
\def\conjecturenameIT{{Congettura}}
\def\definitionnameIT{{Definizione}}
\def\axiomnameIT{{Assioma}}
\def\assumptionnameIT{{Supposizione}}
\def\conventionnameIT{{Convenzione}}
\def\hypothesisnameIT{{Ipotesi}}
\def\notationnameIT{{Notazione}}
\def\examplenameIT{{Esempio}}
\def\problemnameIT{{Problema}}
\def\questionnameIT{{Domanda}}
\def\exercisenameIT{{Esercizio}}
\def\remarknameIT{{Nota}}
\def\observationnameIT{{Osservazione}}
\expandafter\def\csname definition-propositionnameIT\endcsname{\definitionnameIT-\propositionnameIT}
\expandafter\def\csname definition-theoremnameIT\endcsname{\definitionnameIT-\theoremnameIT}

\def\theoremnamePT{{Teorema}}
\def\lemmanamePT{{Lema}}
\def\propositionnamePT{{Proposição}}
\def\corollarynamePT{{Corolário}}
\def\propertynamePT{{Propriedade}}
\def\factnamePT{{Facto}}
\def\conjecturenamePT{{Conjetura}}
\def\definitionnamePT{{Definição}}
\def\axiomnamePT{{Axioma}}
\def\assumptionnamePT{{Suposição}}
\def\conventionnamePT{{Convenção}}
\def\hypothesisnamePT{{Hipótese}}
\def\notationnamePT{{Notação}}
\def\examplenamePT{{Exemplo}}
\def\problemnamePT{{Problema}}
\def\questionnamePT{{Pergunta}}
\def\exercisenamePT{{Exercício}}
\def\remarknamePT{{Comentário}}
\def\observationnamePT{{Observação}}
\expandafter\def\csname definition-propositionnamePT\endcsname{\definitionnamePT-\propositionnamePT}
\expandafter\def\csname definition-theoremnamePT\endcsname{\definitionnamePT-\theoremnamePT}

\def\theoremnameBR{{Teorema}}
\def\lemmanameBR{{Lema}}
\def\propositionnameBR{{Proposição}}
\def\corollarynameBR{{Corolário}}
\def\propertynameBR{{Propriedade}}
\def\factnameBR{{Facto}}
\def\conjecturenameBR{{Conjetura}}
\def\definitionnameBR{{Definição}}
\def\axiomnameBR{{Axioma}}
\def\assumptionnameBR{{Suposição}}
\def\conventionnameBR{{Convenção}}
\def\hypothesisnameBR{{Hipótese}}
\def\notationnameBR{{Notação}}
\def\examplenameBR{{Exemplo}}
\def\problemnameBR{{Problema}}
\def\questionnameBR{{Pergunta}}
\def\exercisenameBR{{Exercício}}
\def\remarknameBR{{Comentário}}
\def\observationnameBR{{Observação}}
\expandafter\def\csname definition-propositionnameBR\endcsname{\definitionnameBR-\propositionnameBR}
\expandafter\def\csname definition-theoremnameBR\endcsname{\definitionnameBR-\theoremnameBR}

\def\theoremnameES{{Teorema}}
\def\lemmanameES{{Lema}}
\def\propositionnameES{{Proposición}}
\def\corollarynameES{{Corolario}}
\def\propertynameES{{Propiedad}}
\def\factnameES{{Hecho}}
\def\conjecturenameES{{Conjetura}}
\def\definitionnameES{{Definición}}
\def\axiomnameES{{Axioma}}
\def\assumptionnameES{{Suposición}}
\def\conventionnameES{{Convención}}
\def\hypothesisnameES{{Hipótesis}}
\def\notationnameES{{Notación}}
\def\examplenameES{{Ejemplo}}
\def\problemnameES{{Problema}}
\def\questionnameES{{Pregunta}}
\def\exercisenameES{{Ejercicio}}
\def\remarknameES{{Comentario}}
\def\observationnameES{{Observación}}
\expandafter\def\csname definition-propositionnameES\endcsname{\definitionnameES-\propositionnameES}
\expandafter\def\csname definition-theoremnameES\endcsname{\definitionnameES-\theoremnameES}

\def\theoremnameCN{{定理}}
\def\lemmanameCN{{引理}}
\def\propositionnameCN{{命题}}
\def\corollarynameCN{{推论}}
\def\propertynameCN{{性质}}
\def\factnameCN{{事实}}
\def\conjecturenameCN{{猜想}}
\def\definitionnameCN{{定义}}
\def\axiomnameCN{{公理}}
\def\assumptionnameCN{{假设}}
\def\conventionnameCN{{约定}}
\def\hypothesisnameCN{{假设}}
\def\notationnameCN{{记号}}
\def\examplenameCN{{例}}
\def\problemnameCN{{问题}}
\def\questionnameCN{{问题}}
\def\exercisenameCN{{练习}}
\def\remarknameCN{{备注}}
\def\observationnameCN{{观察}}
\expandafter\def\csname definition-propositionnameCN\endcsname{\definitionnameCN-\propositionnameCN}
\expandafter\def\csname definition-theoremnameCN\endcsname{\definitionnameCN-\theoremnameCN}

\def\theoremnameTC{{定理}}
\def\lemmanameTC{{引理}}
\def\propositionnameTC{{命題}}
\def\corollarynameTC{{推論}}
\def\propertynameTC{{性質}}
\def\factnameTC{{事實}}
\def\conjecturenameTC{{猜想}}
\def\definitionnameTC{{定義}}
\def\axiomnameTC{{公理}}
\def\assumptionnameTC{{假設}}
\def\conventionnameTC{{約定}}
\def\hypothesisnameTC{{假設}}
\def\notationnameTC{{記號}}
\def\examplenameTC{{例}}
\def\problemnameTC{{問題}}
\def\questionnameTC{{問題}}
\def\exercisenameTC{{練習}}
\def\remarknameTC{{備註}}
\def\observationnameTC{{觀察}}
\expandafter\def\csname definition-propositionnameTC\endcsname{\definitionnameTC-\propositionnameTC}
\expandafter\def\csname definition-theoremnameTC\endcsname{\definitionnameTC-\theoremnameTC}

\def\theoremnameJP{{定理}}
\def\lemmanameJP{{補題}}
\def\propositionnameJP{{命題}}
\def\corollarynameJP{{系}}
\def\propertynameJP{{性質}}
\def\factnameJP{{事実}}
\def\conjecturenameJP{{予想}}
\def\definitionnameJP{{定義}}
\def\axiomnameJP{{公理}}
\def\assumptionnameJP{{仮定}}
\def\conventionnameJP{{慣例}}
\def\hypothesisnameJP{{仮設}}
\def\notationnameJP{{記法}}
\def\examplenameJP{{例}}
\def\problemnameJP{{問題}}
\def\questionnameJP{{問題}}
\def\exercisenameJP{{練習}}
\def\remarknameJP{{注釈}}
\def\observationnameJP{{観察}}
\expandafter\def\csname definition-propositionnameJP\endcsname{\definitionnameJP-\propositionnameJP}
\expandafter\def\csname definition-theoremnameJP\endcsname{\definitionnameJP-\theoremnameJP}

\def\theoremnameRU{{Теорема}} % Теоре́ма
\def\lemmanameRU{{Лемма}} % Ле́мма
\def\propositionnameRU{{Предложение}} % Предложе́ние
\def\corollarynameRU{{Следствие}} % Сле́дствие
\def\propertynameRU{{Имущество}} % Иму́щество
\def\factnameRU{{Факт}}
\def\conjecturenameRU{{Гипотеза}} % Гипо́теза
\def\definitionnameRU{{Определение}} % Определе́ние
\def\axiomnameRU{{Аксиома}} % Аксио́ма
\def\assumptionnameRU{{Предположение}} % Предположе́ние
\def\conventionnameRU{{Конвенция}} % Конве́нция
\def\hypothesisnameRU{{Гипотеза}} % Гипо́теза
\def\notationnameRU{{Нотация}} % Нота́ция
\def\examplenameRU{{Пример}} % Приме́р
\def\problemnameRU{{Проблема}} % Пробле́ма
\def\questionnameRU{{Вопрос}} % Вопро́с
\def\exercisenameRU{{Упражнение}} % Упражне́ние
\def\remarknameRU{{Замечание}} % Замеча́ние
\def\observationnameRU{{Наблюдение}} % Наблюде́ние
\expandafter\def\csname definition-propositionnameRU\endcsname{\definitionnameRU-\propositionnameRU}
\expandafter\def\csname definition-theoremnameRU\endcsname{\definitionnameRU-\theoremnameRU}

\newif\ifPJLthm@IsBook
\ifdefined\c@chapter\PJLthm@IsBooktrue\else\PJLthm@IsBookfalse\fi
\ifbool{PJLthm@IsBook}{
    \newaliascnt{PJLthm@highest}{chapter}
}{
    \newaliascnt{PJLthm@highest}{section}
}
\if@PJLthm@nothms\else
\if@PJLthm@nothmnum
\CreateTheorem*{theorem}
\CreateTheorem*{lemma}
\CreateTheorem*{proposition}
\CreateTheorem*{corollary}
\CreateTheorem*{definition-proposition}
\CreateTheorem*{definition-theorem}
\CreateTheorem*{property}
\CreateTheorem*{fact}
\CreateTheorem*{conjecture}
\else
\CreateTheorem{theorem}<PJLthm@highest>
\CreateTheorem{lemma}[theorem]
\CreateTheorem{proposition}[theorem]
\CreateTheorem{corollary}[theorem]
\CreateTheorem{definition-proposition}[theorem]
\CreateTheorem{definition-theorem}[theorem]
\CreateTheorem{property}[theorem]
\CreateTheorem{fact}[theorem]
\CreateTheorem{conjecture}[theorem]
\fi
\CreateTheorem*{theorem*}
\CreateTheorem*{lemma*}
\CreateTheorem*{proposition*}
\CreateTheorem*{corollary*}
\CreateTheorem*{definition-proposition*}
\CreateTheorem*{definition-theorem*}
\CreateTheorem*{property*}
\CreateTheorem*{fact*}
\CreateTheorem*{conjecture*}

\theoremstyle{definition}
\if@PJLthm@nothmnum
\CreateTheorem*{definition}
\CreateTheorem*{axiom}
\CreateTheorem*{assumption}
\CreateTheorem*{convention}
\CreateTheorem*{hypothesis}
\CreateTheorem*{notation}
\CreateTheorem*{example}
\CreateTheorem*{problem}
\CreateTheorem*{question}
\CreateTheorem*{exercise}
\else
\CreateTheorem{definition}[theorem]
\CreateTheorem{axiom}[theorem]
\CreateTheorem{assumption}[theorem]
\CreateTheorem{convention}[theorem]
\CreateTheorem{hypothesis}[theorem]
\CreateTheorem{notation}[theorem]
\CreateTheorem{example}[theorem]
\CreateTheorem{problem}[theorem]
\CreateTheorem{question}[theorem]
\CreateTheorem{exercise}[theorem]
\fi
\CreateTheorem*{definition*}
\CreateTheorem*{axiom*}
\CreateTheorem*{assumption*}
\CreateTheorem*{convention*}
\CreateTheorem*{hypothesis*}
\CreateTheorem*{notation*}
\CreateTheorem*{example*}
\CreateTheorem*{problem*}
\CreateTheorem*{question*}
\CreateTheorem*{exercise*}

\theoremstyle{remark}
\if@PJLthm@nothmnum
\CreateTheorem*{remark}
\CreateTheorem*{observation}
\else
\CreateTheorem{remark}<PJLthm@highest>
\CreateTheorem{observation}<PJLthm@highest>
\fi
\CreateTheorem*{remark*}
\CreateTheorem*{observation*}
\fi

\numberwithin{equation}{PJLthm@highest}

\gappto{\PJLlang@langconfig@chinese}{%
    \crefname{equation}{式}{式}%
    \crefname{figure}{图}{图}%
    \crefname{table}{表}{表}%
    \crefname{appendix}{附录}{附录}%
    \Crefname{equation}{式}{式}%
    \Crefname{figure}{图}{图}%
    \Crefname{table}{表}{表}%
    \Crefname{appendix}{附录}{附录}%
    \def\crefpairconjunction{、}%
    \def\crefmiddleconjunction{、}%
    \def\creflastconjunction{~和~}%
    \def\crefpairgroupconjunction{~和~}%
    \def\crefmiddlegroupconjunction{、}%
    \def\creflastgroupconjunction{~和~}%
    \def\crefrangeconjunction{～}%
}
\gappto{\PJLlang@langconfig@tchinese}{%
    \crefname{equation}{式}{式}%
    \crefname{figure}{圖}{圖}%
    \crefname{table}{表}{表}%
    \crefname{appendix}{附錄}{附錄}%
    \Crefname{equation}{式}{式}%
    \Crefname{figure}{圖}{圖}%
    \Crefname{table}{表}{表}%
    \Crefname{appendix}{附錄}{附錄}%
    \def\crefpairconjunction{、}%
    \def\crefmiddleconjunction{、}%
    \def\creflastconjunction{~與~}%
    \def\crefpairgroupconjunction{~與~}%
    \def\crefmiddlegroupconjunction{、}%
    \def\creflastgroupconjunction{~與~}%
    \def\crefrangeconjunction{～}%
}
\gappto{\PJLlang@langconfig@japanese}{%
    \crefname{equation}{式}{式}%
    \crefname{figure}{図}{図}%
    \crefname{table}{表}{表}%
    \Crefname{appendix}{付録}{付録}%
    \Crefname{equation}{式}{式}%
    \Crefname{figure}{図}{図}%
    \Crefname{table}{表}{表}%
    \Crefname{appendix}{付録}{付録}%
    \def\crefpairconjunction{~と~}%
    \def\crefmiddleconjunction{~と~}%
    \def\creflastconjunction{~と~}%
    \def\crefpairgroupconjunction{~と~}%
    \def\crefmiddlegroupconjunction{~と~}%
    \def\creflastgroupconjunction{~と~}%
    \def\crefrangeconjunction{〜}%
}
\gappto{\PJLlang@langconfig@russian}{%
    \crefname{equation}{уравнение}{уравнения}%
    \crefname{figure}{рис.}{рис.}%
    \crefname{table}{таблица}{таблицы}%
    \crefname{appendix}{приложение}{приложения}%
    \Crefname{equation}{Уравнение}{Уравнения}%
    \Crefname{figure}{Рис.}{Рис.}%
    \Crefname{table}{Таблица}{Таблицы}%
    \Crefname{appendix}{Приложение}{Приложения}%
    \def\crefpairconjunction{~и~}%
    \def\crefmiddleconjunction{,~}%
    \def\creflastconjunction{~и~}%
    \def\crefpairgroupconjunction{~и~}%
    \def\crefmiddlegroupconjunction{,~}%
    \def\creflastgroupconjunction{~и~}%
    \def\crefrangeconjunction{~\textasciitilde~}%
}
\gappto{\PJLlang@langconfig@portuguese}{%
    \crefname{equation}{eq.}{eqs.}%
    \crefname{figure}{fig.}{figs.}%
    \crefname{table}{tabela}{tabelas}%
    \crefname{appendix}{apêndice}{apêndices}%
    \Crefname{equation}{Eq.}{Eqs.}%
    \Crefname{figure}{Fig.}{Figs.}%
    \Crefname{table}{Tabela}{Tabelas}%
    \Crefname{appendix}{Apêndice}{Apêndices}%
    \def\crefpairconjunction{ e\nobreakspace}%
    \def\crefmiddleconjunction{, }%
    \def\creflastconjunction{ e\nobreakspace}%
    \def\crefpairgroupconjunction{ e\nobreakspace}%
    \def\crefmiddlegroupconjunction{, }%
    \def\creflastgroupconjunction{ e\nobreakspace}%
    \def\crefrangeconjunction{ a\nobreakspace}%
}

\endinput
%%
%% End of file `PJLthm.sty'.
