3

I'm using Xepersian package in Latex. I'm typing my whole text in "XBZar" font, and digits (numbers) in "Yas" font. My concern here is the chapter/section/subsection labels.

So, by default the whole chapter/section/subsection labels are in "XBZar" font (including the text and numbering, or anything you call them). I'd like to only and only change these labels numbering font to "Yas".

Here is an example of what I've currently achived, and what I want to get. enter image description here And here is a minimal example:

    \documentclass{book}
    \usepackage{caption}
    \usepackage{xepersian}

    \settextfont[Scale=1]{XB Zar}
    \setdigitfont[Scale=1]{Yas}
    \setlatintextfont[Scale=.98]{Times New Roman}

    \defpersianfont\Yas{Yas}
    \DeclareCaptionFormat{myformat}{{\Yas #1}#2#3}
    \captionsetup{format=myformat}

    \begin{document}

    \chapter{مقدمه (\lr{Preface})}
    \thispagestyle{empty}
    \section{فصل اول (\lr{First Section})}
    سلام، این یک عدد است $10.004$.
    \subsection{بخش اول}
    \flushleft
    \lr{So, I need the chapter/section/subsection numbering font to be "Yas" instead of "XBZar". I should stress that ONLY numbering not the whole label.}

    \end{document}
  • Welcome to TeX.SX!, can you help us to help you with a minimal example that reproduces the problem – Salim Bou Jul 20 '16 at 16:25
  • I'll do so, but I thought it was not really needed. There is not a problem per say, It's actually a matter of what i need to do :) – Ahama Jul 20 '16 at 18:02
  • To simplify copy-paste code and work on it – Salim Bou Jul 20 '16 at 18:11
1

You can modify the format of \thechapter , \thesection and \thesubsection to obtain the desired font for headings numbers with this trick

\let\oldthechapter\thechapter
\let\oldthesection\thesection
\let\oldthesubsection\thesubsection

\renewcommand{\thechapter}{\begingroup \Yas \oldthechapter \endgroup}
\renewcommand{\thesection}{\begingroup \Yas \oldthesection \endgroup}
\renewcommand{\thesubsection}{\begingroup \Yas \oldthesubsection \endgroup}

Code

\documentclass{book}
\usepackage{caption}
\usepackage{xepersian}

\settextfont[Scale=1]{XB Zar}
\setdigitfont[Scale=1]{Yas}
\setlatintextfont[Scale=.98]{Times New Roman}

\defpersianfont\Yas{Yas}
\DeclareCaptionFormat{myformat}{{\Yas #1}#2#3}
\captionsetup{format=myformat}

\let\oldthechapter\thechapter
\let\oldthesection\thesection
\let\oldthesubsection\thesubsection

\renewcommand{\thechapter}{\begingroup \Yas \oldthechapter \endgroup}
\renewcommand{\thesection}{\begingroup \Yas \oldthesection \endgroup}
\renewcommand{\thesubsection}{\begingroup \Yas \oldthesubsection \endgroup}

\begin{document}

\chapter{مقدمه (\lr{Preface})}
\thispagestyle{empty}
\section{فصل اول (\lr{First Section})}
سلام، این یک عدد است $10.004$.
\subsection{بخش اول}

\end{document}

Output

enter image description here

  • Can I change the page numbering fonts with the same trick? I also need to change the caption numbering fonts, such as image captions and table captions. :) should I post this as a new question? – Ahama Jul 20 '16 at 19:54
  • Same method \let\oldthepage\thepage then \renewcommand{\thepage}{\begingroup \Yas \oldthepage \endgroup} – Salim Bou Jul 20 '16 at 19:57
  • Sorry for being so questionable, But I also need to change the caption numbering fonts, such as image captions and table captions. What are the commands? – Ahama Jul 20 '16 at 20:05

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.