# Hieroglyphs numerals

Can someone give me a hint how do I obtain hieroglyphs numerals 1--1000 in XeTeX? I'm using this package:

\usepackage{hieroglf}


I need a macro with

\hg{\n} which prints \n in Hieroglyphs.

EDIT

Your solution is good, but for the fact that it already uses incorrect character at number 1!

I need to accomplish these both things at once: to correct the starting number according to the snippet below and to extend the following sequence of roman,arabic,babyloniannum to hieroglyphs. My base will be 10.

\renewcommand{\theenumi}{\roman{enumi}--\arabic{enumi}--\!\!\!\!\!\babyloniannum{\value{enumi}}\!\!\!}


• Note that, in XeTeX, you can omit the package and use the Unicode characters for heiroglyphs from any font that supports them. – Davislor Oct 5 '19 at 18:23
• Could you please provide me with MWE to obtain an answer for my EDIT ? – user2925716 Oct 5 '19 at 18:27
• I’m afraid I might need to ask you to wait on that. – Davislor Oct 5 '19 at 18:28
• @Davislor I will wait. I'll be happy to hear the answer sometime. – user2925716 Oct 5 '19 at 18:30
• I think we shouldn't use the comment under Peter's answer to communicate. I updated the answer to be employable in lists and so on. I have not the faintest idea about unicode. The answer works also with PDFLaTeX, which I consider a feature. What I could, however, offer is to make the answer shorter by employing e.g. xint. – Schrödinger's cat Oct 5 '19 at 20:53

UPDATE: Thanks for posting an MWE. Here is something that does that.

\documentclass{article}
\usepackage{hieroglf}
\newcounter{hieroaux}
\newcounter{hierocurr}
\newcommand{\HieroDigit}[1]{\ifcase#1
\or
\Hone
\or
\Hten
\or
\Hhundred
\or
\Hthousand
\or
\HXthousand
\or
\HCthousand
\or
\Hmillion
\fi}
\DeclareRobustCommand\hg[1]{\setcounter{hierocurr}{#1}%
\ifnum\value{hierocurr}>999999
\setcounter{hieroaux}{0}%
\loop\stepcounter{hieroaux}\textpmhg{\HieroDigit{7}}%
\ifnum\value{hieroaux}<\the\numexpr(\value{hierocurr}-500000)/1000000\relax%
\repeat%
\setcounter{hierocurr}{\the\numexpr\value{hierocurr}-\value{hieroaux}*1000000}%
\fi
\ifnum\value{hierocurr}>99999
\setcounter{hieroaux}{0}%
\loop\stepcounter{hieroaux}\textpmhg{\HieroDigit{6}}%
\ifnum\value{hieroaux}<\the\numexpr(\value{hierocurr}-50000)/100000\relax%
\repeat%
\setcounter{hierocurr}{\the\numexpr\value{hierocurr}-\value{hieroaux}*100000}%
\fi%
\ifnum\value{hierocurr}>9999
\setcounter{hieroaux}{0}%
\loop\stepcounter{hieroaux}\textpmhg{\HieroDigit{5}}%
\ifnum\value{hieroaux}<\the\numexpr(\value{hierocurr}-5000)/10000\relax%
\repeat%
\setcounter{hierocurr}{\the\numexpr\value{hierocurr}-\value{hieroaux}*10000}%
\fi%
\ifnum\value{hierocurr}>999
\setcounter{hieroaux}{0}%
\loop\stepcounter{hieroaux}\textpmhg{\HieroDigit{4}}%
\ifnum\value{hieroaux}<\the\numexpr(\value{hierocurr}-500)/1000\relax%
\repeat%
\setcounter{hierocurr}{\the\numexpr\value{hierocurr}-\value{hieroaux}*1000}%
\fi%
\ifnum\value{hierocurr}>99
\setcounter{hieroaux}{0}%
\loop\stepcounter{hieroaux}\textpmhg{\HieroDigit{3}}%
\ifnum\value{hieroaux}<\the\numexpr(\value{hierocurr}-50)/100\relax%
\repeat%
\setcounter{hierocurr}{\the\numexpr\value{hierocurr}-\value{hieroaux}*100}%
\fi%
\ifnum\value{hierocurr}>9
\setcounter{hieroaux}{0}%
\loop\stepcounter{hieroaux}\textpmhg{\HieroDigit{2}}%
\ifnum\value{hieroaux}<\the\numexpr(\value{hierocurr}-5)/10\relax%
\repeat%
\setcounter{hierocurr}{\the\numexpr\value{hierocurr}-\value{hieroaux}*10}%
\fi%
\ifnum\value{hierocurr}>0
\setcounter{hieroaux}{0}%
\loop\stepcounter{hieroaux}\textpmhg{\HieroDigit{1}}%
\ifnum\value{hieroaux}<\value{hierocurr}\relax%
\repeat%
\fi}
\begin{document}
\renewcommand{\thesection}{\hg{\value{section}}}
\section{Examples}

$5=\hg{5}$\par
$36=\hg{36}$\par
$2357468=\hg{2357468}$\par
$\hg{7}\cdot\hg{6}=\hg{42}$\par
$\displaystyle\frac{\hg{3131}}{\hg{101}}=\hg{31}$\par
$\pi=\hg{3}.\hg{14159}$

\section{Numbered lists}

\renewcommand{\theenumi}{\roman{enumi}--\arabic{enumi}--\hg{\value{enumi}}}
\begin{enumerate}
\item A
\item B
\end{enumerate}
\end{document}


OLD (AND COMPLETELY UNEGYTIAN) ANSWER: I'd like to start by saying that I have no idea whatsoever about hieroglyphs. This is just for fun. I copied some of the hieroglyphs from the hieroglf package source. Since there was a block of 74+1 of them, this gives you numerals with base 74. If you want another base, please provide an MWE from which I can learn what the appropriate digits and base are. Other than that I added a clumsy modulo and int function that does not need extra packages. If you want to make this more elegant, you may want to specify if you are OK with loading xint or pgf.

\documentclass{article}
\usepackage{hieroglf}
\newcommand\HieroGlf[1]{\ifcase#1
\Hdual
\or
\HAi
\or
\HAii
\or
\HAxxviii
\or
\HCxi
\or
\HDi
\or
\HDii
\or
\HDiv
\or
\HDxxi
\or
\HDxxxvi
\or
\HDxlvi
\or
\HDxlvii
\or
\HDl
\or
\HDliv
\or
\HDlviii
\or
\HExxiii
\or
\HFi
\or
\HFxx
\or
\HFxxxi
\or
\HFxxxiv
\or
\HFxl
\or
\HGi
\or
\HGxvii
\or
\HGxxvi
\or
\HGxxvis
\or
\HGxxvii
\or
\HGxxviii
\or
\HGxxxvi
\or
\HGxliii
\or
\HHviii
\or
\HIviii
\or
\HIix
\or
\HIx
\or
\HKi
\or
\HMiii
\or
\HMviii
\or
\HMxii
\or
\HMxvii
\or
\HNxxix
\or
\HNxxxv
\or
\HNxxxvii
\or
\HOi
\or
\HOiv
\or
\HOxxxiv
\or
\HQiii
\or
\HRvii
\or
\HSxii
\or
\HSxxix
\or
\HSxxxix
\or
\HSxli
\or
\HTiii
\or
\HTxiv
\or
\HUxxxvi
\or
\HVi
\or
\HViv
\or
\HVxiii
\or
\HVxx
\or
\HVxxiv
\or
\HVxxviii
\or
\HVxxxi
\or
\HWxi
\or
\HXi
\or
\HYiV
\or
\HYiv
\or
\HZi
\or
\HZii
\or
\HZiv
\or
\HZvi
\or
\HZvii
\or
\HZxi
\or
\HAai
\or
\HAaxii
\or
\HPWi
\or
\HPWii
\fi}
\newcommand{\hieronumeral}[1]{\edef\temp{#1}%
\ifnum\the\numexpr\temp/(74*74)>1%
\textpmhg{\HieroGlf{\the\numexpr\temp/(74*74)-1}}%
\edef\temp{\the\numexpr\temp-74*74*\the\numexpr\temp/(74*74)-1\relax}%
\fi%
\ifnum\the\numexpr(\temp+37)/74>1%
\textpmhg{\HieroGlf{\the\numexpr(\temp+37)/74-1}}%
\edef\temp{\the\numexpr\temp-74*\the\numexpr(\temp+37)/74-1\relax}%
\else%
\ifnum#1>74%
0%
\fi%
\fi%
\textpmhg{\HieroGlf{\temp}}}
\begin{document}
$123=\hieronumeral{123}$

\newcounter{iloop}
\setcounter{iloop}{0}
\loop\stepcounter{iloop}
$\number\value{iloop}=\hieronumeral{\number\value{iloop}}$,
\ifnum\number\value{iloop}<999\repeat%
$1000=\hieronumeral{1000}$
\end{document}


• Where is the MWE? Not in the question? – cfr Oct 6 '19 at 2:14
• @cfr I meant to write MEOW. ;-) You're right, there is no MWE, and there has never been one, but at least some important information was added. – Schrödinger's cat Oct 6 '19 at 2:18
• Well, they did like cats, I know. – cfr Oct 6 '19 at 2:20
• @cfr When the climate is too hot for marmots, one starts worshipping cats instead. – Schrödinger's cat Oct 6 '19 at 2:21

The Egyptians used the decimal numbering system. The hieroglf package provides glyphs for numbers, \Hone for units, \Hten for tens, \Hhundred for hundreds. The Egyptians repeated the glyphs to make up the required number.

The only example I have seen is of the number 28 where there were 2 \Hten glyphs on top of 4 \Hone glyphs on top of 4 \Hone glyphs making a stack of three sets of glyphs.

I don't know how the number, say 39, should be represented. I understand that the representation of 234 should consist of 2 of \Hhundred, 3 of \Hten and 4 of \Hone but how the glyphs should be ordered within the document I do not know. I guess that it is a matter of aesthetics and may well depend on how the adjacent glyphs are laid out.

It seems that you might need some code that converts a number into the required number of glyphs, which I assume somebody can do for you, but then these need to be assembled into something that the Egyptians would recognize as a number. Perhaps up to you?

• Unicode has those precomposed glyphs for Egyptian digits. For example, 6,000 is U+131C1. XeTeX can use them with fontspec. – Davislor Oct 5 '19 at 18:40
• Thanks for that information! +1 I wish I had seen that earlier before I posted the second version of my answer... – Schrödinger's cat Oct 5 '19 at 18:57
• @Schrödinger'scat That's my fault, sorry. I should have emphasized that I was using XeTeX. In fact I started to use it just because I needed other strange numerals. – user2925716 Oct 5 '19 at 19:16
• @user2925716 No worries! It was fun learning something about Egyptian numerology. ;-) – Schrödinger's cat Oct 5 '19 at 19:17
• @Schrödinger'scat So could you now please finally give me a general way how to index Hieroglyphs in this style \renewcommand{\theenumi}{\roman{enumi}--\arabic{enumi}--\!\!\!\!\!\babyloniannum{\value{enumi}}\!\!\!} with Unicode and XeTeX ? – user2925716 Oct 5 '19 at 20:17

Here is a solution using fontspec and expl3. It’s not very compact, but in my opinion, it’s a lot more readable than the legacy solution.

\documentclass{article}
\RequirePackage{expl3}
\usepackage{fontspec}

% These fonts are available at: http://users.teilar.gr/~g1951d/
\newfontfamily\hieroglyphfont{Aegyptus}[Scale = MatchUppercase, Script={Egyptian Hieroglyphs}]
\newfontfamily\emojifont{Symbola}[Scale = MatchUppercase] % The modern equivalent.

\newcommand\shrug{{{\emojifont\symbol{"1F937}}}}
\newcommand\EgyptianShrug{{\hieroglyphfont 𓀠}}

\ExplSyntaxOn

\regex_new:N \c_up_to_seven_digits_regex
\regex_set:Nn \c_up_to_seven_digits_regex { ^\d{1,7}\$ }

\cs_new:Npn \hiero_numeral:n #1
{
\regex_match:NnTF
\c_up_to_seven_digits_regex
{#1}
{
\begingroup\hieroglyphfont
\int_to_symbols:nnn
{ \int_mod:nn {\int_div_truncate:nn {#1} {1000000}} {10} }
{10}
{% This is anachronistic; ancient Egyptians did not typically write 𓁨𓁨
{0}{}
{1}{𓁨}
{2}{𓁨𓁨}
{3}{𓁨𓁨𓁨}
{4}{𓁨𓁨𓁨𓁨}
{5}{𓁨𓁨𓁨𓁨𓁨}
{6}{𓁨𓁨𓁨𓁨𓁨𓁨}
{7}{𓁨𓁨𓁨𓁨𓁨𓁨𓁨}
{8}{𓁨𓁨𓁨𓁨𓁨𓁨𓁨𓁨}
{9}{𓁨𓁨𓁨𓁨𓁨𓁨𓁨𓁨𓁨}
}
\int_to_symbols:nnn
{ \int_mod:nn {\int_div_truncate:nn {#1} {100000}} {10} }
{10}
{% Also anachronistic.
{0}{}
{1}{𓆐}
{2}{𓆐𓆐}
{3}{𓆐𓆐𓆐}
{4}{𓆐𓆐𓆐𓆐}
{5}{𓆐𓆐𓆐𓆐𓆐}
{6}{𓆐𓆐𓆐𓆐𓆐𓆐}
{7}{𓆐𓆐𓆐𓆐𓆐𓆐𓆐}
{8}{𓆐𓆐𓆐𓆐𓆐𓆐𓆐𓆐}
{9}{𓆐𓆐𓆐𓆐𓆐𓆐𓆐𓆐𓆐}
}
\int_to_symbols:nnn
{ \int_mod:nn {\int_div_truncate:nn {#1} {10000}} {10} }
{10}
{
{0}{}
{1}{𓂭}
{2}{𓂮}
{3}{𓂯}
{4}{𓂰}
{5}{𓂱}
{6}{𓂲}
{7}{𓂳}
{8}{𓂴}
{9}{𓂵}
}
\int_to_symbols:nnn
{ \int_mod:nn {\int_div_truncate:nn {#1} {1000}} {10} }
{10}
{
{0}{}
{1}{𓆼}
{2}{𓆽}
{3}{𓆾}
{4}{𓆿}
{5}{𓇀}
{6}{𓇁}
{7}{𓇂}
{8}{𓇃}
{9}{𓇄}
}
\int_to_symbols:nnn
{ \int_mod:nn {\int_div_truncate:nn {#1} {100}} {10} }
{10}
{
{0}{}
{1}{𓍢}
{2}{𓍣}
{3}{𓍤}
{4}{𓍥}
{5}{𓍦}
{6}{𓍧}
{7}{𓍨}
{8}{𓍩}
{9}{𓍪}
}
\int_to_symbols:nnn
{ \int_mod:nn {\int_div_truncate:nn {#1} {10}} {10} }
{10}
{
{0}{}
{1}{𓎆}
{2}{𓎇}
{3}{𓎈}
{4}{𓎉}
{5}{𓎊}
{6}{𓎋}
{7}{𓎌}
{8}{𓎍}
{9}{𓎎}
}
\int_to_symbols:nnn
{ \int_mod:nn {#1} {10} }
{10}
{
{0}{}
{1}{𓏺}
{2}{𓏻}
{3}{𓏼}
{4}{𓏽}
{5}{𓏾}
{6}{𓏿}
{7}{𓐀}
{8}{𓐁}
{9}{𓐂}
}
\endgroup
}
{\shrug\EgyptianShrug}
}

\cs_generate_variant:Nn \hiero_numeral:n { e }

\newcommand\hg[1]{\hiero_numeral:e{#1}}

\ExplSyntaxOff

\begin{document}

\hg{1132641} (1132641)

\hg{4037} (4037)

\hg{NaN} (NaN)

\end{document}
`