2

Can you please add some lines to the following .cls file to support Arabic language?

\ProvidesClass{bandar-cv}[2012/04/30 CV class]
\NeedsTeXFormat{LaTeX2e}

\DeclareOption{print}{\def\@cv@print{}}
\DeclareOption*{%
  \PassOptionsToClass{\CurrentOption}{article}%
}
\ProcessOptions\relax
\LoadClass{article}


%%%%%%%%%%
% Colors %
%%%%%%%%%%

\RequirePackage{xcolor}

\definecolor{white}{RGB}{255,255,255}

\definecolor{darkgray}{HTML}{333333}
\definecolor{gray}{HTML}{4D4D4D}
\definecolor{lightgray}{HTML}{999999}

\definecolor{green}{HTML}{C2E15F}
\definecolor{orange}{HTML}{FDA333}
\definecolor{purple}{HTML}{D3A4F9}
\definecolor{red}{HTML}{FB4485}
\definecolor{blue}{HTML}{6CE0F1}

\ifdefined\@cv@print
  \colorlet{green}{gray}
  \colorlet{orange}{gray}
  \colorlet{purple}{gray}
  \colorlet{brown}{gray}
  \colorlet{red}{gray}
  \colorlet{blue}{gray}
  \colorlet{fillheader}{white}
  \colorlet{header}{gray}
\else
  \colorlet{fillheader}{gray}
  \colorlet{header}{white}
\fi
\colorlet{textcolor}{gray}
\colorlet{headercolor}{gray}

%%%%%%%%%
% Fonts %
%%%%%%%%%
%\RequirePackage[arabic,english]

\RequirePackage[quiet]{fontspec}
\RequirePackage[math-style=TeX,vargreek-shape=unicode]{unicode-math}

\newfontfamily\bodyfont[]{Helvetica Neue}
\newfontfamily\thinfont[]{Helvetica Neue UltraLight}
\newfontfamily\headingfont[]{Helvetica Neue Condensed Bold}

\defaultfontfeatures{Mapping=tex-text}
\setmainfont[Mapping=tex-text, Color=textcolor]{Helvetica Neue Light}

%\setmathfont{XITS Math}

%%%%%%%%%%
% Header %
%%%%%%%%%%

\RequirePackage{tikz}

\newcommand{\rolefont}{%
  \fontsize{14pt}{24pt}\selectfont%
  \thinfont%
  \color{white}%
}

\newcommand{\header}[3]{%
  \begin{tikzpicture}[remember picture,overlay]
    \node [rectangle, fill=fillheader, anchor=north, minimum width=\paperwidth, minimum height=4cm] (box) at (current page.north){};
    \node [anchor=center] (name) at (box) {%
      \fontsize{40pt}{72pt}\color{header}%
      {\thinfont #1}{\bodyfont  #2}
    };
    \node [anchor=north] at (name.south) {%
      \fontsize{14pt}{24pt}\color{header}%
      \thinfont #3%
    };
  \end{tikzpicture}
  \vspace{2.5cm}
  \vspace{-2\parskip}
}


%%%%%%%%%%%%%
% Structure %
%%%%%%%%%%%%%
\RequirePackage{parskip}

\newcounter{colorCounter}
\def\@sectioncolor#1#2#3{%
  {%
    \color{%
      \ifcase\value{colorCounter}%
        blue\or%
        red\or%
        orange\or%
        green\or%
        purple\or%
        brown\else%
        headercolor\fi%
    } #1#2#3%
  }%
  \stepcounter{colorCounter}%
}

\renewcommand{\section}[1]{
  \par\vspace{\parskip}
  {%
    \LARGE\headingfont\color{headercolor}%
    \@sectioncolor #1%
  }
  \par\vspace{\parskip}
}

\renewcommand{\subsection}[1]{
  \par\vspace{.5\parskip}%
  {\Large\headingfont\color{headercolor} #1}
  \par\vspace{.25\parskip}%
}

\renewcommand{\subsubsection}[2]{
  \par\vspace{.5\parskip}%
  {\Large\headingfont\color{headercolor} #2}
  \par\vspace{.25\parskip}%
}

\pagestyle{empty}


%%%%%%%%%%%%%%%%%%%%
% List environment %
%%%%%%%%%%%%%%%%%%%%

\setlength{\tabcolsep}{0pt}
\newenvironment{entrylist}{%
  \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}ll}
}{%
  \end{tabular*}
}
\renewcommand{\bfseries}{\headingfont\color{headercolor}}
\newcommand{\entry}[4]{%
  #1&\parbox[t]{11.8cm}{%
    \textbf{#2}%
    \hfill%
    {\footnotesize\addfontfeature{Color=lightgray} #3}\\%
    #4\vspace{\parsep}%
  }\\}


%%%%%%%%%%%%%%
% Side block %
%%%%%%%%%%%%%%

\RequirePackage[absolute,overlay]{textpos}
\setlength{\TPHorizModule}{1cm}
\setlength{\TPVertModule}{1cm}
\newenvironment{aside}{%
  \let\oldsection\section
  \renewcommand{\section}[1]{
    \par\vspace{\baselineskip}{\Large\headingfont\color{headercolor} ##1}
  }
  \begin{textblock}{3.6}(1.5, 4.33)
  \begin{flushright}
  \obeycr
}{%
  \restorecr
  \end{flushright}
  \end{textblock}
  \let\section\oldsection
}

%%%%%%%%%%%%%%%%
% Bibliography %
%%%%%%%%%%%%%%%%

\RequirePackage[style=verbose, maxnames=99, sorting=ydnt]{biblatex}

\DeclareFieldFormat[article]{title}{#1\par}
\DeclareFieldFormat[book]{title}{#1\par}
\DeclareFieldFormat[inproceedings]{title}{#1\par}
\DeclareFieldFormat[misc]{title}{#1\par}
\DeclareFieldFormat[report]{title}{#1\par}

\DeclareBibliographyDriver{article}{%
  \printfield{title}%
  \newblock%
  \printnames{author}%
  \par%
  \newblock%
  {%
    \footnotesize\addfontfeature{Color=lightgray}\itshape%
    \usebibmacro{journal+issuetitle}%
    \setunit{\space}%
    \printfield{pages}%
    \newunit%
    \printlist{publisher}%
    \setunit*{\addcomma\space}%
    \printfield{year}%
    \newunit%
  }
  \par\vspace{0.3\baselineskip}
}

\DeclareBibliographyDriver{book}{%
  \printfield{title}%
  \newblock%
  \printnames{author}%
  \par%
  \newblock%
  {%
    \footnotesize\addfontfeature{Color=lightgray}\itshape%
    \printlist{publisher}%
    \setunit*{\addcomma\space}%
    \printfield{note}%
    \setunit*{\addcomma\space}%
    \printfield{year}%
    \setunit{\addcomma\space}%
    \printlist{location}%
    \newunit%
  }
  \par\vspace{0.3\baselineskip}
}


\DeclareBibliographyDriver{inproceedings}{%
  \printfield{title}%
  \newblock%
  \printnames{author}%
  \par%
  \newblock%
  {%
    \footnotesize\addfontfeature{Color=lightgray}%
    \printfield{booktitle}%
    \setunit{\addcomma\space}%
    \printfield{year}%
    \setunit{\addcomma\space}%
    \printlist{location}%
    \newunit%
  }
  \par\vspace{0.3\baselineskip}
}

\DeclareBibliographyDriver{misc}{%
  \printfield{title}%
  \newblock%
  \printnames{author}%
  \par%
  \newblock%
  {%
    \footnotesize\addfontfeature{Color=lightgray}\itshape%
    \printfield{booktitle}%
    \setunit*{\addcomma\space}%
    \printfield{note}%
    \setunit*{\addcomma\space}%
    \printfield{year}%
    \setunit{\addcomma\space}%
    \printlist{location}%
    \newunit%
  }
  \par\vspace{0.3\baselineskip}
}

\DeclareBibliographyDriver{report}{%
  \printfield{title}%
  \newblock%
  \printnames{author}%
  \par%
  \newblock%
  {%
    \footnotesize\addfontfeature{Color=lightgray}\itshape%
    \printfield{type}%
    \setunit{\space}%
    \printfield{number}%
    \setunit{\addcomma\space}%
    \printfield{year}%
    \newunit%
  }
  \par\vspace{0.3\baselineskip}
}

\DeclareNameFormat{author}{%
  \small\addfontfeature{Color=lightgray}%
  \ifblank{#3}{}{#3\space}#1%
  \ifthenelse{\value{listcount}<\value{liststop}}
    {\addcomma\space}
    {}%
}

\defbibheading{bibheading}[\bibname]{%
   \subsubsection*{#1}
   \markboth{#1}{#1}
}

\newcommand{\printbibsection}[2]{
  \begin{refsection}
    \nocite{*}
    \printbibliography[sorting=chronological, type={#1}, title={#2}, heading=bibheading]
  \end{refsection}
}

\DeclareSortingScheme{chronological}{
  \sort[direction=descending]{\field{year}}
  \sort[direction=descending]{\field{month}}
}



%%%%%%%%%%%%%%%%
% Other tweaks %
%%%%%%%%%%%%%%%%

\RequirePackage[left=6.1cm,top=2cm,right=1.5cm,bottom=2.5cm,nohead,nofoot]{geometry}
\RequirePackage{hyperref}
\hypersetup{
    colorlinks=false,       
    linkcolor=red,          
    citecolor=red,        
    filecolor=red,      
    urlcolor = red}

% A fix for \href{}{} colors not working with fontspec
\makeatletter
\def\HyColor@@@@UseColor#1\@nil{\addfontfeatures{Color=#1}}
\makeatother
  • \newfontfamily\arabicfont[Script=Arabic]{Amiri} to use the arabic font you need {\arabicfont نص عربي } – Salim Bou Jul 30 '18 at 18:13
  • thanks Salim but in which section to be added. I have tried many solutions but no chance. That's why i included the whole file to mention where could be included. – user3653683 Jul 30 '18 at 18:16
  • After \RequirePackage[quiet]{fontspec}, If you are using xelatex you need also to add bidi package for right to left text – Salim Bou Jul 30 '18 at 18:19
  • Can you please extract that section and add it. Regarding bidi , what does it mean and where exactly to add it. thanks in advance – user3653683 Jul 30 '18 at 18:35
1

To add arabic in your class you need first an arabic font this can be done with fontspec

\newfontfamily\arabicfont[Script=Arabic]{Amiri}

You need also macros to change text direction provided by the bidi package, for short right to left text you can use \RL{arabic text}, or the environment RTL for long text

\begin{RTL}
arabic text ......
\end{RTL}

  1. Add arabic font in the class file

    \ProvidesClass{bandar-cv}[2012/04/30 CV class]
    \NeedsTeXFormat{LaTeX2e}
    
    \DeclareOption{print}{\def\@cv@print{}}
    \DeclareOption*{%
      \PassOptionsToClass{\CurrentOption}{article}%
    }
    \ProcessOptions\relax
    \LoadClass{article}
    
    
    %%%%%%%%%%
    % Colors %
    %%%%%%%%%%
    
    \RequirePackage{xcolor}
    
    \definecolor{white}{RGB}{255,255,255}
    
    \definecolor{darkgray}{HTML}{333333}
    \definecolor{gray}{HTML}{4D4D4D}
    \definecolor{lightgray}{HTML}{999999}
    
    \definecolor{green}{HTML}{C2E15F}
    \definecolor{orange}{HTML}{FDA333}
    \definecolor{purple}{HTML}{D3A4F9}
    \definecolor{red}{HTML}{FB4485}
    \definecolor{blue}{HTML}{6CE0F1}
    
    \ifdefined\@cv@print
      \colorlet{green}{gray}
      \colorlet{orange}{gray}
      \colorlet{purple}{gray}
      \colorlet{brown}{gray}
      \colorlet{red}{gray}
      \colorlet{blue}{gray}
      \colorlet{fillheader}{white}
      \colorlet{header}{gray}
    \else
      \colorlet{fillheader}{gray}
      \colorlet{header}{white}
    \fi
    \colorlet{textcolor}{gray}
    \colorlet{headercolor}{gray}
    
    %%%%%%%%%
    % Fonts %
    %%%%%%%%%
    %\RequirePackage[arabic,english]
    
    \RequirePackage[quiet]{fontspec}
    \newfontfamily\arabicfont[Script=Arabic]{Amiri} % <-- add arabic font 
    \RequirePackage[math-style=TeX,vargreek-shape=unicode]{unicode-math}
    
    \newfontfamily\bodyfont[]{Helvetica Neue}
    \newfontfamily\thinfont[]{Helvetica Neue UltraLight}
    \newfontfamily\headingfont[]{Helvetica Neue Condensed Bold}
    
    \defaultfontfeatures{Mapping=tex-text}
    \setmainfont[Mapping=tex-text, Color=textcolor]{Helvetica Neue Light}
    
    %\setmathfont{XITS Math}
    
    %%%%%%%%%%
    % Header %
    %%%%%%%%%%
    
    \RequirePackage{tikz}
    
    \newcommand{\rolefont}{%
      \fontsize{14pt}{24pt}\selectfont%
      \thinfont%
      \color{white}%
    }
    
    \newcommand{\header}[3]{%
      \begin{tikzpicture}[remember picture,overlay]
        \node [rectangle, fill=fillheader, anchor=north, minimum 
    width=\paperwidth, minimum height=4cm] (box) at (current page.north){};
        \node [anchor=center] (name) at (box) {%
          \fontsize{40pt}{72pt}\color{header}%
          {\thinfont #1}{\bodyfont  #2}
        };
        \node [anchor=north] at (name.south) {%
          \fontsize{14pt}{24pt}\color{header}%
          \thinfont #3%
        };
      \end{tikzpicture}
      \vspace{2.5cm}
      \vspace{-2\parskip}
    }
    
    
    %%%%%%%%%%%%%
    % Structure %
    %%%%%%%%%%%%%
    \RequirePackage{parskip}
    
    \newcounter{colorCounter}
    \def\@sectioncolor#1#2#3{%
      {%
        \color{%
          \ifcase\value{colorCounter}%
            blue\or%
            red\or%
            orange\or%
            green\or%
            purple\or%
            brown\else%
            headercolor\fi%
        } #1#2#3%
      }%
      \stepcounter{colorCounter}%
    }
    
    \renewcommand{\section}[1]{
      \par\vspace{\parskip}
      {%
        \LARGE\headingfont\color{headercolor}%
        \@sectioncolor #1%
      }
      \par\vspace{\parskip}
    }
    
    \renewcommand{\subsection}[1]{
      \par\vspace{.5\parskip}%
      {\Large\headingfont\color{headercolor} #1}
      \par\vspace{.25\parskip}%
    }
    
    \renewcommand{\subsubsection}[2]{
      \par\vspace{.5\parskip}%
      {\Large\headingfont\color{headercolor} #2}
      \par\vspace{.25\parskip}%
    }
    
    \pagestyle{empty}
    
    
    %%%%%%%%%%%%%%%%%%%%
    % List environment %
    %%%%%%%%%%%%%%%%%%%%
    
    \setlength{\tabcolsep}{0pt}
    \newenvironment{entrylist}{%
      \begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}ll}
    }{%
      \end{tabular*}
    }
    \renewcommand{\bfseries}{\headingfont\color{headercolor}}
    \newcommand{\entry}[4]{%
      #1&\parbox[t]{11.8cm}{%
        \textbf{#2}%
        \hfill%
        {\footnotesize\addfontfeature{Color=lightgray} #3}\\%
        #4\vspace{\parsep}%
      }\\}
    
    
    %%%%%%%%%%%%%%
    % Side block %
    %%%%%%%%%%%%%%
    
    \RequirePackage[absolute,overlay]{textpos}
    \setlength{\TPHorizModule}{1cm}
    \setlength{\TPVertModule}{1cm}
    \newenvironment{aside}{%
      \let\oldsection\section
      \renewcommand{\section}[1]{
        \par\vspace{\baselineskip}{\Large\headingfont\color{headercolor} ##1}
      }
      \begin{textblock}{3.6}(1.5, 4.33)
      \begin{flushright}
      \obeycr
    }{%
      \restorecr
      \end{flushright}
      \end{textblock}
      \let\section\oldsection
    }
    
    %%%%%%%%%%%%%%%%
    % Bibliography %
    %%%%%%%%%%%%%%%%
    
    \RequirePackage[style=verbose, maxnames=99, sorting=ydnt]{biblatex}
    
    \DeclareFieldFormat[article]{title}{#1\par}
    \DeclareFieldFormat[book]{title}{#1\par}
    \DeclareFieldFormat[inproceedings]{title}{#1\par}
    \DeclareFieldFormat[misc]{title}{#1\par}
    \DeclareFieldFormat[report]{title}{#1\par}
    
    \DeclareBibliographyDriver{article}{%
      \printfield{title}%
      \newblock%
      \printnames{author}%
      \par%
      \newblock%
      {%
        \footnotesize\addfontfeature{Color=lightgray}\itshape%
        \usebibmacro{journal+issuetitle}%
        \setunit{\space}%
        \printfield{pages}%
        \newunit%
        \printlist{publisher}%
        \setunit*{\addcomma\space}%
        \printfield{year}%
        \newunit%
      }
      \par\vspace{0.3\baselineskip}
    }
    
    \DeclareBibliographyDriver{book}{%
      \printfield{title}%
      \newblock%
      \printnames{author}%
      \par%
      \newblock%
      {%
        \footnotesize\addfontfeature{Color=lightgray}\itshape%
        \printlist{publisher}%
        \setunit*{\addcomma\space}%
        \printfield{note}%
        \setunit*{\addcomma\space}%
        \printfield{year}%
        \setunit{\addcomma\space}%
        \printlist{location}%
        \newunit%
      }
      \par\vspace{0.3\baselineskip}
    }
    
    
    \DeclareBibliographyDriver{inproceedings}{%
      \printfield{title}%
      \newblock%
      \printnames{author}%
      \par%
      \newblock%
      {%
        \footnotesize\addfontfeature{Color=lightgray}%
        \printfield{booktitle}%
        \setunit{\addcomma\space}%
        \printfield{year}%
        \setunit{\addcomma\space}%
        \printlist{location}%
        \newunit%
      }
      \par\vspace{0.3\baselineskip}
    }
    
    \DeclareBibliographyDriver{misc}{%
      \printfield{title}%
      \newblock%
      \printnames{author}%
      \par%
      \newblock%
      {%
        \footnotesize\addfontfeature{Color=lightgray}\itshape%
        \printfield{booktitle}%
        \setunit*{\addcomma\space}%
        \printfield{note}%
        \setunit*{\addcomma\space}%
        \printfield{year}%
        \setunit{\addcomma\space}%
        \printlist{location}%
        \newunit%
      }
      \par\vspace{0.3\baselineskip}
    }
    
    \DeclareBibliographyDriver{report}{%
      \printfield{title}%
      \newblock%
      \promma\space}
        {}%
    }
    
    \defbibheading{bibheading}[\bibname]{%
       \subsubsection*{#1}
       \markboth{#1}{#1}
    }
    
    \newcommand{\printbibsection}[2]{
      \begin{refsection}
        \nocite{*}
        \printbibliography[sorting=chronological, type={#1}, title={#2}, 
     heading=bibheading]
      \end{refsection}
    }
    
    \DeclareSortingScheme{chronological}{
      \sort[direction=descending]{\field{year}}
      \sort[direction=descending]{\field{month}}
    }
    
    
    
    %%%%%%%%%%%%%%%%
    % Other tweaks %
    %%%%%%%%%%%%%%%%
    
    \RequirePackage[left=6.1cm,top=2cm,right=1.5cm,bottom=2.5cm,nohead,nofoot] 
    {geometry}
    \RequirePackage{hyperref}
    \hypersetup{
        colorlinks=false,       
        linkcolor=red,          
        citecolor=red,        
        filecolor=red,      
        urlcolor = red}
    
    % A fix for \href{}{} colors not working with fontspec
    \makeatletter
    \def\HyColor@@@@UseColor#1\@nil{\addfontfeatures{Color=#1}}
    \makeatother
    
  2. Add bidi package in your tex file for right to left writing ( bidi should be the last package that you load)

    \documentclass{bandar-cv}
    % add your packages here 
    \usepackage{bidi}
    
    \begin{document}
    
    % write short arabic text with 
    \RL{\arabicfont   نص عربي قصير}
    
    % write long arabic text with 
    
    \begin{RTL}
    \arabicfont
    نص عربي طويل به العديد من الأسطر 
    ........
    ........ 
    \end{RTL} 
    
    \end{document}
    
1

I would rather use polyglossia and Arabic numerals (I don't know why one would use Latin numerals and months in Arabic, you can see the difference below):

\documentclass{article} \usepackage{polyglossia} 
\setotherlanguage[locale=mashriq]{arabic} %locale=maghrib (default) 
\setmainlanguage{english}

\usepackage{fontspec} 
\newfontfamily\arabicfont[Script=Arabic,Mapping=arabicdigits]{Amiri} % <-- add arabic font % add your packages here  \usepackage{bidi}

\begin{document}

% write short arabic text with  \RL{\arabicfont   نص عربي قصير}

% write long arabic text with 

\begin{RTL} \arabicfont 123456789 نص عربي طويل به العديد من الأسطر  ........ ........  \today  \end{RTL} 

\begin{Arabic} 123456789 نص عربي طويل به العديد من الأسطر 

\today \end{Arabic}

\end{document}

arabic and polyglossia

Change \usepackage to \RequirePackage in your .cls file and you're ready to go.

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.