%% katibmath.sty — Arabic mathematical notation for XeLaTeX and LuaLaTeX
%% Generated by scripts/build-ctan-package.ts from the symbol registry of
%% الكاتب العلمي (Scientific Writer). Do not edit by hand.
%%
%% Copyright (C) 2026 Muhammad Nabeel Shaesha
%%
%% 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
%%   https://www.latex-project.org/lppl.txt
%% This work has the LPPL maintenance status "maintained".
%% The font KatibMath-Regular.otf is under the SIL Open Font License 1.1.
\NeedsTeXFormat{LaTeX2e}[2020/10/01]
\ProvidesPackage{katibmath}[2026/11/14 v0.1.0 Arabic mathematical notation]

\RequirePackage{iftex}
\RequireTUTeX

%% Options
%%   mathfont   (default) use Katib Math as the math font (\setmathfont)
%%   nomathfont keep the document's math font; Arabic symbols still use Katib Math
\newif\ifkatib@mathfont \katib@mathfonttrue
\DeclareOption{mathfont}{\katib@mathfonttrue}
\DeclareOption{nomathfont}{\katib@mathfontfalse}
\ProcessOptions\relax

\RequirePackage{amsmath}
\RequirePackage{graphicx}
\RequirePackage{fontspec}
\RequirePackage{unicode-math}

\ifkatib@mathfont
  \setmathfont{KatibMath-Regular.otf}
\fi

%% \katibglyphs: Katib Math as a text font, for the Arabic Mathematical
%% Alphabetic Symbols (U+1EE00–1EEFF) and the Arabic math signs, which
%% unicode-math does not map into math mode.
\newfontfamily\katibglyphs{KatibMath-Regular.otf}

%% \katibarabic: Katib Math's Arabic (from Amiri), shaped, for Arabic words
%% in formulas (جا، نها، لـو …).
\newfontfamily\katibarabic{KatibMath-Regular.otf}[Script=Arabic,BoldFeatures={FakeBold=2.5}]

%% \katibmirror{x}: x flipped horizontally, keeping the current math style,
%% so mirrored big operators stay large and keep their limits.
\newcommand{\katibmirror}[1]{\mathpalette\katib@mirror{#1}}
\newcommand{\katib@mirror}[2]{\reflectbox{$\m@th#1#2$}}

%% Arabic text inside math. polyglossia and babel define \textarabic; without
%% them, katibmath supplies one that sets the text right to left in Katib Math.
%% It also works in math mode (it switches to text with amsmath's \text).
\newcommand{\katib@textarabic}[1]{%
  \ifLuaTeX
    {\katibarabic\textdir TRT #1}%
  \else
    {\TeXXeTstate=1 \katibarabic\beginR #1\endR}%
  \fi}
\AtBeginDocument{%
  \providecommand{\textarabic}[1]{%
    \ifmmode\text{\katib@textarabic{#1}}\else\katib@textarabic{#1}\fi}%
}

%% ── Symbols (190) ──
\DeclareRobustCommand{\jaa}{\operatorname{\text{\textarabic{جا}}}}
\DeclareRobustCommand{\jataa}{\operatorname{\text{\textarabic{جتا}}}}
\DeclareRobustCommand{\dhaa}{\operatorname{\text{\textarabic{ظا}}}}
\DeclareRobustCommand{\dhataa}{\operatorname{\text{\textarabic{ظتا}}}}
\DeclareRobustCommand{\qaa}{\operatorname{\text{\textarabic{قا}}}}
\DeclareRobustCommand{\qataa}{\operatorname{\text{\textarabic{قتا}}}}
\DeclareRobustCommand{\jaainv}{\operatorname{\text{\textarabic{جا}}}^{-1}}
\DeclareRobustCommand{\jataainv}{\operatorname{\text{\textarabic{جتا}}}^{-1}}
\DeclareRobustCommand{\dhaainv}{\operatorname{\text{\textarabic{ظا}}}^{-1}}
\DeclareRobustCommand{\jaaz}{\operatorname{\text{\textarabic{جاز}}}}
\DeclareRobustCommand{\jataaz}{\operatorname{\text{\textarabic{جتاز}}}}
\DeclareRobustCommand{\dhaaz}{\operatorname{\text{\textarabic{ظاز}}}}
\DeclareRobustCommand{\lugh}{\operatorname{\text{\textarabic{لو}}}}
\DeclareRobustCommand{\lugt}{\operatorname{\text{\textarabic{لط}}}}
\DeclareRobustCommand{\nihaya}{\operatorname*{\text{\textarabic{نها}}}}
\DeclareRobustCommand{\majmu}{\operatorname*{\text{\textarabic{مجـ}}}}
\DeclareRobustCommand{\arAlef}{\mathord{\text{\katibglyphs 𞸀}}}
\DeclareRobustCommand{\arBeh}{\mathord{\text{\katibglyphs 𞸁}}}
\DeclareRobustCommand{\arJeem}{\mathord{\text{\katibglyphs 𞸂}}}
\DeclareRobustCommand{\arDal}{\mathord{\text{\katibglyphs 𞸃}}}
\DeclareRobustCommand{\arWaw}{\mathord{\text{\katibglyphs 𞸅}}}
\DeclareRobustCommand{\arZain}{\mathord{\text{\katibglyphs 𞸆}}}
\DeclareRobustCommand{\arHah}{\mathord{\text{\katibglyphs 𞸇}}}
\DeclareRobustCommand{\arTah}{\mathord{\text{\katibglyphs 𞸈}}}
\DeclareRobustCommand{\arYeh}{\mathord{\text{\katibglyphs 𞸉}}}
\DeclareRobustCommand{\arKaf}{\mathord{\text{\katibglyphs 𞸊}}}
\DeclareRobustCommand{\arLam}{\mathord{\text{\katibglyphs 𞸋}}}
\DeclareRobustCommand{\arMeem}{\mathord{\text{\katibglyphs 𞸌}}}
\DeclareRobustCommand{\arNoon}{\mathord{\text{\katibglyphs 𞸍}}}
\DeclareRobustCommand{\arSeen}{\mathord{\text{\katibglyphs 𞸎}}}
\DeclareRobustCommand{\arAin}{\mathord{\text{\katibglyphs 𞸏}}}
\DeclareRobustCommand{\arFeh}{\mathord{\text{\katibglyphs 𞸐}}}
\DeclareRobustCommand{\arSad}{\mathord{\text{\katibglyphs 𞸑}}}
\DeclareRobustCommand{\arQaf}{\mathord{\text{\katibglyphs 𞸒}}}
\DeclareRobustCommand{\arReh}{\mathord{\text{\katibglyphs 𞸓}}}
\DeclareRobustCommand{\arSheen}{\mathord{\text{\katibglyphs 𞸔}}}
\DeclareRobustCommand{\arTeh}{\mathord{\text{\katibglyphs 𞸕}}}
\DeclareRobustCommand{\arTheh}{\mathord{\text{\katibglyphs 𞸖}}}
\DeclareRobustCommand{\arKhah}{\mathord{\text{\katibglyphs 𞸗}}}
\DeclareRobustCommand{\arThal}{\mathord{\text{\katibglyphs 𞸘}}}
\DeclareRobustCommand{\arDad}{\mathord{\text{\katibglyphs 𞸙}}}
\DeclareRobustCommand{\arZah}{\mathord{\text{\katibglyphs 𞸚}}}
\DeclareRobustCommand{\arGhain}{\mathord{\text{\katibglyphs 𞸛}}}
\DeclareRobustCommand{\arDotlessBeh}{\mathord{\text{\katibglyphs 𞸜}}}
\DeclareRobustCommand{\arDotlessNoon}{\mathord{\text{\katibglyphs 𞸝}}}
\DeclareRobustCommand{\arDotlessFeh}{\mathord{\text{\katibglyphs 𞸞}}}
\DeclareRobustCommand{\arDotlessQaf}{\mathord{\text{\katibglyphs 𞸟}}}
\DeclareRobustCommand{\arInitBeh}{\mathord{\text{\katibglyphs 𞸡}}}
\DeclareRobustCommand{\arInitJeem}{\mathord{\text{\katibglyphs 𞸢}}}
\DeclareRobustCommand{\arInitHeh}{\mathord{\text{\katibglyphs 𞸤}}}
\DeclareRobustCommand{\arInitHah}{\mathord{\text{\katibglyphs 𞸧}}}
\DeclareRobustCommand{\arInitYeh}{\mathord{\text{\katibglyphs 𞸩}}}
\DeclareRobustCommand{\arInitKaf}{\mathord{\text{\katibglyphs 𞸪}}}
\DeclareRobustCommand{\arInitLam}{\mathord{\text{\katibglyphs 𞸫}}}
\DeclareRobustCommand{\arInitMeem}{\mathord{\text{\katibglyphs 𞸬}}}
\DeclareRobustCommand{\arInitNoon}{\mathord{\text{\katibglyphs 𞸭}}}
\DeclareRobustCommand{\arInitSeen}{\mathord{\text{\katibglyphs 𞸮}}}
\DeclareRobustCommand{\arInitAin}{\mathord{\text{\katibglyphs 𞸯}}}
\DeclareRobustCommand{\arInitFeh}{\mathord{\text{\katibglyphs 𞸰}}}
\DeclareRobustCommand{\arInitSad}{\mathord{\text{\katibglyphs 𞸱}}}
\DeclareRobustCommand{\arInitQaf}{\mathord{\text{\katibglyphs 𞸲}}}
\DeclareRobustCommand{\arInitSheen}{\mathord{\text{\katibglyphs 𞸴}}}
\DeclareRobustCommand{\arInitTeh}{\mathord{\text{\katibglyphs 𞸵}}}
\DeclareRobustCommand{\arInitTheh}{\mathord{\text{\katibglyphs 𞸶}}}
\DeclareRobustCommand{\arInitKhah}{\mathord{\text{\katibglyphs 𞸷}}}
\DeclareRobustCommand{\arInitDad}{\mathord{\text{\katibglyphs 𞸹}}}
\DeclareRobustCommand{\arInitGhain}{\mathord{\text{\katibglyphs 𞸻}}}
\DeclareRobustCommand{\arTailJeem}{\mathord{\text{\katibglyphs 𞹂}}}
\DeclareRobustCommand{\arTailHah}{\mathord{\text{\katibglyphs 𞹇}}}
\DeclareRobustCommand{\arTailYeh}{\mathord{\text{\katibglyphs 𞹉}}}
\DeclareRobustCommand{\arTailLam}{\mathord{\text{\katibglyphs 𞹋}}}
\DeclareRobustCommand{\arTailNoon}{\mathord{\text{\katibglyphs 𞹍}}}
\DeclareRobustCommand{\arTailSeen}{\mathord{\text{\katibglyphs 𞹎}}}
\DeclareRobustCommand{\arTailAin}{\mathord{\text{\katibglyphs 𞹏}}}
\DeclareRobustCommand{\arTailSad}{\mathord{\text{\katibglyphs 𞹑}}}
\DeclareRobustCommand{\arTailQaf}{\mathord{\text{\katibglyphs 𞹒}}}
\DeclareRobustCommand{\arTailSheen}{\mathord{\text{\katibglyphs 𞹔}}}
\DeclareRobustCommand{\arTailKhah}{\mathord{\text{\katibglyphs 𞹗}}}
\DeclareRobustCommand{\arTailDad}{\mathord{\text{\katibglyphs 𞹙}}}
\DeclareRobustCommand{\arTailGhain}{\mathord{\text{\katibglyphs 𞹛}}}
\DeclareRobustCommand{\arTailDotlessNoon}{\mathord{\text{\katibglyphs 𞹝}}}
\DeclareRobustCommand{\arTailDotlessQaf}{\mathord{\text{\katibglyphs 𞹟}}}
\DeclareRobustCommand{\arStretchBeh}{\mathord{\text{\katibglyphs 𞹡}}}
\DeclareRobustCommand{\arStretchJeem}{\mathord{\text{\katibglyphs 𞹢}}}
\DeclareRobustCommand{\arStretchHeh}{\mathord{\text{\katibglyphs 𞹤}}}
\DeclareRobustCommand{\arStretchHah}{\mathord{\text{\katibglyphs 𞹧}}}
\DeclareRobustCommand{\arStretchTah}{\mathord{\text{\katibglyphs 𞹨}}}
\DeclareRobustCommand{\arStretchYeh}{\mathord{\text{\katibglyphs 𞹩}}}
\DeclareRobustCommand{\arStretchKaf}{\mathord{\text{\katibglyphs 𞹪}}}
\DeclareRobustCommand{\arStretchMeem}{\mathord{\text{\katibglyphs 𞹬}}}
\DeclareRobustCommand{\arStretchNoon}{\mathord{\text{\katibglyphs 𞹭}}}
\DeclareRobustCommand{\arStretchSeen}{\mathord{\text{\katibglyphs 𞹮}}}
\DeclareRobustCommand{\arStretchAin}{\mathord{\text{\katibglyphs 𞹯}}}
\DeclareRobustCommand{\arStretchFeh}{\mathord{\text{\katibglyphs 𞹰}}}
\DeclareRobustCommand{\arStretchSad}{\mathord{\text{\katibglyphs 𞹱}}}
\DeclareRobustCommand{\arStretchQaf}{\mathord{\text{\katibglyphs 𞹲}}}
\DeclareRobustCommand{\arStretchSheen}{\mathord{\text{\katibglyphs 𞹴}}}
\DeclareRobustCommand{\arStretchTeh}{\mathord{\text{\katibglyphs 𞹵}}}
\DeclareRobustCommand{\arStretchTheh}{\mathord{\text{\katibglyphs 𞹶}}}
\DeclareRobustCommand{\arStretchKhah}{\mathord{\text{\katibglyphs 𞹷}}}
\DeclareRobustCommand{\arStretchDad}{\mathord{\text{\katibglyphs 𞹹}}}
\DeclareRobustCommand{\arStretchZah}{\mathord{\text{\katibglyphs 𞹺}}}
\DeclareRobustCommand{\arStretchGhain}{\mathord{\text{\katibglyphs 𞹻}}}
\DeclareRobustCommand{\arStretchDotlessBeh}{\mathord{\text{\katibglyphs 𞹼}}}
\DeclareRobustCommand{\arStretchDotlessFeh}{\mathord{\text{\katibglyphs 𞹾}}}
\DeclareRobustCommand{\arLoopAlef}{\mathord{\text{\katibglyphs 𞺀}}}
\DeclareRobustCommand{\arLoopBeh}{\mathord{\text{\katibglyphs 𞺁}}}
\DeclareRobustCommand{\arLoopJeem}{\mathord{\text{\katibglyphs 𞺂}}}
\DeclareRobustCommand{\arLoopDal}{\mathord{\text{\katibglyphs 𞺃}}}
\DeclareRobustCommand{\arLoopHeh}{\mathord{\text{\katibglyphs 𞺄}}}
\DeclareRobustCommand{\arLoopWaw}{\mathord{\text{\katibglyphs 𞺅}}}
\DeclareRobustCommand{\arLoopZain}{\mathord{\text{\katibglyphs 𞺆}}}
\DeclareRobustCommand{\arLoopHah}{\mathord{\text{\katibglyphs 𞺇}}}
\DeclareRobustCommand{\arLoopTah}{\mathord{\text{\katibglyphs 𞺈}}}
\DeclareRobustCommand{\arLoopYeh}{\mathord{\text{\katibglyphs 𞺉}}}
\DeclareRobustCommand{\arLoopLam}{\mathord{\text{\katibglyphs 𞺋}}}
\DeclareRobustCommand{\arLoopMeem}{\mathord{\text{\katibglyphs 𞺌}}}
\DeclareRobustCommand{\arLoopNoon}{\mathord{\text{\katibglyphs 𞺍}}}
\DeclareRobustCommand{\arLoopSeen}{\mathord{\text{\katibglyphs 𞺎}}}
\DeclareRobustCommand{\arLoopAin}{\mathord{\text{\katibglyphs 𞺏}}}
\DeclareRobustCommand{\arLoopFeh}{\mathord{\text{\katibglyphs 𞺐}}}
\DeclareRobustCommand{\arLoopSad}{\mathord{\text{\katibglyphs 𞺑}}}
\DeclareRobustCommand{\arLoopQaf}{\mathord{\text{\katibglyphs 𞺒}}}
\DeclareRobustCommand{\arLoopReh}{\mathord{\text{\katibglyphs 𞺓}}}
\DeclareRobustCommand{\arLoopSheen}{\mathord{\text{\katibglyphs 𞺔}}}
\DeclareRobustCommand{\arLoopTeh}{\mathord{\text{\katibglyphs 𞺕}}}
\DeclareRobustCommand{\arLoopTheh}{\mathord{\text{\katibglyphs 𞺖}}}
\DeclareRobustCommand{\arLoopKhah}{\mathord{\text{\katibglyphs 𞺗}}}
\DeclareRobustCommand{\arLoopThal}{\mathord{\text{\katibglyphs 𞺘}}}
\DeclareRobustCommand{\arLoopDad}{\mathord{\text{\katibglyphs 𞺙}}}
\DeclareRobustCommand{\arLoopZah}{\mathord{\text{\katibglyphs 𞺚}}}
\DeclareRobustCommand{\arLoopGhain}{\mathord{\text{\katibglyphs 𞺛}}}
\DeclareRobustCommand{\arDsBeh}{\mathord{\text{\katibglyphs 𞺡}}}
\DeclareRobustCommand{\arDsJeem}{\mathord{\text{\katibglyphs 𞺢}}}
\DeclareRobustCommand{\arDsDal}{\mathord{\text{\katibglyphs 𞺣}}}
\DeclareRobustCommand{\arDsWaw}{\mathord{\text{\katibglyphs 𞺥}}}
\DeclareRobustCommand{\arDsZain}{\mathord{\text{\katibglyphs 𞺦}}}
\DeclareRobustCommand{\arDsHah}{\mathord{\text{\katibglyphs 𞺧}}}
\DeclareRobustCommand{\arDsTah}{\mathord{\text{\katibglyphs 𞺨}}}
\DeclareRobustCommand{\arDsYeh}{\mathord{\text{\katibglyphs 𞺩}}}
\DeclareRobustCommand{\arDsLam}{\mathord{\text{\katibglyphs 𞺫}}}
\DeclareRobustCommand{\arDsMeem}{\mathord{\text{\katibglyphs 𞺬}}}
\DeclareRobustCommand{\arDsNoon}{\mathord{\text{\katibglyphs 𞺭}}}
\DeclareRobustCommand{\arDsSeen}{\mathord{\text{\katibglyphs 𞺮}}}
\DeclareRobustCommand{\arDsAin}{\mathord{\text{\katibglyphs 𞺯}}}
\DeclareRobustCommand{\arDsFeh}{\mathord{\text{\katibglyphs 𞺰}}}
\DeclareRobustCommand{\arDsSad}{\mathord{\text{\katibglyphs 𞺱}}}
\DeclareRobustCommand{\arDsQaf}{\mathord{\text{\katibglyphs 𞺲}}}
\DeclareRobustCommand{\arDsReh}{\mathord{\text{\katibglyphs 𞺳}}}
\DeclareRobustCommand{\arDsSheen}{\mathord{\text{\katibglyphs 𞺴}}}
\DeclareRobustCommand{\arDsTeh}{\mathord{\text{\katibglyphs 𞺵}}}
\DeclareRobustCommand{\arDsTheh}{\mathord{\text{\katibglyphs 𞺶}}}
\DeclareRobustCommand{\arDsKhah}{\mathord{\text{\katibglyphs 𞺷}}}
\DeclareRobustCommand{\arDsThal}{\mathord{\text{\katibglyphs 𞺸}}}
\DeclareRobustCommand{\arDsDad}{\mathord{\text{\katibglyphs 𞺹}}}
\DeclareRobustCommand{\arDsZah}{\mathord{\text{\katibglyphs 𞺺}}}
\DeclareRobustCommand{\arDsGhain}{\mathord{\text{\katibglyphs 𞺻}}}
\DeclareRobustCommand{\arOpMeemHah}{\mathop{\text{\katibglyphs 𞻰}}}
\DeclareRobustCommand{\arOpHahDal}{\mathop{\text{\katibglyphs 𞻱}}}
\DeclareRobustCommand{\rsum}{\operatorname*{\katibmirror{\sum}}}
\DeclareRobustCommand{\rint}{\mathop{\katibmirror{\int}}\nolimits}
\DeclareRobustCommand{\riint}{\mathop{\katibmirror{\iint}}\nolimits}
\DeclareRobustCommand{\riiint}{\mathop{\katibmirror{\iiint}}\nolimits}
\DeclareRobustCommand{\roint}{\mathop{\katibmirror{\oint}}\nolimits}
\DeclareRobustCommand{\roiint}{\mathop{\katibmirror{\oiint}}\nolimits}
\DeclareRobustCommand{\rsqrt}[1]{\katibmirror{\sqrt{\katibmirror{#1}}}}
\DeclareRobustCommand{\rroot}[2]{\katibmirror{\sqrt[\katibmirror{#1}]{\katibmirror{#2}}}}
\DeclareRobustCommand{\rpartial}{\katibmirror{\partial}}
\DeclareRobustCommand{\rexists}{\katibmirror{\exists}}
\DeclareRobustCommand{\rnexists}{\katibmirror{\nexists}}
\DeclareRobustCommand{\ranglesign}{\katibmirror{\angle}}
\DeclareRobustCommand{\rmeasuredangle}{\katibmirror{\measuredangle}}
\DeclareRobustCommand{\rpropto}{\mathrel{\katibmirror{\propto}}}
\DeclareRobustCommand{\rcomplement}{\katibmirror{\complement}}
\DeclareRobustCommand{\arCubeRoot}{\mathop{\text{\katibglyphs ؆}}}
\DeclareRobustCommand{\arFourthRoot}{\mathop{\text{\katibglyphs ؇}}}
\DeclareRobustCommand{\arRay}{\mathord{\text{\katibglyphs ؈}}}
\DeclareRobustCommand{\arPercent}{\mathord{\text{\katibglyphs ٪}}}
\DeclareRobustCommand{\arPermille}{\mathord{\text{\katibglyphs ؉}}}
\DeclareRobustCommand{\arPerTenThousand}{\mathord{\text{\katibglyphs ؊}}}
\DeclareRobustCommand{\arNaturals}{\arDsTah}
\DeclareRobustCommand{\arIntegers}{\arDsSad}
\DeclareRobustCommand{\arRationals}{\arDsNoon}
\DeclareRobustCommand{\arReals}{\arDsHah}
\DeclareRobustCommand{\arComplex}{\mathord{\text{\textbf{\textarabic{ك}}}}}
\DeclareRobustCommand{\arGcd}{\operatorname{\text{\textarabic{ق.م.أ}}}}
\DeclareRobustCommand{\arLcm}{\operatorname{\text{\textarabic{م.م.أ}}}}
\DeclareRobustCommand{\arDet}{\operatorname{\text{\textarabic{محدد}}}}
\DeclareRobustCommand{\arMod}{\mathrel{\text{\textarabic{باقي القسمة}}}}
\DeclareRobustCommand{\arFact}[1]{\mathord{!}#1}

\endinput
