6

I'm using xepersian for my article but in one page I need to add Gregorian calendar date. so I add:

\usepackage[british]{babel}

and then where I want the date:

\selectlanguage{british}
{\large \today}

butthen where ever I use today it writes Gregorian instead of persian (still in persian but uses Gregorian calender) and figure caption texts (like Fig.) is in english instead of persian.

EDIT:

\documentclass[14pt,a4paper]{article}

%\usepackage[british]{babel}
\usepackage{enumerate}
\usepackage{xepersian}
\settextfont{XB Niloofar}

\begin{document}
\today
\end{document}

Like this the printed date is from persian calendar like this (reads 16th of khordad 1393):

enter image description here

but when I uncomment that line it will be english language in persian like this(reads 6th of june 2014):

enter image description here

  • Can you give us a minimal working example (MWE) to test? – Johannes_B Jun 6 '14 at 17:09
  • Is there a babel option for persian? than you could try \usepackage[persian,english]{babel} ... \begin{document} \selectlanguage{persian} – user36296 Jun 6 '14 at 17:24
  • I don't think so. I looked on the internet but couldn't find anything. I also tried adding persian in that line but it didn't recognize it. – soroosh.strife Jun 6 '14 at 17:28
9

Two things up front:

  1. As XePersian is relying on the XeTeX engine, I would recommend using polyglossia instead of babel.
  2. The article document class cannot use the 14pt option; for more information, take a look at this answer.

The Problem in your case is that XePersian clearly changes all western numerals (123) into genuine Arabic numerals (١٢٣), even though the XB Niloofar font contains both. Therefore, you need to tell XeTeX to use a different font than XePersian uses with \settextfont. If you do not specify a different font, XePersian will be used for typesetting, which will of course substitute the numerals.

First, of course, you need to tell XeTeX there is another language besides Farsi. You should use polyglossia to set this up: \setotherlanguage[]{english}. Then you must tell polyglossia to use a different font for all English text with \newfontfamily\englishfont{XB Niloofar}. This can of course be the exact same typeface as your XePersian \settextfont, but this time, it will not go through XePersian and thusly use the correct number forms. In the document, use \textenglish{} or \begin{english} to switch to an English environment.

Using the above suggestions will yield the following MWE:

\documentclass[12pt,a4paper]{article}

\usepackage{polyglossia}

%\setdefaultlanguage[]{farsi}
\setotherlanguage[]{english}
\newfontfamily\englishfont{XB Niloofar}

\usepackage{enumerate}
\usepackage{xepersian}

\settextfont{XB Niloofar}


\begin{document}
\today

\textenglish{\today}
\end{document}

which gives this output:

XePersian output


On a side note, setting \setdefaultlanguage[]{farsi}, which would be normal practice with polyglossia, does not work, because it clashes with XePersian, therefore it is commented out here but you are welcome to delete it.

  • 1
    Thank you for the detailed explanation and the code. It did just what I wanted. – soroosh.strife Jun 7 '14 at 9:05
4

All you had to do was looking at xepersian documentation. No extra package required, no babel no polyglossia, etc.

\documentclass{article}
\usepackage{xepersian}
\begin{document}
\today

\latintoday
\end{document}

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.