0

I would like to change bookmark numbers to Burmese numbers (i.e (1) to (၁), (2.1) to (၂.၁), etc.). I use fontspec and I can map all Arabic numbers to corresponding Burmese ones so that I have chapter, section, and page numbers in Burmese. I use

\addfontfeatures{Mapping=digit_mapping}

to do the mapping. (Details can be found here: How to use locale numbering / custom numbering for Burmese?)

Would it be possible to do similar mapping before generating the bookmarks? Please see MWE below for what I've been trying.

%!TeX program = XeLaTex
%!TEX encoding = UTF-8 Unicode

\documentclass[10pt]{book}
\XeTeXlinebreaklocale "my_MM"  %Myanmar line and character breaks
\XeTeXinterwordspaceshaping=2 %%% PLEASE EXPERIMENT  BY SETTING WITH DIFFERENT VALUES


\usepackage{fontspec}
\setmainfont{Padauk Book}

\usepackage{titletoc}
\usepackage{titlesec}

\usepackage[hyperfootnotes=false,bookmarksnumbered]{hyperref}
\usepackage{bookmark}
% I may be able to transform the numbers to Burmese here
\makeatletter
\renewcommand\Hy@numberline[1]{(#1)} 
\makeatother
% I'd like to do some font mapping so that (1) to (၁), (2.1) to (၂.၁), etc.


\begin{document}

\chapter{Hello 1}
Helo
\section{world }

\chapter{Hello 2}
Helo
\section{world }

\end{document}

enter image description here

5
  • What language setup are you using? Babel? Polyglossia? Language options?
    – cfr
    Commented Apr 26 at 18:43
  • Hi @cfr, I only use XeLaTex and fontspec. For my setup, MWE can be found here: tex.stackexchange.com/questions/690399/…
    – Pyi Soe
    Commented Apr 26 at 18:49
  • Doesn't that throw everything else off? It means you're using hyphenation patterns for US English, for example, as well as US English labels. There is, of course, no such thing as not using any language configuration. You just get US defaults.
    – cfr
    Commented Apr 26 at 23:36
  • Hi, the packages you mentioned don't support Burmese language well, as far as I've tried and researched. Especially, justification doesn't work probably because Burmese doesn't have hyphenation dictionary yet. Only XeLaTex and \XeTeXinterwordspaceshaping=2 option can produce the desired justification. Even then, I've to use \allowbreak frequently to overcome horizontal overflow problem.
    – Pyi Soe
    Commented Apr 27 at 2:24
  • Oh, if there aren't hyphenation patterns, that's different. There's not a whole lot you can do in that case except providing hyphenation for the most difficult cases and manually breaking where necessary. Sorry, I didn't realise there weren't any. (I don't know how to decode the language abbreviations the files use in all cases.) Burmese and Scottish Gaelic both have this problem (though Gaelic does have some basic translations - I don't know how good).
    – cfr
    Commented Apr 27 at 4:16

1 Answer 1

3

Assuming that burmese numbers are a decimal system like the arabic numbers this here could work (both with xelatex and lualatex):

\documentclass[10pt]{book}


\usepackage{fontspec}
\setmainfont{Padauk Book}

\usepackage{titletoc}
\usepackage{titlesec}

\usepackage[hyperfootnotes=false,bookmarksnumbered]{hyperref}
\usepackage{bookmark}
% I may be able to transform the numbers to Burmese here
\makeatletter
\renewcommand\Hy@numberline[1]{(#1)} 

\ExplSyntaxOn
\renewcommand\thechapter{\codepoint_generate:nn {\the\value{chapter}+4160}{12}}
\renewcommand\thesection{\thechapter.\codepoint_generate:nn {\the\value{section}+4160}{12}}

\ExplSyntaxOff
\makeatother
% I'd like to do some font mapping so that (1) to (၁), (2.1) to (၂.၁), etc.


\begin{document}
\chapter{Hello 1}
Helo
\section{world }
\section{two}

\chapter{Hello 2}
Helo
\section{world }

enter image description here

enter image description here

5
  • Thank you so much. Actually, I already manage to get Burmese numbers for ToC(the pdf page, not the bookmark of course) using titlecontents{chapter/section etc} together with \addfontfeatures{Mapping=digit_mapping}. Anyway, I will have to use your method for bookmarks and some other scenarios where addfontfeatures doesn't work.
    – Pyi Soe
    Commented Apr 27 at 2:16
  • For MWE, it does work. But when I tried in my current setup, I got bookmarks like (1) Hello 1, (1.၁) world, (1.၂) two. It seems only the last number is replaced. I will see if I can figure out what's going on.
    – Pyi Soe
    Commented Apr 27 at 2:38
  • I noticed that, as it is, {\the\value{chapter}+4160}{12}} doesn't work if I have more than one digit, e.g (11.12). I think we will have to add 4160 to each digit (character), not the whole thing, which is either the chapter number or the section number.
    – Pyi Soe
    Commented Apr 27 at 4:25
  • Yes, if the number gets larger you must extend the code. In babel-greek there is something similar that you can copy and adapt. Commented Apr 27 at 7:44
  • Thanks, I'll take a look. By the way, is it possible to \renewcommand only for bookmark processing. I mean only when bookmark package is doing its processing. Since I've already used \addfontfeatures{Mapping=digit_mapping} for other cases, I guess it will be better if I can use \renewcommand only for bookmark processing.
    – Pyi Soe
    Commented Apr 27 at 8:38

You must log in to answer this question.

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