%% mathbb-one.sty -- \mathbb{1} for amssymb, in the bbm style, as a vector font.
%%
%% amssymb's \mathbb has no digits. This package makes \mathbb{1} (and
%% \Bbbone, the unicode-math name) print the "1" from Gilles F. Robert's bbm
%% fonts, the closest match to \mathbb's Computer Modern style, traced to
%% Type 1 outlines so it stays sharp in PDF. Nothing else changes.
%%
%% Copyright (C) 2026 Thomas Beck
%% https://github.com/t-a-beck/mathbb-one
%%
%% This work may be distributed and/or modified under the conditions of
%% the LaTeX Project Public License, version 1.3c or later
%% (https://www.latex-project.org/lppl.txt).
%% This work has the LPPL maintenance status `maintained'.
%% The Current Maintainer of this work is Thomas Beck.
%% This work consists of the file mathbb-one.sty.
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mathbb-one}[2026/11/04 v1.0 Blackboard-bold 1 for amssymb's mathbb]
\RequirePackage{iftex}
\ifpdftex
  \pdfmapfile{=mathbb-one.map}
\else\ifluatex
  \pdfextension mapfile {=mathbb-one.map}
\else\ifxetex
  \special{pdf:mapfile mathbb-one.map}
\fi\fi\fi
% Sizes are chosen the way amssymb's umsb.fd chooses msbm, so the 1 keeps
% the same weight relative to the \mathbb letters at every size.
\DeclareFontFamily{U}{mathbb-one}{}
\DeclareFontShape{U}{mathbb-one}{m}{n}{%
  <-6> mathbb-one5 <6-8> mathbb-one7 <8-> mathbb-one10}{}
% Under unicode-math, \Bbbone and \mathbb{1} already work; keep those.
\ifdefined\Bbbone\else
  \DeclareSymbolFont{mathbbone}{U}{mathbb-one}{m}{n}
  \DeclareMathSymbol{\Bbbone}{\mathord}{mathbbone}{`1}
\fi
% Inside \mathbb, make 1 mean \Bbbone. Done at \begin{document} so the order
% of \usepackage lines doesn't matter.
\begingroup\lccode`\~=`\1 \lowercase{\endgroup\def\mathbbone@activeone{~}}
\AtBeginDocument{%
  \@ifpackageloaded{unicode-math}{}{%
    \ifdefined\mathbb
      \NewCommandCopy\mathbbone@mathbb\mathbb
      \RenewDocumentCommand\mathbb{m}{%
        {\mathcode`\1="8000 \mathbbone@mathbb{#1}}}%
      \expandafter\let\mathbbone@activeone\Bbbone
    \else
      \PackageWarningNoLine{mathbb-one}{%
        \string\mathbb\space is not defined. Load amssymb (or amsfonts)\MessageBreak
        to get \string\mathbb{1}; \string\Bbbone\space works either way}%
    \fi}}
\endinput
