我想让标题从右到左编号。例如将标题更改شکل 01
为: شکل 10
。
我想要这样的东西的原因是我正在使用从右到左的语言,我可以使用使文档中的数字正确显示,\LR
但我无法控制标题编号。所以第 10 个标题将是这样的Figure 01
。
以下是我的 MWE,用来表达我想要的意思。我尽量让它尽可能通用。
\documentclass{beamer}
\usepackage[persian]{babel}
\usepackage{caption}
\setbeamertemplate{caption}[numbered]
\setmainfont[Script=Arabic,Numbers=Arabic]{XB Zar}
\setsansfont[Script=Arabic,Numbers=Arabic]{XB Zar}
\begin{document}
\begin{frame}
\begin{figure}
\caption{شکل \LR{1}}
\caption{شکل \LR{2}}
\caption{شکل \LR{3}}
\caption{شکل \LR{4}}
\caption{شکل \LR{5}}
\caption{شکل \LR{6}}
\caption{شکل \LR{7}}
\caption{شکل \LR{8}}
\caption{شکل \LR{9}}
\caption{شکل \LR{10}}
\end{figure}
\end{frame}
\end{document}
我看到\renewcommand{\thefigure}{\textbf{\arabic{figure}}}
将标题编号改为粗体,所以我认为类似的东西\renewcommand{\thefigure}{\LR{\arabic{figure}}}
应该可以工作,但事实并非如此。我教的另一件事是制作正确格式的数字列表,因此 LaTeX 遵循我的编号样式而不是计数器样式,但我显然不是那么专业。请使用 LuaLaTeX 进行排版。
这是将波斯语选项转换为 babel 的 Persian.ldf。
\ProvidesLanguage{persian}
[2010/01/03 v0.3 Persian support for the babel system]
\LdfInit{persian}{captionspersian}
\ifx\l@persian\@undefined
\@nopatterns{Persian}
\adddialect\l@persian0
\fi
\addto\captionspersian{%
\def\prefacename{\RL{پیشگفتار}}%
\def\refname{\RL{منابع}}
\def\abstractname{\RL{چکیده}}%
\def\bibname{\RL{منبع}}%
\def\chaptername{\RL{فصل}}%
\def\appendixname{\RL{پیوست}}%
%\def\contentsname{\RL{فهرست مطالب}}
\def\contentsname{\RL{فهرست}}%
\def\listfigurename{\RL{لیست تصاویر}}%
\def\listtablename{\RL{لیست جدولها}}%
\def\indexname{\RL{نمایه}}%
\def\figurename{\RL{شکل}}%
\def\tablename{\RL{جدول}}%
\def\partname{\RL{قسمت}}%
\def\enclname{\RL{المرفقات}}
\def\ccname{\RL{رونوشت}}% <<
\def\headtoname{\RL{به}}
\def\pagename{\RL{صفحه}}%
\def\seename{\RL{ببینید}}%
\def\alsoname{\RL{همچنین ببینید}}%
\def\proofname{\RL{برهان}}% for AMS-\LaTeX
\def\glossaryname{\RL{واژهنامه}}%<<
}
\AtEndOfPackage{
\RequirePackage{luatextra}
\RequirePackage{ifluatex}
%\luatexRequireModule{persian}
\ifluatex
\else
\newlinechar`\^^J
\typeout{^^JTo avoid this error message,^^J%
run LuaTeX engine instead of regular TeX.^^J}
\errmessage{[Persian Support Error: use LuaTeX engine}%
\fi
\@switch@dir{TRT}\@rltrue
}
\def\@page@dir#1{\luatexpagedir #1}
\def\@body@dir#1{\luatexbodydir #1}
\def\@para@dir#1{\luatexpardir #1}
\def\@text@dir#1{\luatextextdir #1}
\def\@math@dir#1{\luatexmathdir #1}
\def\@switch@dir#1{\@page@dir{#1}\@body@dir{#1}\@para@dir{#1}\@text@dir{#1}}
\newif\if@rl
\def\LR#1{{\@rlfalse\@text@dir{TLT}#1}}
\def\RL#1{{\@rltrue\@text@dir{TRT}#1}}
\def\setRL{\@rltrue\@switch@dir{TRT}}
\def\setLR{\@rlfalse\@switch@dir{TLT}}
\newenvironment{rltext}{\@rltrue\@para@dir{TRT}\@text@dir{TRT}}{}
\newenvironment{lrtext}{\@rlfalse\@para@dir{TLT}\@text@dir{TLT}}{}
\def\@sect#1#2#3#4#5#6[#7]#8{%
\ifnum #2>\c@secnumdepth
\let\@svsec\@empty
\else
\refstepcounter{#1}%
\protected@edef\@svsec{\@seccntformat{#1}\relax}%
\fi
\@tempskipa #5\relax
\ifdim \@tempskipa>\z@
\begingroup
#6{%
\@hangfrom{\hskip #3\relax\@svsec}%
\interlinepenalty \@M #8\@@par}%
\endgroup
\csname #1mark\endcsname{#7}%
\addcontentsline{toc}{#1}{%
\ifnum #2>\c@secnumdepth \else
\protect\numberline{\csname the#1\endcsname}%
\fi
\if@rl{\@text@dir{TRT}#7}%
\else{\@text@dir{TLT}#7}\fi}%
\else
\def\@svsechd{%
#6{\hskip #3\relax
\@svsec #8}%
\csname #1mark\endcsname{#7}%
\addcontentsline{toc}{#1}{%
\ifnum #2>\c@secnumdepth \else
\protect\numberline{\csname the#1\endcsname}%
\fi
#7}}%
\fi
\@xsect{#5}}
% BEGIN TABULAR
% my "buggy" code
%\def\@tabular{\leavevmode \hbox \bgroup \if@rl\@math@dir{TRT}\fi $\let\@acol\@tabacol
% \let\@classz\@tabclassz
% \let\@classiv\@tabclassiv \let\\\@tabularcr\@tabarray}
% the follwing from Vafa
\def\@array[#1]#2{%
\if #1t\vtop \else \if#1b\vbox \else \vcenter \fi\fi
\bgroup
\setbox\@arstrutbox\hbox{%
\vrule \@height\arraystretch\ht\strutbox
\@depth\arraystretch \dp\strutbox
\@width\z@}%
\@mkpream{#2}%
\edef\@preamble{%
\ialign \noexpand\@halignto
\bgroup \@arstrut \@preamble \tabskip\z@skip \cr}%
\let\@startpbox\@@startpbox \let\@endpbox\@@endpbox
\let\tabularnewline\\%
\let\par\@empty
\let\@sharp##%
\set@typeset@protect
\lineskip\z@skip\baselineskip\z@skip
\ifhmode \@preamerr\z@ \@@par\fi
\if@rl\@text@dir{TRT}\fi
\@preamble}
% swap right and left
\def\@testpach#1{\@chclass \ifnum \@lastchclass=\tw@ 4 \else
\ifnum \@lastchclass=3 5 \else
\z@ \if #1c\@chnum \z@ \else
\if \if@rl#1r\else#1l\fi\@chnum \@ne \else
\if \if@rl#1l\else#1r\fi\@chnum \tw@ \else
\@chclass \if #1|\@ne \else
\if #1@\tw@ \else
\if #1p3 \else \z@ \@preamerr 0\fi
\fi \fi \fi \fi \fi \fi
\fi}
% END TABULAR
\newif\if@rlmath
\def\@my@startmath{\if@rl\if@rlmath\bgroup\@math@dir{TRT}\fi\fi$}
\def\@my@stopmath{$\if@rl\if@rlmath\egroup\fi\fi}
\def\@my@startdisplaymath{\if@rl\if@rlmath\bgroup\@math@dir{TRT}\fi\fi$$}
\def\@my@stopdisplaymath{$$\if@rl\if@rlmath\egroup\fi\fi}
\def\({\relax\ifmmode\@badmath\else\@my@startmath\fi}
\def\){\relax\ifmmode\ifinner\@my@stopmath\else\@badmath\fi\else \@badmath\fi}
\def\[{%
\relax\ifmmode
\@badmath
\else
\ifvmode
\nointerlineskip
\makebox[.6\linewidth]{}%
\fi
\@my@startdisplaymath%%$$ BRACE MATCH HACK
\fi
}
\def\]{%
\relax\ifmmode
\ifinner
\@badmath
\else
\@my@stopdisplaymath%%$$ BRACE MATCH HACK
\fi
\else
\@badmath
\fi
\ignorespaces
}
\def\@seccntformat#1{{%
\if@rl%
\@text@dir{TRT}%
\else%
\@text@dir{TLT}%
\fi%
\csname the#1\endcsname\quad}}
\def\datepersian{\def\today{\luadirect{tex.sprint(jalali.today())}}}
\ldf@finish{persian}
\endinput
答案1
这里有一种方法:
\documentclass{beamer}
\usepackage[persian]{babel}
\usepackage[compatibility=false]{caption}
\setbeamertemplate{caption}[numbered]
\DeclareCaptionLabelFormat{rlnumber}{#1 \LR{#2}}
\captionsetup{labelformat=rlnumber}
\setmainfont[Script=Arabic]{XB Zar}
\setsansfont[Script=Arabic,Numbers=Arabic]{XB Zar}
\begin{document}
\begin{frame}
\setcounter{figure}{8}
\begin{figure}
\caption{شکل \LR{9}}
\caption{شکل \LR{10}}
\end{figure}
\end{frame}
\end{document}