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 .