3

I have page numbers which are not arabic. I use page numbers in Burmese, ၁, ၂, ၃, ၄, etc., which are equivalent to 1, 2, 3, 4. I use the following to turn default arabic page numbers to Burmese numbers:

%%% Auto numbering in Myanmar %%%
%This macro is to produce myanmar numbering by adopting the thai numbering method
\makeatletter  
\def\@mmnum#1{\expandafter\@@mmnum\number#1\@nil}  
\def\@@mmnum#1{%  
  \ifx#1\@nil  
  \else  
  \char\numexpr#1+"1040\relax  % 1040 is zero character for Burmese.
  \expandafter\@@mmnum\fi  
}  
\renewcommand\@arabic{\@mmnum} % to reset number in \arabic to \mmnum

When I tried vref, even if the referenced item is on the facing/or preceding page, I still get the result with the page number like "Figure 1 on page 23" instead of "Figure 1 on the facing/previous page". If the reference and the referenced item are on the same page, the result seems to work. I get just "Figure 1" without the page number if it's on the same page on which vref is used to refer to it.

How can I get the expected result for preceding/facing page without the page number even if my page numbers are not arabic?

Thanks in advance!

\documentclass[twoside]{book}
\usepackage{parskip}
\usepackage{graphicx}
\usepackage{varioref}
\usepackage{blindtext}
\usepackage{fontspec}


%%% Font related tweaks
\defaultfontfeatures{Script=Myanmar,Mapping=tex-text} 
\fontspec[Script=Myanmar, BoldFont={Padauk Bold}, ]{Padauk}
\setmainfont[Color=tungsten,
                UprightFont={Padauk},
                BoldFont={Padauk Bold},
                ItalicFont={Padauk},
                BoldItalicFont={Padauk Bold},
                SmallCapsFont={Padauk},
                SlantedFont={Padauk}]{Padauk}
                [Renderer=Harfbuzz,Script=Myanmar]


\def\reftextfaceafter{\reftextvario{Page is near}{Page is near} Page is near}%%
\def\reftextafter {Page is near}%
\def\reftextfacebefore{Page is near}%
\def\reftextbefore {Page is near}%
\def\reftextcurrent{\reftextvario{Same page}{Sagem page} Same page}%
\def\reftextfaraway#1{(“If the referenced item is near, I should not see this.”).~\pageref{#1}}%
\def\reftextpagerange#1#2{on QQQQ~\pageref{#1}--\pageref{#2}}%
\def\reftextlabelrange#1#2{\ref{#1} to~\ref{#2}}%

%%% Auto numbering in Myanmar %%%
%This macro is to produce myanmar numbering by adopting the thai numbering method
\makeatletter  
\def\@mmnum#1{\expandafter\@@mmnum\number#1\@nil}  
\def\@@mmnum#1{%  
  \ifx#1\@nil  
  \else  
  \char\numexpr#1+"1040\relax  
  \expandafter\@@mmnum\fi  
}  
\renewcommand\@arabic{\@mmnum} % to reset number in \arabic to \mmnum 

\begin{document}
\section{Figures}
\begin{figure}
\includegraphics{example-image}
\caption{An example figure}
%%%%%% This is okay
See figure -- \vref*{fig:example}
%%%%%%
\label{fig:example}
\end{figure}
\blindtext
\begin{figure}
\includegraphics{example-image}
\caption{Another example figure}
\label{fig:other}
\end{figure}
\newpage
Same reference code, different output:
\begin{verbatim}
See the \vpageref[above figure][figure]{fig:other} and
the \vpageref[above figure][figure]{fig:example}.
\end{verbatim}
See the \vpageref[above figure][figure]{fig:other} and
the \vpageref[above figure][figure]{fig:example}.
\blindtext
\blindtext
\blindtext
\blindtext


%%%%% This is not okay 
See figure \vref*{fig:other} ----

See figure \vref*{fig:example} ----

\end{document}
10
  • Welcome to TeX.SE! Can you please make your code snippet be compilable, then we do not have to guess what you are doing ...
    – Mensch
    Commented Jun 4, 2022 at 16:04
  • Thanks a lot @Mensch. I've added the code snippet I used to test. The font I used can be downloaded here: fonts.google.com/specimen/Padauk
    – Pyi Soe
    Commented Jun 4, 2022 at 16:12
  • Clarification question: when I run your code I get the output See the above figure and the LLLLL ၁ for the first references and fig. ၂ LLLLL ၂ sdfsdfdf fig. ၁ LLLLL ၁ for the second references. When I remove the \reftext redefinitions I get See the above figure and the on page ၁ for the first references. Do you get the same output? If yes, how should it be changed, i.e., what is the exact desired output in these four cases?
    – Marijn
    Commented Jun 5, 2022 at 8:46
  • 1
    Basically, for my case with Burmese numerals, vref is always returning reftextfaraway when the reference and the referenced item are not on the same page even if they are close.
    – Pyi Soe
    Commented Jun 5, 2022 at 9:27
  • 1
    Note that in Ubuntu the Padauk font is installed automatically as dependency of the distribution package texlive-lang-other (and therefore texlive-full) so anyone that installed TeX Live through the Ubuntu repositories has the font. It is also a dependency of various Ubuntu desktop packages (presumably to provide Myanmar support), so probably also available if you installed TeX Live through tlmgr.
    – Marijn
    Commented Jun 5, 2022 at 13:11

3 Answers 3

2

A different answer with an altogether different approach.

Since the latest update, zref-vario allows one to specify the zref property to use for page comparisons, instead of page, thus lifting the restriction of varioref of requiring Arabic page numbering to distinguish "nearby" from "far away" pages.

This is done with the pageprop option, which can be set to abspage provided by the zref-abspage zref module, so that you have a page counter used for page comparisons which is independent from the printed representation of your page references, and thus you can use whatever page numbering scheme you may fancy.

What you may or may not consider a downside, is that this works with the zref referencing system rather than the standard one. Anyway, the example below adjusts your MWE to it:

\documentclass[twoside]{book}
\usepackage{parskip}
\usepackage{graphicx}
\usepackage{blindtext}
\usepackage{fontspec}

%%% Font related tweaks
\defaultfontfeatures{Script=Myanmar,Mapping=tex-text}
\fontspec[Script=Myanmar, BoldFont={Padauk Bold}, ]{Padauk}
\setmainfont[Color=tungsten,
                UprightFont={Padauk},
                BoldFont={Padauk Bold},
                ItalicFont={Padauk},
                BoldItalicFont={Padauk Bold},
                SmallCapsFont={Padauk},
                SlantedFont={Padauk}]{Padauk}
                [Renderer=Harfbuzz,Script=Myanmar]

%%% Auto numbering in Myanmar %%%
%This macro is to produce myanmar numbering by adopting the thai numbering method
\makeatletter
\def\@mmnum#1{\expandafter\@@mmnum\number#1\@nil}
\def\@@mmnum#1{%
  \ifx#1\@nil
  \else
  \char\numexpr#1+"1040\relax
  \expandafter\@@mmnum\fi
}%"
\renewcommand\@arabic{\@mmnum} % to reset number in \arabic to \mmnum

\usepackage{zref-vario}
\usepackage{zref-abspage}
\zvsetup{pageprop=abspage}

\begin{document}

\section{Figures}

\begin{figure}
\includegraphics{example-image}
\caption{An example figure}

%%%%%% This is okay
See \zvref{fig:example}
%%%%%%

\zlabel{fig:example}
\end{figure}

\blindtext

\begin{figure}
\includegraphics{example-image}
\caption{Another example figure}
\zlabel{fig:other}
\end{figure}

\newpage

Same reference code, different output:

\begin{verbatim}
See the \zvpageref[vcurrent={above figure},vother={figure}]{fig:other} and
the \zvpageref[vcurrent={above figure},vother={figure}]{fig:example}.
\end{verbatim}
See the \zvpageref[vcurrent={above figure},vother={figure}]{fig:other} and
the \zvpageref[vcurrent={above figure},vother={figure}]{fig:example}.

\blindtext
\blindtext
\blindtext
\blindtext

%%%%% This is now okay
See \zvref{fig:other} ---

See \zvref{fig:example} ---

\end{document}

enter image description here

Edit: Some fun. This approach allows us to use varioref's enhanced page references with the awesome sillypage package:

\documentclass[twoside]{book}

\usepackage{graphicx}
\usepackage{blindtext}
\usepackage{sillypage}

\usepackage{zref-vario}
\usepackage{zref-abspage}
\zvsetup{pageprop=abspage}

\begin{document}
\pagenumbering{silly}

\chapter{Figures}

\blindtext

\begin{figure}
\includegraphics{example-image}
\caption{An example figure}
\zlabel{fig:example}
\end{figure}

\blindtext[3]

\begin{figure}
\includegraphics{example-image}
\caption{Another example figure}
\zlabel{fig:other}
\end{figure}

\clearpage

\blindtext[3]

\bigskip{}

See \zvref{fig:other}.

See \zvref{fig:example}.

\end{document}

enter image description here

7
  • Hello @gusbrs, thank you so much for your help. I think the second approach looks promising. I'll try that out and let know how it goes after testing.
    – Pyi Soe
    Commented Jul 17, 2022 at 6:04
  • What I've been thinking as a workaround is just to replace the 0, 1, 2,..., 9 with ၀, ၁, ၂, ..., ၉ in the Burmese font using some kind of font editor software like FontForge. I am not sure about the consequences though.
    – Pyi Soe
    Commented Jul 17, 2022 at 6:24
  • @PyiSoe Hard-coding the change at the font itself sounds a little too "brute force" to me. But, well, who knows? Maybe it works. Technically, as far as I understand, it more or less is what the mapdigits / LuaLaTeX answer does, without editing the font.
    – gusbrs
    Commented Jul 17, 2022 at 10:36
  • after updating \usepackage{zref-vario} \usepackage{zref-abspage} packages, I can produce the desired output. And I hope this is one and only last obstacle I encountered regarding auto numbering and referencing. It seems everything else in LaTex is already working fine for me. Bye the way, I also feel that changing the font itself should be the last resort. I've asked for others' opinion here. Again, I really appreciate your help. Thanks a lot!
    – Pyi Soe
    Commented Jul 17, 2022 at 14:23
  • Hi @gusbrs, when I add \XeTeXlinebreaklocale "my_MM" \XeTeXinterwordspaceshaping = 2 , zvref doesn't produce the desired result. If \XeTeXinterwordspaceshaping = 0/1, it can produce the desired result. My head starts spinning again :). I have no idea why XeTeXinterwordspaceshaping can affect the way zvref wroks.
    – Pyi Soe
    Commented Jul 19, 2022 at 16:49
1

The following solution gives me the result I want as well. It also works with these two important properties which are very important for me:

\XeTeXlinebreaklocale "my_MM"  %Myanmar line and character breaks
\XeTeXinterwordspaceshaping = 2
  1. create a mapping file, mmdigit_mapping.map with content
; FC ... 
LHSName "Digits"
RHSName "BurmeseDigits"

pass(Unicode)
U+0030 <> U+1040 ;
U+0031 <> U+1041 ;
U+0032 <> U+1042 ;
U+0033 <> U+1043 ;
U+0034 <> U+1044 ;
U+0035 <> U+1045 ;
U+0036 <> U+1046 ;
U+0037 <> U+1047 ;
U+0038 <> U+1048 ;
U+0039 <> U+1049 ;
  1. Run teckit_compile mmdigit_mapping.map to get mmdigit_mapping.tec file. I am not sure why my macos already has teckit_compile. Probably one will need to get the installer from here: https://software.sil.org/teckit/

And then I create my *.tex file like below and test :

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

\documentclass[twoside, openright]{book}
\XeTeXlinebreaklocale "my_MM"  %Myanmar line and character breaks
\XeTeXinterwordspaceshaping = 2

\usepackage[nospace]{varioref}
\usepackage{graphicx}
\usepackage{varioref}
\usepackage{fontspec}
\usepackage{fancyhdr}
\usepackage{caption}
\usepackage{subcaption}
\usepackage[dvipsnames]{xcolor}
\usepackage{hyperref}

\setmainfont[
        % https://tex.stackexchange.com/questions/193412/what-is-happening-to-the-quotes
        Ligatures = TeX,
        WordSpace = 1,
        UprightFont = {Padauk Book},
        BoldFont = {Padauk Book Bold},
        ItalicFont = {Padauk Book},
        BoldItalicFont = {Padauk Book Bold},
        SmallCapsFont = {Padauk Book},
        SlantedFont = {Padauk Book},
        % https://tex.stackexchange.com/questions/498689/how-to-use-locale-numbering-custom-numbering-for-burmese
        % Mapping=mmdigit_mapping
    ]
    {Padauk Book}
    [Renderer = Graphite, RawFeature = {Tear drop style washwe=True}]

\newcommand{\myPgNoFnt}
    {\fontspec[
            % the mapping
            Mapping = mmdigit_mapping,
            Script = Myanmar,
            Scale = MatchLowercase, 
            BoldFont = {Padauk Book Bold}
        ]
        {Padauk Book}
        \selectfont}

\newcommand{\myRefCntFnt}
{\fontspec[
        Mapping = mmdigit_mapping,
        Script = Myanmar,
        Scale = MatchLowercase, 
        BoldFont = {Padauk Book Bold}
    ]
    {Padauk Book}
    \selectfont} 
    
\newcommand{\myCptFnt}
{\fontspec[
        Mapping = mmdigit_mapping,
        Script = Myanmar,
        Scale = MatchLowercase, 
        BoldFont = {Pyidaungsu Bold}
    ]
    {Pyidaungsu}
    %[Renderer=Graphite, RawFeature={Tear drop style washwe=True}]
    \selectfont} 

%\def\reftextfaceafter {on the \reftextvario{facing}{next} page}%
%\def\reftextfacebefore{on the \reftextvario{facing}{preceding} page}%
%\def\reftextafter     {on the \reftextvario{following}{next} page}%
%\def\reftextbefore    {on the \reftextvario{preceding}{previous} page}%
%\def\reftextcurrent   {on \reftextvario{this}{the current} page}%
%\def\reftextfaraway#1{on page~\pageref{#1}}%

\def\reftextfaceafter {\reftextvario{တစ်ဖက်}{နောက်}စာမျက်နှာ~}%
\def\reftextfacebefore{\reftextvario{တစ်ဖက်}{ရှေ့}စာမျက်နှာ~}% အရင် ပြီးခဲ့တဲ့ 
\def\reftextafter     {\reftextvario{လာမဲ့}{နောက်}စာမျက်နှာ~}%
\def\reftextbefore    {\reftextvario{ပြီးခဲ့တဲ့}{‌ရှေ့}စာမျက်နှာ~}%
\def\reftextcurrent   {\reftextvario{}{}}%
\def\reftextfaraway#1{စာမျက်နှာ~{\myRefCntFnt\pageref{#1}}~}%

\newcommand{\myvref}[1] {
    {\myRefCntFnt{\vpageref[]{#1}}}{\myRefCntFnt{\Ref*{#1}}}
} 

\renewcommand{\figurename}{ပုံ}

\fancypagestyle{plain}{%
    \fancyhf{} % clear all header and footer fields
    \fancyfoot[C]{\bfseries\myPgNoFnt\thepage}
    \renewcommand{\headrulewidth}{0pt}
    \renewcommand{\footrulewidth}{0pt}
}

\fancypagestyle{headings}{%
    \fancyhf{} % clear all header and footer fields
    \fancyhead[LO,RE]{\bfseries\myPgNoFnt\thepage}
    \renewcommand{\headrulewidth}{0pt}
    \renewcommand{\footrulewidth}{0pt}
}

\pagestyle{headings}

\renewcommand{\figurename}{ပုံ}
\DeclareCaptionFont{captionfont}{\myCptFnt}
\captionsetup[figure]{
    singlelinecheck=false,
    justification=raggedright,
    font={captionfont, bf, small, onehalfspacing}}
\DeclareCaptionLabelFormat{custom}
    {~#1 \textbf{#2}~}  %to get "Figure (1)", "Figure [1]", etc
% Separator style
\DeclareCaptionLabelSeparator{custom}{- } % to get "Figure (1):", "Figure(1) - Some caption" etc
% Caption format    
\DeclareCaptionFormat{custom}
    {#1#2\small #3}
\captionsetup{
    format=custom,
    labelformat=custom,
    labelsep=custom}
    
\labelformat{figure}{ပုံ~{\myRefCntFnt #1}}

\addtolength{\topmargin}{-3.0pt}
\setlength{\headheight}{15pt}

\begin{document}

\chapter{Chapter 1}

\begin{figure}
\includegraphics{example-image}
\caption{အစမ်းပုံ ၁}
\label{fig:fig1}
\end{figure}

----------------------- \myvref{fig:fig1} -----------------------

\noindent----------------------- \myvref{fig:fig2} -----------------------

\noindent----------------------- \myvref{fig:fig3} -----------------------

\noindent----------------------- \myvref{fig:fig4} -----------------------

\noindent----------------------- \myvref{fig:fig5} -----------------------

\noindent----------------------- \myvref{fig:fig6} -----------------------




\newpage
\begin{figure}
\includegraphics{example-image}
\caption{အစမ်းပုံ ၂}
\label{fig:fig2}
\end{figure}

----------------------- \myvref{fig:fig1} -----------------------

\noindent----------------------- \myvref{fig:fig2} -----------------------

\noindent----------------------- \myvref{fig:fig3} -----------------------

\noindent----------------------- \myvref{fig:fig4} -----------------------

\noindent----------------------- \myvref{fig:fig5} -----------------------

\noindent----------------------- \myvref{fig:fig6} -----------------------

\newpage
\begin{figure}
\includegraphics{example-image}
\caption{အစမ်းပုံ ၃}
\label{fig:fig3}
\end{figure}

----------------------- \myvref{fig:fig1} -----------------------

\noindent----------------------- \myvref{fig:fig2} -----------------------

\noindent----------------------- \myvref{fig:fig3} -----------------------

\noindent----------------------- \myvref{fig:fig4} -----------------------

\noindent----------------------- \myvref{fig:fig5} -----------------------

\noindent----------------------- \myvref{fig:fig6} -----------------------

\newpage
\begin{figure}
\includegraphics{example-image}
\caption{အစမ်းပုံ ၄}
\label{fig:fig4}
\end{figure}

----------------------- \myvref{fig:fig1} -----------------------

\noindent----------------------- \myvref{fig:fig2} -----------------------

\noindent----------------------- \myvref{fig:fig3} -----------------------

\noindent----------------------- \myvref{fig:fig4} -----------------------

\noindent----------------------- \myvref{fig:fig5} -----------------------

\noindent----------------------- \myvref{fig:fig6} -----------------------

\newpage
\begin{figure}
\includegraphics{example-image}
\caption{အစမ်းပုံ ၅}
\label{fig:fig5}
\end{figure}

----------------------- \myvref{fig:fig1} -----------------------

\noindent----------------------- \myvref{fig:fig2} -----------------------

\noindent----------------------- \myvref{fig:fig3} -----------------------

\noindent----------------------- \myvref{fig:fig4} -----------------------

\noindent----------------------- \myvref{fig:fig5} -----------------------

\noindent----------------------- \myvref{fig:fig6} -----------------------

\newpage
\begin{figure}
\includegraphics{example-image}
\caption{အစမ်းပုံ ၆}
\label{fig:fig6}
\end{figure}

----------------------- \myvref{fig:fig1} -----------------------

\noindent----------------------- \myvref{fig:fig2} -----------------------

\noindent----------------------- \myvref{fig:fig3} -----------------------

\noindent----------------------- \myvref{fig:fig4} -----------------------

\noindent----------------------- \myvref{fig:fig5} -----------------------

\noindent----------------------- \myvref{fig:fig6} -----------------------

\end{document}

enter image description here

0

If you are willing to use babel and luatex I think there is a clean solution to this, which is to use the mapdigits option from \babelprovide. Of course, the effects of loading a babel locale and setting a language are not limited to this mapping, but I presume these would also be desirable.

% !TeX program = LuaLaTeX
\documentclass[twoside]{book}

\usepackage[english]{babel}
\babelprovide[mapdigits, import, main]{burmese}

\usepackage{parskip}
\usepackage{graphicx}
\usepackage{varioref}
\usepackage{blindtext}
\usepackage{fontspec}

%%% Font related tweaks
\defaultfontfeatures{Script=Myanmar,Mapping=tex-text}
\fontspec[Script=Myanmar, BoldFont={Padauk Bold}]{Padauk}
\setmainfont[
  Color=tungsten,
  UprightFont={Padauk},
  BoldFont={Padauk Bold},
  ItalicFont={Padauk},
  BoldItalicFont={Padauk Bold},
  SmallCapsFont={Padauk},
  SlantedFont={Padauk}
]{Padauk}[Renderer=Harfbuzz,Script=Myanmar]

\def\reftextfaceafter{\reftextvario{Page is near}{Page is near} Page is near}%%
\def\reftextafter {Page is near}%
\def\reftextfacebefore{Page is near}%
\def\reftextbefore {Page is near}%
\def\reftextcurrent{\reftextvario{Same page}{Sagem page} Same page}%
\def\reftextfaraway#1{(“If the referenced item is near, I should not see this.”).~\pageref{#1}}%
\def\reftextpagerange#1#2{on QQQQ~\pageref{#1}--\pageref{#2}}%
\def\reftextlabelrange#1#2{\ref{#1} to~\ref{#2}}%

\begin{document}
\section{Figures}
\begin{figure}
\includegraphics{example-image}
\caption{An example figure}
%%%%%% This is okay
See figure -- \vref*{fig:example}
%%%%%%
\label{fig:example}
\end{figure}
\blindtext
\begin{figure}
\includegraphics{example-image}
\caption{Another example figure}
\label{fig:other}
\end{figure}
\newpage
Same reference code, different output:
\begin{verbatim}
See the \vpageref[above figure][figure]{fig:other} and
the \vpageref[above figure][figure]{fig:example}.
\end{verbatim}
See the \vpageref[above figure][figure]{fig:other} and
the \vpageref[above figure][figure]{fig:example}.
\blindtext
\blindtext
\blindtext
\blindtext

%%%%% This is okay now
See figure \vref*{fig:other} ----

See figure \vref*{fig:example} ----

\end{document}

enter image description here

2
  • Thanks for helping me out. I am currently using XeLaTex. The reason is that, according to what I've read online, it's the best engine for our language. And it also supports right justification pretty well. By the way, I need to write the book mostly in Burmese. I am not sure how much support babel can provide for my language. Anyway, I'll try what you have suggested above. Just in case you may want to have a look at my document: github.com/pyiso80/book-programming-with-java/blob/master/…
    – Pyi Soe
    Commented Jun 6, 2022 at 2:39
  • @PyiSoe Well, unfortunately, I really have no idea of the specific needs of your language, and what different packages handle it better. You are better placed than me to judge. Still, that was the best I could come up with. :)
    – gusbrs
    Commented Jun 6, 2022 at 2:46

You must log in to answer this question.

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