0

I have been using latex for a long time but I always use latex for writing documents that are not particularly special. Now, it is a bit different because I would like to to change the numbering system and I would like all pages to be numbered with Mayan numbers. I know that the command:

\maya{number}

Would give the number in mayan format. However, that would not allow me to number every page automatically unless I go page by page adding \maya{number} to every page manually.

Does anyone has any suggestion as where to look in order to get some knowledge about this?

  • Welcome to TeX - LaTeX! Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – Alessandro Cuttin Apr 15 at 15:07
0

I adapted (read reusing) the code from Mayan Numerals in math mode. You need XeLaTeX or LuaLaTeX to compile it, as well as BabelStone Mayan Numerals font. Here's the code:

%!TEX program = lualatex
%You can use xelatex, too
\documentclass{article}
\usepackage{amsmath}
\usepackage{fontspec}

\newfontface{\mayanumerals}{BabelStone Mayan Numerals}
\ExplSyntaxOn

\NewDocumentCommand{\mayanumber}{sO{}m}
{
    \IfBooleanTF { #1 }
    {
        \ensuremath { \mathrm { \tl_upper_case:n { \int_to_base:nn { #3 } { 20 } }\sb{20} } }
    }
    {
        \tatojo_maya_number:nn { #2 } { #3 }
    }
}

\int_const:Nn \c__tatojo_maya_start_int { "1D2E0 }
\tl_new:N \l__tatojo_maya_converted_tl
\seq_new:N \l__tatojo_maya_digits_seq

\keys_define:nn { tatojo/maya }
{
    align      .tl_set:N = \l__tatojo_maya_align_tl,
    align      .initial:n = c,
    horizontal .bool_set:N = \l__tatojo_maya_horizontal_bool,
    horizontal .default:n = true,
    vertical   .bool_set_inverse:N = \l__tatojo_maya_horizontal_bool,
    vertical   .default:n = true,
    scale      .code:n =
    {
        \fp_compare:nT { #1 != 1 } { \addfontfeatures{Scale=#1} }
    }
}

\cs_new_protected:Nn \tatojo_maya_number:nn
{
    \mbox
    {
        % choose the font and set spacing to 0.5
        \mayanumerals
        % evaluate options
        \keys_set:nn { tatojo/maya } { #1 }
        % clear the sequence containing the digits
        \seq_clear:N \l__tatojo_maya_digits_seq
        % convert the input to base 20
        \tl_set:Nx \l__tatojo_maya_converted_tl
        {
            \int_to_base:nn { #2 } { 20 }
        }
        % fill the digit sequence
        \tl_map_function:NN \l__tatojo_maya_converted_tl \__tatojo_maya_adddigit:n
        % print the digit sequence
        \bool_if:NTF \l__tatojo_maya_horizontal_bool
        {
            \seq_use:Nn \l__tatojo_maya_digits_seq { }
        }
        {
            \begin{tabular}[\l__tatojo_maya_align_tl]{@{}c@{}}
                \shortstack[c]{ \seq_use:Nn \l__tatojo_maya_digits_seq { \\ } }
            \end{tabular}
        }
    } % close the \mbox
}

\cs_new:Nn \__tatojo_maya_adddigit:n
{
    \seq_put_right:Nx \l__tatojo_maya_digits_seq
    {
        \tatojo_maya_digit:n { \int_from_base:nn { #1 } { 20 } }
    }
}

\cs_new_protected:Nn \tatojo_maya_digit:n
{
    \symbol { \int_eval:n { \c__tatojo_maya_start_int + #1 } }
}

\ExplSyntaxOff
%And here's the magic
\renewcommand{\thepage}{$\mayanumber[horizontal,scale=3]{\arabic{page}}$}
\begin{document}
\Huge
\input tufte
\input knuth
\input knuth
\input tufte
\input knuth
\input knuth
\end{document}

Now we go to the document and, voilà, Mayan numerals. enter image description here

| improve this answer | |
  • Thank you very much. This is easy to use. Thank you. – Bpi Apr 15 at 18:08
  • Please don't forget to mark this answer as useful if this helped you. – user193767 Apr 15 at 18:31

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.