I'm trying to write a sentence like

The word must be either کا, کے or کی.

into a LaTeX document. I've tried several ways of getting Arabic characters to LaTeX, and this: Arabic in latex was the only one I managed to get to work. However, when I try to embed a version of it into a document with words in many different languages, it doesn't compile. I'm using Windows 10, TeXworks editor, PdfLaTeX. (I'm quite new to LaTeX, this is my first major document I'm writing in it). Below is the error I get (and yes, I do have \begin{document} in my document as if I remove the package imports and the section containing Arabic characters, the document compiles just fine.

Here's a "minimal" working example. This code does not compile, but if I comment out all the five lines that contain a comment like this: %%%% If I comment out this and the rest of lines with this comment, it will compile.

LaTeX code:

% -*- coding: utf-8 -*-
\documentclass{article}% use option titlepage to get the title on a page of its own.
\usepackage{devanagari}%Hindi word: {\dn kA}
\usepackage{CJKutf8} % Japanese
\usepackage[russian,english]{babel} % Cyrillic: Bulgarian
\usepackage[LGR,T1]{fontenc} % this and the next two lines for Ancient Greek, as well as the comment on the first line
\usepackage[utf8]{inputenc} % utf8 is required

\usepackage{arabtex} % Arabic: Urdu (doesn't work) %%%% If I comment out this and the rest of lines with this comment, it will compile
\usepackage{utf8} % Urdu (doesn't work) %%%% If I comment out this and the rest of lines with this comment, it will compile



% numbering tutorials: https://latex.org/forum/viewtopic.php?t=12143 ; https://www.latex-tutorial.com/tutorials/lists/
% https://tex.stackexchange.com/questions/512584/arabic-alphabet-urdu-language-to-latex
\title{Some random title}
\date{Some random date}
\author{Anonymous authors}
\noindent Text:
\item This is an enumerated item
\item boom boom boom.
\item englanti.
\textbf{word} has four letters 

\section{Devanagari transliteration workaround}

This works fine {\dn kA} yeah.

\section{Urdu (here's the problem)}

The word must be either
\<کا>%%%% If I comment out this and the rest of lines with this comment, it will compile
\<کے>%%%% If I comment out this and the rest of lines with this comment, it will compile
\<کی>%%%% If I comment out this and the rest of lines with this comment, it will compile

\section{Meaningless section}
\textbf{Some bold text here.}\newline\newline
\code{this is a code block}, boom.

\section{A Japanese character}

This is the only Japanese wod that I need: \begin{CJK}{UTF8}{min}の\end{CJK} and it works fine.


This is a Bulgarian word: \foreignlanguage{russian}{на} and I need that as well.


Error message:

This is pdfTeX, Version 3.14159265-2.6-1.40.20 (MiKTeX 2.9.7050 64-bit)
entering extended mode
LaTeX2e <2018-12-01>
("C:\Program Files\MiKTeX 2.9\tex/latex/base\article.cls"
Document Class: article 2018/09/03 v1.4i Standard LaTeX document class
("C:\Program Files\MiKTeX 2.9\tex/latex/base\size10.clo"))
("C:\Program Files\MiKTeX 2.9\tex/latex/blindtext\blindtext.sty"
("C:\Program Files\MiKTeX 2.9\tex/latex/tools\xspace.sty"))
("C:\Program Files\MiKTeX 2.9\tex/latex/graphics\graphicx.sty"
("C:\Program Files\MiKTeX 2.9\tex/latex/graphics\keyval.sty")
("C:\Program Files\MiKTeX 2.9\tex/latex/graphics\graphics.sty"
("C:\Program Files\MiKTeX 2.9\tex/latex/graphics\trig.sty")
("C:\Program Files\MiKTeX 2.9\tex/latex/graphics-cfg\graphics.cfg")
("C:\Program Files\MiKTeX 2.9\tex/latex/graphics-def\pdftex.def")))
("C:\Program Files\MiKTeX 2.9\tex/latex/devanagari\devanagari.sty")
("C:\Program Files\MiKTeX 2.9\tex/latex/url\url.sty")
("C:\Program Files\MiKTeX 2.9\tex/latex/enumitem\enumitem.sty")
("C:\Program Files\MiKTeX 2.9\tex/latex/cjk\CJKutf8.sty"
("C:\Program Files\MiKTeX 2.9\tex/generic/oberdiek\ifpdf.sty")
("C:\Program Files\MiKTeX 2.9\tex/latex/base\inputenc.sty")
("C:\Program Files\MiKTeX 2.9\tex/latex/cjk\CJK.sty"
("C:\Program Files\MiKTeX 2.9\tex/latex/cjk/mule\MULEenc.sty")
("C:\Program Files\MiKTeX 2.9\tex/latex/cjk\CJK.enc"))
("C:\Program Files\MiKTeX 2.9\tex/latex/base\fontenc.sty"))
("C:\Program Files\MiKTeX 2.9\tex/latex/base\fontenc.sty"
("C:\Program Files\MiKTeX 2.9\tex/latex/cyrillic\t2aenc.def"
("C:\Program Files\MiKTeX 2.9\tex/latex/base\t2aenc.dfu"))
("C:\Program Files\MiKTeX 2.9\tex/latex/base\t1enc.def"))
("C:\Program Files\MiKTeX 2.9\tex/generic/babel\babel.sty"
("C:\Program Files\MiKTeX 2.9\tex/generic/babel\switch.def")
* Local config file bblopts.cfg used
("C:\Program Files\MiKTeX 2.9\tex/latex/arabi\bblopts.cfg")
("C:\Program Files\MiKTeX 2.9\tex/latex/babel-russian\russianb.ldf"
("C:\Program Files\MiKTeX 2.9\tex/generic/babel\babel.def"
("C:\Program Files\MiKTeX 2.9\tex/generic/babel\txtbabel.def")))
("C:\Program Files\MiKTeX 2.9\tex/latex/babel-english\english.ldf"))
("C:\Program Files\MiKTeX 2.9\tex/latex/base\fontenc.sty"
("C:\Program Files\MiKTeX 2.9\tex/latex/greek-fontenc\lgrenc.def"
("C:\Program Files\MiKTeX 2.9\tex/latex/greek-inputenc\lgrenc.dfu")
("C:\Program Files\MiKTeX 2.9\tex/latex/greek-fontenc\greek-fontenc.def"))
("C:\Program Files\MiKTeX 2.9\tex/latex/base\t1enc.def"))
("C:\Program Files\MiKTeX 2.9\tex/latex/base\textcomp.sty"
("C:\Program Files\MiKTeX 2.9\tex/latex/base\ts1enc.def"
("C:\Program Files\MiKTeX 2.9\tex/latex/base\ts1enc.dfu")))
("C:\Program Files\MiKTeX 2.9\tex/latex/arabtex\arabtex.sty"

! LaTeX Error: Missing \begin{document}.

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

l.40 \let \xpa \expandafter         
                                        \def \xxpa {\xpa \xpa \xpa }
  • Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – dexteritas
    Oct 17, 2019 at 11:08
  • Done. I'll need individual words in a number of different scripts, so I included some of those as well in this minimal working example.
    – hilssu
    Oct 17, 2019 at 12:18
  • For some reason, the editor did not copy the error message originally (I had to right-click and copy, Control+C didn't work), so for a short time I had the code again as the "error message" but now that's updated as well (and has been for about an hour now as I write this extra comment).
    – hilssu
    Oct 17, 2019 at 13:31
  • 1
    There seems to be a compatibily problem with arabtex and devanagari. Btw. you import inputenc two times.
    – dexteritas
    Oct 17, 2019 at 15:50
  • That seems true. I commented out the devanagari and uncommented the arabic, and now it compiled. However, the Arabic text was still invisible, and a huge space was inserted before the Japanese character. I guess the only solution is to insert the Urdu words as images and not as text...
    – hilssu
    Oct 17, 2019 at 16:03

2 Answers 2


As noted in the comments of the question, the packages arabtex and devanagari seem to have compatibility issues. As a solution, I recommend using XeLaTeX with packages polyglossia and fontspec instead. Below is a small example. Note that polyglossia loads fontspec automatically.

Additionally, you need fonts containing the characters of the languages used in your document. This example uses Microsoft Windows 10 fonts Times New Roman, Nirmala UI and MS Gothic. If the latter two are not installed, you can install them from Control Panel > Fonts > Download fonts for all languages.

Further information can be found from the documentation of the polyglossia and fontspec packages.

% !TEX encoding = UTF-8 Unicode
% !TEX TS-program = xelatex
% Document's main font (for English, Bulgarian and Urdu):
\setmainfont{Times New Roman}
% Font for Hindi text:
\newfontfamily\hindifont{Nirmala UI}
% Font and command for Japanese text:
\newfontfamily\japanesefont{MS Gothic}
\newcommand*{\textjapanese}[1]{{\japanesefont #1}}
Bulgarian: \textbulgarian{пример} \\
Urdu: \texturdu{مثال} \\
Hindi: \texthindi{उदाहरण}  \\
Japanese: \textjapanese{例}

Here is how to do it with a recent Babel, and either XeLaTeX or LuaLaTeX. There are some comments in the code.


% For a mostly monolingual document, only declare explicitly the main
% language (minor languages are loaded on the fly). We need activate
% bidi writing; for a few words, the default is enough.
\usepackage[english, bidi=default]{babel}

% The default font doesn't include the required scripts,
% so we need some extra setup (fonts from TeXLive):
\babelfont[bulgarian]{rm}{CMU Serif}
% With LuaLaTeX Harfbuzz is required in Hindi. XeLaTeX just
% ignores this setting.

\title{Some random title}
\date{Some random date}
\author{Anonymous authors}





\textbf{word} has four letters 

\section{Urdu (here's the problem)}

The word must be either \foreignlanguage{urdu}{کا}, or
\foreignlanguage{urdu}{کے}, or \foreignlanguage{urdu}{کی}

\section{A Japanese character}

This is the only Japanese word that I need:


This is a Bulgarian word: \foreignlanguage{bulgarian}{на} and I need
that as well.

And hindi: \foreignlanguage{hindi}{हिन्दी} 



  • That doesn't work for me, here are the error messages: pastebin.com/X3GpFH9u . May be due to me not having a recent enough version of Babel.
    – hilssu
    May 13, 2020 at 18:29
  • @hilssu Yes, from the log file it's clear the problem is the version is not one of the most recent. By declaring explicitly the languages with \babelprovide{urdu} and the like, it might work. May 14, 2020 at 6:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .