3

I am preparing a document whose main language is arabic, I am using babel+Lualatex I followed the procedure discussed in Redefine \cref for non-English languages

However, it gives an error saying "unknown option arabic", is there a way to define a new language for Clever ref and Varioref ref?? Here is the MWE:

\documentclass[a4paper,12pt,twoside]{book}
\usepackage[a4paper,top=2.5cm,bottom=2.5cm,margin=2.5cm,bindingoffset=0.5cm]{geometry} % Set paper layout
%======================================================================================================
%Babel Package Settings%
%======================================================================================================
\usepackage[bidi=basic,layout=lists.tabular]{babel}
\babelprovide[import=ar,mapdigits,main]{arabic}
\babelprovide[import=en,language=Default]{english}
\babelfont{rm}{Latin Modern Roman}
\babelfont[arabic]{rm}{Simplified Arabic}

\usepackage [arabic]{varioref} %  add "on the preceding page", "on the following page", or on the page number to a reference

\usepackage[arabic,english]{cleveref}
%==================================================
%Start actual document %
%===================================================
\title{jhhjjhhj}
\author{}
\date{}

\begin{document}
\chapter{سييسسيبيسب}
بلبيللبيبلبي
\section{بيسيبلبيبلبيل}\label{بندددد}
البند رقم
\ref{بندددد} 
صفحة
\pageref{بندددد}
البند
~\vref{بندددد}

ب
\cref{بندددد}

\end{document}

5

Languages are supported by varioref (and cleveref) through defined options. Languages that aren't set up in this way can't be given as an "option" to the package even though you can nevertheless set them up in the preamble of your document.

I could add an "arabic" option to the package if somebody provides me with the right textual strings, i.e., I would need the texts in the following definitions be replaced with Arabic words:

\DeclareOption{arabic}
  {\vref@addto\extrasarabic{%
    \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\reftextpagerange#1#2{on pages~\pageref{#1}--\pageref{#2}}%
    \def\reftextlabelrange#1#2{\ref{#1} to~\ref{#2}}%
  }}

after which \usepackage[arabic]{varioref} would work.

With cleveref the situation is similar, but you would need to talk the developer of that package to get this language supported as an option.

Test document

As requested in a comment, here is a test document which (I think) exercises all cases.

\documentclass[twoside]{article}

\usepackage{varioref}

\begin{document}

          \section{A} \label{A1} \section{A2} \label{A2}

\newpage  \section{B} \label{B1} \section{B2} \label{B2}

See \vref{A1} ; See \vref{A2} ; See \vrefrange{A1}{A2} 

See \vref{B1} ; See \vref{B2} ; See \vrefrange{B1}{B2}

Current page: \pageref{B1} ; \pageref{B2}

See \vref{C1} ; See \vref{C2} ; See \vrefrange{C1}{C2} 

See \vref{D1} ; See \vref{D2} ; See \vrefrange{D1}{D2} 

Longer ranges: \vrefrange{A1}{C1} ; \vpagerefrange{B1}{D2}

\newpage  \section{C} \label{C1} \section{C2} \label{C2}

\newpage  \section{D} \label{D1} \section{D2} \label{D2}

\end{document}
| improve this answer | |
  • According to cleveref manual: Cleveref supports a number of languages other than English, and also supports the babel and polyglossia packages for those languages. Either pass the desired language as an option to cleveref, or pass it as a global option to\document class. Passing a language to the document class is not preferred. However, do you happen to have the code required for declaring a new language as an option, since this is already possible? – Silva Sep 7 '19 at 19:19
  • @Silva sure cleveref supports a number of languages, but not necessary all of babel and what it doesn't support you can't pass as an option to it. As a user you can't declare a new language for either ot the two packages; it has to be done by the maintainer of the package, there is no real interface for it. – Frank Mittelbach Sep 7 '19 at 19:31
  • I prepared the Arabic translation. However, do you happen to have any sample code on which I can test the proposed translation (examine all cases), only to make sure it is working as it should? – Silva Sep 8 '19 at 0:18
  • @Silva done. If your translation is ready, please send it to the email address in the file and indicate if you want your contact details shown in the doc or not. – Frank Mittelbach Sep 8 '19 at 8:41
  • Final Query, for the lines having 2 definitions, when is each one used, for example :"\reftextvario{facing}{next}", when is the term "facing" used and when is the term"next" used?? Is there a purpose for having 2 terms with the same meaning? The same query goes for the rest of the definitions. – Silva Sep 8 '19 at 21:02

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.