21

I'm using TeXlive (2009-7) on Ubuntu 10.04. I've installed texlive-lang-arabic and I can't find out how should I compose the preamble to be able to use it. The babel's documentation I've found in the Internet http://www.tug.org/texlive/Contents/live/texmf-dist/doc/generic/babel/ is probably out-of-date (September 2009), because Arabic is not mentioned as supported language, and aptitude show texlive-lang-arabic gives as the result:

This package includes the following CTAN packages: 
 arabi -- (La)TeX support for Arabic and Farsi, compliant with Babel.
 arabtex -- Macros and fonts for typesetting Arabic.
 hyphen-arabic --
 hyphen-farsi --

I could't find any documentation of the newly installed package. I'm even not sure if the package allows what I want, i.e. writing using Arabic script directly and not, as it was the case with arabtex, in transcription (and Arabic script was appearing only in output).

If I've missed some relevant information, I can complete my question.

UPDATE

Thanks for everybody. First of all, I've tried to apply Mustail's solution. I've composed the preamble based on his example (mostly the same, just without Persian). I run for it XeLaTeX. Compilation failed, the .log file said that I need xetex package. I had texlive-xetex installed and xetex is mentioned as part of it. Searching further in the Internet I've found that all information about XeLaTeX I can find not match with my LaTeX installation.

I've decided to try the solution proposed by Caramdir and I've made a new TeX Live installation following the instruction in the link. I can't compile any file as I don't have LaTeX nor pdfLaTeX installed and I don't want to install it in other way I've installed TeX Live. In the documentation about installation I've found that I should run tlmgr to manage my LaTeX installation, but I can't do it, command not found.

I have still previous installation of TeX Live on one computer, I can test both (by aptitude and downloaded from tug.org).

Maybe I should post another question concerning installation of TeX Live from tug.org, but I try first here, maybe it's not a real problem but just an omission of something obvious from my part.

UPDATE 2

I was trying to compile Mehro's exemple document (using instalation of LaTeX from Ubuntu packages), without succes. This is the terminal's output (starting from first warning):

Package polyglossia Warning: No hyphenation patterns were loaded for `arabic'
(polyglossia)                I will use the patterns loaded for \language=0
(polyglossia)                instead on input line 7.

) (./mehro.aux)
kpathsea: Running mktextfm 
/usr/share/texmf/web2c/mktexnam: Could not map source abbreviation 6 for 600.
/usr/share/texmf/web2c/mktexnam: Need to update /usr/share/texmf-texlive/fonts/map/fontname/special.map?
mktextfm: Running mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input 
This is METAFONT, Version 2.718281 (TeX Live 2009/Debian)


kpathsea: Running mktexmf 
! I can't find file `'.
<*> \mode:=ljfour; mag:=1; nonstopmode; input

Please type another input file name
! Emergency stop.
<*> \mode:=ljfour; mag:=1; nonstopmode; input

Transcript written on mfput.log.
grep: .log: No such file or directory
mktextfm: `mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input ' failed to make .tfm.
kpathsea: Appending font creation commands to missfont.log.

! Font \zf@basefont="" not loadable: Metric (TFM) file or installed font not fo
und.
<to be read again> 
                   \zf@family@fontdeflmr 
l.15 ...abic: \textarabic{السلام عليكم}

? ^C! Interruption.
<argument> ...@family@fontdef\f@family \endcsname 
                                                  " at \f@size pt \zf@check@...

I had a look in Polyglossia documentation, but I didn't find there nothing what could help me to compile document.

It seems I have more general problem with fonts for XeTeX. Fontspec documentation opens but should lack of some fonts as I see white gaps in some places. The termial output is quite long and consist almost of 'error' messages. This are just few lines of it:

Error: Missing language pack for 'Adobe-Japan1' mapping 
Error: Unknown font tag 'F5.1' 
Error (24124): No font in show 
Error: Unknown font tag 'F5.1' 

UPDATE 3

I have maneged to install Linux Liberation O and Scheherazade via Ubuntu Sotware Center (although I still can't understand why I could't do that via Synaptic nor aptitude...), so Meho's and Alan's exemple files are compiled succesfully.

Documentation became readable after installation of poppeler data. I'm still not able to compile Mustail's exemple file, but having acces to documentation I can try to solve it.

Thanks a lot for everybody for your help.

maria
  • 925
  • 2
  • 8
  • 18
  • I think you should post a separate question about installing. A good guide will also be useful to others. – Caramdir Mar 01 '11 at 21:50
  • Your first problem might be related to http://tex.stackexchange.com/questions/652/xetex-not-working-on-ubuntu-10-04 – Caramdir Mar 01 '11 at 21:52
  • @Caramdir: Thanks a lot for the link and advice. Unfortunatly, the link didn't solve the problem. I have had already lmodern package installed, still no output. I have now also information about problems with fonts: Latin Modern Sans not found. I've commented the line and than compilation stops on `\begin{document}... Actually I've decided to try to install from the source you've mentioned becouse I was not able to find out where I have installed fonts... I'll post a separate question about second problem. – maria Mar 01 '11 at 22:21

4 Answers4

28

I usually use XeLaTeX with Polyglossia. A quick example:

\documentclass{book}

\usepackage{setspace}

\usepackage{fontspec}
\usepackage{polyglossia}

\setmainlanguage{english}
\setotherlanguage{arabic}

\newfontfamily\arabicfont[Script=Arabic,Scale=1.1]{Scheherazade}

\begin{document}

Some latin text and inline arabic: \textarabic{السلام عليكم}

And for larger blocks of text you can use Arabic environment:

\begin{Arabic}

العربية أكثر لغات المجموعة السامية متحدثينَ، وإحدى أكثر اللغات انتشارًا في العالم، يتحدثها أكثر من 422 مليون نسمة،1 ويتوزع متحدثوها في المنطقة المعروفة باسم الوطن العربي، بالإضافة إلى العديد من المناطق الأخرى المجاورة كالأحواز وتركيا وتشاد ومالي السنغال وإرتيريا. اللغة العربية ذات أهمية قصوى لدى المسلمين، فهي لغة مقدسة (لغة القرآن)، ولا تتم الصلاة (وعبادات أخرى) في الإسلام إلا بإتقان بعض من كلماتها. العربية هي أيضا لغة شعائرية رئيسية لدى عدد من الكنائس المسيحية في الوطن العربي، كما كتبت بها الكثير من أهم الأعمال الدينية والفكرية اليهودية في العصور الوسطى. وأثّر انتشار الإسلام، وتأسيسه دولاً، في ارتفاع مكانة اللغة العربية، وأصبحت لغة السياسة والعلم والأدب لقرون طويلة في الأراضي التي حكمها المسلمون، وأثرت العربية، تأثيرًا مباشرًا أو غير مباشر على كثير من اللغات الأخرى في العالم الإسلامي، كالتركية والفارسية والكردية والأوردية والماليزية والإندونيسية والألبانية وبعض اللغات الإفريقية الأخرى مثل الهاوسا والسواحيلية، وبعض اللغات الأوروبية وخاصةً المتوسطية منها كالإسبانية والبرتغالية والمالطية والصقلية. كما أنها تدرس بشكل رسمي أو غير رسمي في الدول الإسلامية والدول الإفريقية المحاذية للوطن العربي.

العربية لغة رسمية في كل دول الوطن العربي إضافة إلى كونها لغة رسمية في تشاد وإريتيريا وإسرائيل. وهي إحدى اللغات الرسمية الست في منظمة الأمم المتحدة.

تحتوي العربية على 28 حرفًا مكتوبًا. ويرى بعض اللغويين أنه يجب إضافة حرف الهمزة إلى حروف العربية، ليصبح عدد الحروف 29. تكتب العربية من اليمين إلى اليسار - مثلها اللغة الفارسية والعبرية وعلى عكس الكثير من اللغات العالمية - ومن أعلى الصفحة إلى أسفلها.

\end{Arabic}

To get even spacing between lines, you can use \verb|\lineskiplimit| command (locally or globally, preferably locally) and set spacing with \verb|setspace| or \verb|leading| package to avoid possible overlapping:

\begin{Arabic}
\lineskiplimit=-1000pt
\setstretch{1.2}

العربية أكثر لغات المجموعة السامية متحدثينَ، وإحدى أكثر اللغات انتشارًا في العالم، يتحدثها أكثر من 422 مليون نسمة،1 ويتوزع متحدثوها في المنطقة المعروفة باسم الوطن العربي، بالإضافة إلى العديد من المناطق الأخرى المجاورة كالأحواز وتركيا وتشاد ومالي السنغال وإرتيريا. اللغة العربية ذات أهمية قصوى لدى المسلمين، فهي لغة مقدسة (لغة القرآن)، ولا تتم الصلاة (وعبادات أخرى) في الإسلام إلا بإتقان بعض من كلماتها. العربية هي أيضا لغة شعائرية رئيسية لدى عدد من الكنائس المسيحية في الوطن العربي، كما كتبت بها الكثير من أهم الأعمال الدينية والفكرية اليهودية في العصور الوسطى. وأثّر انتشار الإسلام، وتأسيسه دولاً، في ارتفاع مكانة اللغة العربية، وأصبحت لغة السياسة والعلم والأدب لقرون طويلة في الأراضي التي حكمها المسلمون، وأثرت العربية، تأثيرًا مباشرًا أو غير مباشر على كثير من اللغات الأخرى في العالم الإسلامي، كالتركية والفارسية والكردية والأوردية والماليزية والإندونيسية والألبانية وبعض اللغات الإفريقية الأخرى مثل الهاوسا والسواحيلية، وبعض اللغات الأوروبية وخاصةً المتوسطية منها كالإسبانية والبرتغالية والمالطية والصقلية. كما أنها تدرس بشكل رسمي أو غير رسمي في الدول الإسلامية والدول الإفريقية المحاذية للوطن العربي.

العربية لغة رسمية في كل دول الوطن العربي إضافة إلى كونها لغة رسمية في تشاد وإريتيريا وإسرائيل. وهي إحدى اللغات الرسمية الست في منظمة الأمم المتحدة.

تحتوي العربية على 28 حرفًا مكتوبًا. ويرى بعض اللغويين أنه يجب إضافة حرف الهمزة إلى حروف العربية، ليصبح عدد الحروف 29. تكتب العربية من اليمين إلى اليسار - مثلها اللغة الفارسية والعبرية وعلى عكس الكثير من اللغات العالمية - ومن أعلى الصفحة إلى أسفلها.

\end{Arabic}

\end{document}
Meho R.
  • 1,777
  • @Mehro Thanks a lot. Do you use also polyglossia for typesetting a document in one language? In any case, it will be useful for me for multi-languages documents, the day I manage to make it working :) Could you tell me what kind of installation of LaTeX do you use? More details in the body of question. – maria Mar 01 '11 at 21:54
  • 3
    Consider polyglossia "babel for XeLaTeX" which means you should use it whenever using XeLaTeX, even if there's only one language. As for TeXLive installation, there is no tlmgr if TL is installed from repos. But if you install it from DVD or using netinstall, it'll be there. – Meho R. Mar 02 '11 at 02:37
  • @Meho I was trying to compile your document - failed... As for tlmgr, I was trying to run it in installation from TUG, but it seems there is more general problem, it doesn't work at all (I've asked separate question for it), so for the moment I'm trying to run XeLaTeX on installation from repos. The result is in main question under UPDATE 2. Thanks – maria Mar 03 '11 at 09:02
  • @Maria, regarding fonts, for running this example you only need Scheherazade font installed. You can find it in Ubuntu's repos, or you can download it from sil.org and put it into ~/.fonts directory (this is shortcut for /home/your_username/.fonts). – Meho R. Mar 03 '11 at 12:08
  • @Meho But I don't have such a directory... In ~/ I have only .fontconfig under .f. Looking for (using locate) *.fonts* I can find only two files fonts.gz in /usr/share/doc/console-setup. – maria Mar 03 '11 at 13:31
  • @Maria, then either create .fonts directory in your home directory and put the font in it (will be available only for you), or put it in /usr/share/fonts directory (if you install it using Synaptic, the font will be placed here, under truetype subdirectory, and will be available for all users). Either way, XeLaTeX will find it in any of these locations. – Meho R. Mar 03 '11 at 17:38
  • @Meho: Did you have to install any additional fonts for basic use of XeLaTeX? I'm asking, because I can't even display specfont documentation file, Linux Libaration O seems to be uninstalled, but also unavailable via apt-get and I can't find anything connected with otf fonts. Details in the body of question (and more details on http://askubuntu.com/questions/28887/fonts-on-ubuntu-10-04). Thanks. – maria Mar 03 '11 at 18:56
  • @Maria, well, of course, I've installed some high-quality fonts from Adobe :) But, again, those two locations I mentioned are default ones and all fonts that are in either of the two would be found by XeLaTeX. So, if you haven't installed Linux Libertine O font through Synaptic or apt-get, you'll have to download it and install it manually, i.e., copy it to any of the two: ~/.fonts or /usr/share/fonts. Also pay attention to exact names of the fonts when using them with XeLaTeX. – Meho R. Mar 04 '11 at 02:26
  • @Meho Succes! Thank you very much for your help. – maria Mar 04 '11 at 17:22
  • You seem to need to have installed .ldf files. When I try to run a minimal version of this it complains that there is no \begin{document} and stops there. So there seems to be a pre-requisite I don't know about. – Francis Davey Aug 01 '17 at 20:14
10

Although I am no expert in LaTeX and Arabic typesetting, I have had some experience in using Arabic and Persian in TeX environment, that I can share.

I have tried arabi and babel in the past, it worked out well, however, I had problems with fonts. Then, as most people would do, I switched to XeLaTeX (or XeTeX, I'm not sure which one means what, I use it anyway..), which is an evolution of LaTeX in terms of fonts and language usage.

I suggest you have a look at XeLaTeX. You don't need the package babel anymore in XeLaTeX, and the package arabxetex, the XeLaTeX counterpart of the LaTeX packages arabi or arabtex, is superior to both in my experience.

This is how my preamble looks like:

\usepackage{fontspec}
\usepackage{xunicode}
\usepackage{xltxtra}
\usepackage{arabxetex}

\newfontfamily\arabicfont[Script=Arabic, Scale=1]{Traditional Arabic}
\newfontfamily\farsifont[Script=Arabic, Scale=1]{Farsi Simple Bold}
\defaultfontfeatures{Mapping=tex-text}

\usepackage[T1]{fontenc}

\setsansfont[Mapping=text-text]{Latin Modern Sans}

My font for Arabic and Persian are respectively Traditional Arabic and Farsi Simple, which are available in Windows.

And this is how I address Arabic and Persian within my text:

\textarab[utf]{ ...كمثل الحمار يحمل أسفاراً ...}

\textfarsi[utf]{هم عمل هم علم باهم یار داشت}

Unfortunately, the documentation in XeLaTeX, as is the case with LaTeX and many other open source software, is scarce and/or poorly presented. (I do not mean to detract from the great amount of work devoted to these projects, but I wish the barrier for entry could be made lower.) It takes time to learn but it pays in the end.

Hope this helps.

Caramdir
  • 89,023
  • 26
  • 255
  • 291
mustail
  • 101
  • Welcome to tex.sx! A tip: If you indent lines by 4 spaces, then they are marked as a code sample. You can also highlight the code and click the "code" button (with "101010" on it). You can mark short passages of code with backticks (```). – Caramdir Mar 01 '11 at 03:10
  • XeTeX is an extension of the TeX typesetting engine. XeLaTeX is using LaTeX on top of that (LaTeX is basically just a bunch of TeX macros that are loaded automatically when you call (pdf/xe/lua)latex. You don't need \usepackage[T1]{fontenc} with XeLaTeX and xunicode is automatically loaded with recent versions of fontspec. – Caramdir Mar 01 '11 at 03:12
  • +1 for XeLaTeX; Most of the documentation you need for using xelatex is contained in the fontspec documentation, which is very clear and helpful. The arabxetex documentation is also very clear. Other than that, XeLaTeX is just latex. – Alan Munn Mar 01 '11 at 03:26
  • The arabxetex solution is mainly intended for people who are used to using the arabtex system, which was designed for people who needed to input Arabic without access to an Arabic keyboard layout. If you are typing Arabic text directly, you should probably just use xelatex and polyglossia as in Meho's answer. – Alan Munn Mar 01 '11 at 18:14
  • @mustail: Thanks a lot. Unfortunatly I coudn't run XeLaTeX on my file. More details in the main question after UPDATE. What kind of LaTeX installation are you working with? @Alan: But in Mustail's exemple there is arabic script in the input? I thought polyglossia is for double language documents? Could you explain more? – maria Mar 01 '11 at 21:49
  • @maria As Meho mentions in his comment, polyglossia is to be thought of as babel for XeLaTeX; the name is intended to imply that it can deal with many language rather than that it is for use with multiple languages at a time. Just like babel, it automatically translates the formulaic strings like "Chapter" and "Table of Contents" etc. into the language you select. It also deals with numerals, dates etc., and in conjunction with the bidi package, deals correctly with RTL and LTR scripts in the same document. See also the tag wiki – Alan Munn Mar 02 '11 at 23:51
  • @Alan Thanks. The problem is that I'm not able to compile Meho's exempe file (details in body of question). It seems I have some problems with fonts, but I don't know where the fonts should be located in the TeX Live instalation form Ubuntu packages, and installation from TUG didn't work (http://tex.stackexchange.com/questions/12440/installing-tex-live-from-tug-org). I think so, because some of tex documentation files opens with white gaps. – maria Mar 03 '11 at 00:09
  • @Maria XeLaTeX should find any font that is accessible to your system (I think on linux this is in /.fonts). So if your XeLaTeX is working, and you have a font that has an Arabic script, it should work. Have you managed to compile a very simple XeLaTeX file? (e.g. \documentclass{article}\usepackage{fontspec}\setmainfont{Linux Libertine O}\begin{document}Hello World!\end{document}) – Alan Munn Mar 03 '11 at 02:08
  • @Alan I can't compile this file (file or installed font not found). I don't have a directory ./fonts. I've try locate .otf (http://tex.stackexchange.com/questions/11888/finding-a-font-for-xetex), I can't see Linux Libertine in the list. Does it mean that I miss some TeX Live package? Thanks. – maria Mar 03 '11 at 09:00
  • @Alan Searching by aptitude I can find only Linux Libertine (uninstalled), but it's .ttf and non .otf. It showes only one package. I guess that installing it won't solve problem with Linux Libertine O and even if, how should I know what fonts should I install (for exemple to display the documentation files)? I still have an impression that my TeX Live install lack of some font package... Thanks – maria Mar 03 '11 at 13:39
  • 1
    @Maria Unfortunately I use a Mac, not linux, so I don't have any experience with fonts in Linux. The main thing to understand about XeLaTeX is that it is not dependent on fonts installed as part of your TeX Live distribution, but by default uses the fonts that are available on your system for any application. (E.g. if you have OpenOffice installed, any font that you can use with OpenOffice, you should be able to use with XeLaTeX as well.) – Alan Munn Mar 03 '11 at 15:03
  • @Alan Finally I've understood :). I will try to find out where is it listed and how to add what is necessery. Thanks. – maria Mar 03 '11 at 15:19
6

I don't know about typesetting arabic, but I did watch this presentation by Idris Hamid from TUG 2010 about a project called Oriental TeX, and remember being rather impressed by it.

I understood it is using ConTeXt mkIV and LuaTeX.

Werner
  • 603,163
morbusg
  • 25,490
  • 4
  • 81
  • 162
3

I don't really know anything about typesetting Arabic with LaTeX. The following should be comments, but turned out to be too long for the comment field.

  • CTAN always has the most current stable packages.
  • September 2009 is not outdated, in comparison to the packages you have installed. Ubuntu 10.04 (and 10.10) contain TeX Live 2009, which was packages sometime in summer 2009.
  • Generally you can find the documentation for packages you have installed with texdoc 〈packagename〉 on the command line. However, this mechanism seems to be rather broken with the Ubuntu packages (at least on my system).
  • Documentation (if it exists) can always be found on CTAN. For example for arabi and arabtex. Both of these packages haven't seen a lot development recently though.
  • Instead of using the traditional pdfTeX engine for your documents, you could use XeLaTeX or LuaLaTeX, two engines that accept the full range of Unicode input and arbitrary TrueType and OpenType fonts. You can try to adapt the answer to a similar question for Devanagari. Compile the document with xelatex instead of (pdf)latex.
  • If you use this last suggestion, I would also suggest that you replace the Ubuntu packages with the latest version of TeX Live to be able to use all the recent developments.
Caramdir
  • 89,023
  • 26
  • 255
  • 291
  • Thanks a lot for useful informations. I've tried to follow your suggestion, the result of my attempts is in main question in UPDATE. I'm not sure if it makes part of the problem for which I've posted this question or should I post another one. – maria Mar 01 '11 at 21:43