3

I need to extend the following sequence of roman,arabic,babyloniannum to hieroglyphs. The solution for LaTeX has been given elsewhere but is very cumbersome. Also, it doesn't do the grouping of numerals of the same class.

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

I'm looking for a Unicode with the use of XeTeX version which should be very straightforward. That is in at most **ordinary 5 lines of code.**

EDIT This question is not a duplicate of this question at all. The answer there doesn't use Unicode which I expect to use here. Tha author of the answer there has stated in fact that he is unable to write an Unicode answer to my problem.

More precisely I need to use that Unicode has those precomposed glyphs for Egyptian digits. For example, 6,000 is U+131C1. XeTeX can use them with fontspec. But I do not know how do I create this U+131C1 in my file ideje.tex. I hope the situation is clearer now?

enter image description here

16
  • 2
    Your question is very unclear. Most of the code in the linked answer could be put into a package and therefore the fact that it appears cumbersome to you is irrelevant. The grouping problem would be better described with a minimal example using that code and showing what the desired output would be. Furthermore, the issue seems to have very little to do with Unicode, other than the source of the glyphs themselves, which has nothing to do with generating the correct sequence of them corresponding to a number. And stating a maximum!? number of lines of code makes no sense.
    – Alan Munn
    Oct 5, 2019 at 22:06
  • 1
    this seems to be a duplicate of, or at most a comment on, the question you just asked tex.stackexchange.com/questions/511099/hieroglyphs-numerals Oct 5, 2019 at 22:45
  • 1
    I am not sure what you mean by "how do I create this U+131C1 in my file ideje.tex" that seems to be just a question about your editor, you can just type it in as character data (๐“‡) or use ^^^^131c1 tex notation, or \symbol{"131C1} for example. Oct 6, 2019 at 11:10
  • 1
    well clearly you need a font with the characters, I have no idea which (but I assume any google search for these characters would suggest a suitable font. On my windows machine here firefox shows the character that I used in the previous comment with Segoe UI Historic (which I think is a standard Windows font, so I could use that in xetex via fontspec. Oct 6, 2019 at 11:28
  • 1
    Does unicode do the grouping? How? if you would accept a package that does the mapping of the numbers then the 5 line comment really makes no sense at all as any code given can be saved to a package, and there are very few packages with less than 5 lines Oct 6, 2019 at 11:40

2 Answers 2

7

enter image description here

I had to guess some of the unicode mappings, just looking at

https://www.unicode.org/charts/PDF/U13000.pdf

\documentclass{article}
\usepackage{fontspec}
\newfontfamily\hg{Segoe UI Historic}

\def\hgunits#1{\ifcase#1\relax\or
^^^^^^0133fa\or
^^^^^^0133fb\or
^^^^^^0133fc\or
^^^^^^0133fd\or
^^^^^^0133fe\or
^^^^^^0133ff\or
^^^^^^013400\or
^^^^^^013401\or
^^^^^^013402\else
?\fi}

\def\hgtens#1{\ifcase#1\relax\or
^^^^^^013386\or
^^^^^^013387\or
^^^^^^013388\or
^^^^^^013389\or
^^^^^^01338a\or
^^^^^^01338b\or
^^^^^^01338c\or
^^^^^^01338d\or
^^^^^^01338e\else
?\fi}

\def\hghundreds#1{\ifcase#1\relax\or
^^^^^^013362\or
^^^^^^013363\or
^^^^^^013364\or
^^^^^^013365\or
^^^^^^013366\or
^^^^^^013367\or
^^^^^^013368\or
^^^^^^013369\or
^^^^^^01336a\else
?\fi}

\def\hgthousands#1{\ifcase#1\relax\or
^^^^^^0131bc\or
^^^^^^0131bd\or
^^^^^^0131be\or
^^^^^^0131bf\or
^^^^^^0131c0\or
^^^^^^0131c1\or
^^^^^^0131c2\or
^^^^^^0131c3\or
^^^^^^0131c4\else
?\fi}

\def\hgtenthousands#1{\ifcase#1\relax\or
^^^^^^0130ad\or
^^^^^^0130ae\or
^^^^^^0130af\or
^^^^^^0130b0\or
^^^^^^0130b1\or
^^^^^^0130b2\or
^^^^^^0130b3\or
^^^^^^0130b4\or
^^^^^^0130b5\else
?\fi}

\def\hghundredthousands#1{\ifcase#1\relax\or
^^^^^^013190\or
^^^^^^013190^^^^^^013190\or
^^^^^^013190^^^^^^013190^^^^^^013190\or
^^^^^^013190^^^^^^013190^^^^^^013190^^^^^^013190\or
^^^^^^013190^^^^^^013190^^^^^^013190^^^^^^013190^^^^^^013190\else
?\fi}

\def\hgnum#1{{\hg\expandafter\hgnumx\the\numexpr10000000+#1\relax}}
\def\hgnumx#1#2#3#4#5#6#7#8{%
\hghundredthousands{#3}%
\hgtenthousands{#4}%
\hgthousands{#5}%
\hghundreds{#6}%
\hgtens{#7}%
\hgunits{#8}%
}
\begin{document}


152123

{\hg
\hghundredthousands{1}%
\hgtenthousands{5}%
\hgthousands{2}%
\hghundreds{1}%
\hgtens{2}%
\hgunits{3}%
}

\hgnum{152123}

\end{document}
3
  • Works fine! However see this. Oct 6, 2019 at 14:54
  • You have typos in the definition of \hgtens ;-) Oct 11, 2019 at 15:42
  • I blame @UlrikeFischer Oct 11, 2019 at 15:43
0

Iโ€™ll repost my answer using Unicode. Itโ€™s not as terse as requested, because it uses expl3, but neither is David Carslisleโ€™s fine answer.

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .