6

I have not any problem with English LaTeX but today I wanted to write in Farsi (Persian) in LaTeX. I tried to write in Arabic instead but I faced an issue. I wrote this simple code:

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[Arabic]{babel}

\begin{document}
می خواهد
\end{document}

I saw this error:

  • Local config file arabic.cfg used
  • (C:\Users\me\AppData\Roaming\MiKTeX\2.9\tex\latex\arabi\arabic.cfg))) (untitled-2.aux) ("C:\Program Files (x86)\MiKTeX 2.9\tex\latex\base\ifthen.sty" ) ! Undefined control sequence. \farsiya l.7 می خواهد ?

However, I have not any problem when I am writing for example an Arabic word like "سلام". How can I fix this issue?

EDIT: I wrote the below code but again I got an error.

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[LAE,LFE]{fontenc}
\usepackage[farsi,arabic]{babel}
\TOCLanguage{farsi}

\title{این یک مقاله تست است}
\author{محمد}

\begin{document}

\selectlanguage{farsi}
\maketitle
\newpage
\tableofcontents
\section{مطالعه ی عمیق}
\subsection{آری!}

می خواهد باید برویم
$$E=m c^{2}$$
\end{document}

The error is:

! LaTeX Error: Command \farsiya unavailable in encoding LAE.

See the LaTeX manual or LaTeX Companion for explanation. Type H for immediate help. ...

l.4 ...C {\meem }\IeC {\farsiya }\IeC {\qaf }}}{1} ?

However, when I removed the \tableofcontents code, I got no error.

  • I'm confused, do you want to write in Farsi or Arabic? Because you said you wanted to try Farsi, but then wrote in Arabic. – Alenanno Jul 29 '16 at 18:20
  • please try with \usepackage[farsi]{babel} – touhami Jul 29 '16 at 18:24
  • @touhami I got this error: ! LaTeX Error: Encoding scheme `LAE' unknown. – Kiarash Jul 29 '16 at 18:25
  • @Alenanno I want to write in Farsi but I haven't found any Farsi packages for LaTeX so I tried to write in Arabic. – Kiarash Jul 29 '16 at 18:26
  • @KNP Should this be correct output using what you wrote? – Alenanno Jul 29 '16 at 18:27
5

A sample of arabic, farsi document with arabi package

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[LAE,LFE]{fontenc}
\usepackage[farsi,arabic]{babel}
\begin{document}
 سلام
\selectlanguage{farsi}
می خواهد
\end{document}

if you want farsi to be the main language

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[LAE,LFE]{fontenc}
\usepackage[farsi,arabic]{babel}
\TOCLanguage{farsi}
\begin{document}
\selectlanguage{farsi}
می خواهد
\end{document}

Update From arabi user-guide

Important note.

Nevertheless, since the Arabic part of the code was developed first and the Farsi part was developed after, we advise the user who wants to mix the two languages to call the option arabic always after farsi. And if you want Farsi to be the main document language, just issue the command

              \TOCLanguage{english} * 

and call the Farsi language whenever needed as shown below. This may save you a lot of trouble (concerning the choice of the fonts to be used by the system) until the system becomes more mature.

* I think the package's author means \TOCLanguage{farsi}


If one don't need arabic the solution is to use

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[LAE,LFE]{fontenc}
\usepackage[farsi]{babel}
\TOCLanguage{farsi}


\title{این یک مقاله تست است}
\author{محمد}

\begin{document}
\maketitle
\newpage
\tableofcontents
\section{مطالعه ی عمیق}
\subsection{آری!}

می خواهد باید برویم
$$E=m c^{2}$$

\end{document}

If one needs both languages he can works around by

{\makeatletter
\let\@arabic@R\@farsi@R
\tableofcontents}

Complet code

\documentclass{article}

\usepackage[utf8]{inputenc}
\usepackage[LAE,LFE]{fontenc}
\usepackage[farsi,arabic]{babel}
\TOCLanguage{farsi}


\title{این یک مقاله تست است}
\author{محمد}

\begin{document}

\selectlanguage{farsi}
\maketitle
\newpage
{\makeatletter
\let\@arabic@R\@farsi@R
\tableofcontents}
\section{مطالعه ی عمیق}
\subsection{آری!}

می خواهد باید برویم
$$E=m c^{2}$$

\end{document}
  • I get the same error when I use \maketitle. Don't you have any idea? – Kiarash Jul 29 '16 at 19:25
  • may be because \maketitle is before \selectlanguage{farsi} no? – touhami Jul 29 '16 at 20:09
  • But I still have the same problem with \tableofcontents. – Kiarash Jul 29 '16 at 20:24
  • if you don't need to mix arabic and farsi text in your document just remove arabic option from babel and remove \selectlanguage{farsi} if you need both languages you can try \usepackage[arabic,farsi]{babel} this solves your problem but this is not what the package's doc recommend. I will give this a try. – touhami Jul 30 '16 at 8:08
  • Thank you again! :) And a question. Is it okay to put everything between {\makeatletter \let\@arabic@R\@farsi@R? I did it and everything worked perfect! – Kiarash Jul 30 '16 at 10:33

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.