3

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}}\!\!\!}

enter image description here

  • 3
    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
  • 1
    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
8

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}

enter image description here

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}

enter image description here

| improve this answer | |
  • 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
  • 1
    Well, they did like cats, I know. – cfr Oct 6 '19 at 2:20
  • 1
    @cfr When the climate is too hot for marmots, one starts worshipping cats instead. – Schrödinger's cat Oct 6 '19 at 2:21
3

@user2925716 sent me an email about this and I responded with some information and suggested asking here, not realising that he had already done so. This is not a complete answer but might help others give one.

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?

| improve this answer | |
  • 1
    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
0

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}

Aegyptus Sample

| improve this answer | |

Your Answer

By clicking โ€œPost Your Answerโ€, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.