我的页码不是阿拉伯语。我使用缅甸语页码,၁、၂、၃、၄ 等,相当于 1、2、3、4。我使用以下方法将默认阿拉伯语页码转换为缅甸语数字:
%%% 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
当我尝试 vref 时,即使引用的项目位于对页/或上一页,我仍然会得到带有页码的结果,例如“第 23 页上的图 1”,而不是“对页/上一页上的图 1”。如果引用和引用的项目位于同一页,结果似乎有效。如果它位于使用 vref 引用它的同一页上,我只会得到没有页码的“图 1”。
即使我的页码不是阿拉伯语,我怎样才能获得没有页码的前一页/对页的预期结果?
提前致谢!
\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}
答案1
一个完全不同的答案,采用完全不同的方法。
自最新更新以来,zref-vario
允许人们指定zref
用于页面比较的属性,而不是,从而解除了要求使用阿拉伯页码来区分“附近”页面和“远处”页面page
的限制。varioref
这是通过pageprop
选项完成的,可以将其设置abspage
为由模块提供zref-abspage
zref
,这样您就有一个用于页面比较的页面计数器,它独立于页面引用的打印表示,因此您可以使用任何您可能喜欢的页码编号方案。
您可能认为或不认为这是一个缺点,即它适用于zref
引用系统,而不是标准系统。无论如何,下面的示例会将您的 MWE 调整为它:
\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}
编辑:有些好玩。这种方法允许我们利用varioref
awesome 包来使用 的增强页面引用sillypage
:
\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}
答案2
以下解决方案也给了我想要的结果。它还适用于这两个对我来说非常重要的重要属性:
\XeTeXlinebreaklocale "my_MM" %Myanmar line and character breaks
\XeTeXinterwordspaceshaping = 2
- 创建映射文件 mmdigit_mapping.map,内容如下
; 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 ;
- 运行
teckit_compile mmdigit_mapping.map
以获取mmdigit_mapping.tec
文件。我不确定为什么我的 macos 已经有了teckit_compile
。可能需要从这里获取安装程序: https://software.sil.org/teckit/
然后我创建如下所示的 *.tex 文件并测试:
%!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}
答案3
如果您愿意使用babel
,luatex
我认为有一个干净的解决方案,即使用mapdigits
来自的选项\babelprovide
。当然,加载babel
区域设置和设置语言的效果不仅限于此映射,但我认为这些也是可取的。
% !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}