3

I'm wondering how to change the font in juste a single paragraph inside \begin{arab} environnement. My default font is setted like so \newfontfamily\arabicfont{Scheherazade}, i also use polyglossia package along with arabxetex.

  • Welcome to TeX SX! Probably defining another \newfontfamily\some_font_command{fontname} and switching to this other font with \some_font_command should be enough. – Bernard Dec 26 '17 at 11:34
  • tried so, but when applied inside a begin{arab} environnement the text is not parsed though. – Vutz Dec 26 '17 at 12:28
  • but when i use new font declaration with just arabic text pasted it work even inside arab environnement – Vutz Dec 26 '17 at 12:36
3

Here's two ways of doing it.

The easiest way is to put your paragraphs in separate arab environments then change the definition of \arabicfont before the arab environment then back again afterwards.

(BTW, I don't know what the Arabic says, I copied out of the araxetex manual.)

MWE 1:

\documentclass{article}
\usepackage{arabxetex}
\newfontfamily\scheherazadefont{Scheherazade}[Script=Arabic]
\newfontfamily\amirifont{Amiri}[Script=Arabic]
\let\arabicfont\scheherazadefont
\pagestyle{empty}
\begin{document}
\section*{Changing fonts between \texttt{arab} environments}
\begin{arab}
  'amruN, 'ibiluN, 'u_htuN, '"u_ht"uN, '"Uql"Id"Is, ra'suN, 'ar'asu,
  sa'ala, qara'a, bu'suN, 'ab'usuN, ra'ufa, ru'asA'u, bi'ruN, 'as'ilaTuN,
  ka'iba, qA'imuN, ri'AsaTuN, su'ila, samA'uN, barI'uN, sU'uN, bad'uN,
  ^say'uN, ^say'iN, ^say'aN, sA'ala, mas'alaTuN, saw'aTuN, _ha.tI'aTuN,
  jA'a, ridA'uN, ridA'aN, jI'a, radI'iN, sU'uN, .daw'uN, qay'iN, .zim'aN
  , yatasA'alUna, 'a`dA'akum, 'a`dA'ikum, 'a`dA'ukum maqrU'aT, mU'ibAt,
  taw'am, yas'alu, 'a.sdiq^A'uh_u, ya^g^I'u, s^U'ila
\end{arab}
\let\arabicfont\amirifont
\begin{arab}
  'amruN, 'ibiluN, 'u_htuN, '"u_ht"uN, '"Uql"Id"Is, ra'suN, 'ar'asu,
  sa'ala, qara'a, bu'suN, 'ab'usuN, ra'ufa, ru'asA'u, bi'ruN, 'as'ilaTuN,
  ka'iba, qA'imuN, ri'AsaTuN, su'ila, samA'uN, barI'uN, sU'uN, bad'uN,
  ^say'uN, ^say'iN, ^say'aN, sA'ala, mas'alaTuN, saw'aTuN, _ha.tI'aTuN,
  jA'a, ridA'uN, ridA'aN, jI'a, radI'iN, sU'uN, .daw'uN, qay'iN, .zim'aN
  , yatasA'alUna, 'a`dA'akum, 'a`dA'ikum, 'a`dA'ukum maqrU'aT, mU'ibAt,
  taw'am, yas'alu, 'a.sdiq^A'uh_u, ya^g^I'u, s^U'ila
\end{arab}
\let\arabicfont\scheherazadefont
\begin{arab}
  'amruN, 'ibiluN, 'u_htuN, '"u_ht"uN, '"Uql"Id"Is, ra'suN, 'ar'asu,
  sa'ala, qara'a, bu'suN, 'ab'usuN, ra'ufa, ru'asA'u, bi'ruN, 'as'ilaTuN,
  ka'iba, qA'imuN, ri'AsaTuN, su'ila, samA'uN, barI'uN, sU'uN, bad'uN,
  ^say'uN, ^say'iN, ^say'aN, sA'ala, mas'alaTuN, saw'aTuN, _ha.tI'aTuN,
  jA'a, ridA'uN, ridA'aN, jI'a, radI'iN, sU'uN, .daw'uN, qay'iN, .zim'aN
  , yatasA'alUna, 'a`dA'akum, 'a`dA'ikum, 'a`dA'ukum maqrU'aT, mU'ibAt,
  taw'am, yas'alu, 'a.sdiq^A'uh_u, ya^g^I'u, s^U'ila
\end{arab}
\end{document}

enter image description here

The other option is to define a command to change the font within the arab environment which deals with the encoding. I think the output is the same, but I've included screen shots just in case.

MWE 2:

\documentclass{article}
\usepackage{arabxetex}
\newfontfamily\arabicfont{Scheherazade}[Script=Arabic]
\newfontfamily\amirifont{Amiri}[Script=Arabic]
\makeatletter
\newcommand{\setarabfont}[1]{%
  #1
  \ifax@mode@defined%
    \ifx\@tempa\ax@mode@trans%
      \arabtex@codes\ax@trans@style%
      \addfontfeature{Mapping=arabtex-trans-\ax@trans@convention}%
    \else
      \ifx\@tempa\ax@mode@utf%
        \utf@fontfeature%
      \else
        \arabtex@codes%
        \addfontfeature{Mapping=arabtex-\@tempa}%
      \fi
    \fi
  \else
    \PackageWarning{arabxetex}{Mode \@tempa\ not defined, defaulting to \@ax@mode}%
    \arabtex@codes%
    \addfontfeature{Mapping=arabtex-\ax@mode}%
  \fi}
\makeatother
\pagestyle{empty}
\begin{document}
\section*{Changing fonts within the \texttt{arab} environment}
\begin{arab}
  'amruN, 'ibiluN, 'u_htuN, '"u_ht"uN, '"Uql"Id"Is, ra'suN, 'ar'asu,
  sa'ala, qara'a, bu'suN, 'ab'usuN, ra'ufa, ru'asA'u, bi'ruN, 'as'ilaTuN,
  ka'iba, qA'imuN, ri'AsaTuN, su'ila, samA'uN, barI'uN, sU'uN, bad'uN,
  ^say'uN, ^say'iN, ^say'aN, sA'ala, mas'alaTuN, saw'aTuN, _ha.tI'aTuN,
  jA'a, ridA'uN, ridA'aN, jI'a, radI'iN, sU'uN, .daw'uN, qay'iN, .zim'aN
  , yatasA'alUna, 'a`dA'akum, 'a`dA'ikum, 'a`dA'ukum maqrU'aT, mU'ibAt,
  taw'am, yas'alu, 'a.sdiq^A'uh_u, ya^g^I'u, s^U'ila

  \setarabfont{\amirifont}
  'amruN, 'ibiluN, 'u_htuN, '"u_ht"uN, '"Uql"Id"Is, ra'suN, 'ar'asu,
  sa'ala, qara'a, bu'suN, 'ab'usuN, ra'ufa, ru'asA'u, bi'ruN, 'as'ilaTuN,
  ka'iba, qA'imuN, ri'AsaTuN, su'ila, samA'uN, barI'uN, sU'uN, bad'uN,
  ^say'uN, ^say'iN, ^say'aN, sA'ala, mas'alaTuN, saw'aTuN, _ha.tI'aTuN,
  jA'a, ridA'uN, ridA'aN, jI'a, radI'iN, sU'uN, .daw'uN, qay'iN, .zim'aN
  , yatasA'alUna, 'a`dA'akum, 'a`dA'ikum, 'a`dA'ukum maqrU'aT, mU'ibAt,
  taw'am, yas'alu, 'a.sdiq^A'uh_u, ya^g^I'u, s^U'ila

  \setarabfont{\arabicfont}
  'amruN, 'ibiluN, 'u_htuN, '"u_ht"uN, '"Uql"Id"Is, ra'suN, 'ar'asu,
  sa'ala, qara'a, bu'suN, 'ab'usuN, ra'ufa, ru'asA'u, bi'ruN, 'as'ilaTuN,
  ka'iba, qA'imuN, ri'AsaTuN, su'ila, samA'uN, barI'uN, sU'uN, bad'uN,
  ^say'uN, ^say'iN, ^say'aN, sA'ala, mas'alaTuN, saw'aTuN, _ha.tI'aTuN,
  jA'a, ridA'uN, ridA'aN, jI'a, radI'iN, sU'uN, .daw'uN, qay'iN, .zim'aN
  , yatasA'alUna, 'a`dA'akum, 'a`dA'ikum, 'a`dA'ukum maqrU'aT, mU'ibAt,
  taw'am, yas'alu, 'a.sdiq^A'uh_u, ya^g^I'u, s^U'ila
\end{arab}
\end{document}

enter image description here

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.