# Entering Arabic hamza (ء) with LaTeX

I need to enter some words that begin with an Arabic hamza. Because of publishers' limitation, I don't use Lua/XeLaTeX, and I experience conflicts with ucs package. LaTeX returns error when it encounters the hamza in the text: "not set up for use with LaTeX". At this point I can only approximate the hamza with

\usepackage{rotating}

\newcommand{\hamza}{\reflectbox{\large{\textquoteright}}}

But I want a real hamza (ء)

I use emacs. C-x 8 RET 0621 before a word produces wordء. Emacs thinks I'm writing arabic and so put it to right and works from right to left. But anyway LaTeX does not know the hamza glyph.

Now that I better understand your question, I still think arabtex is the best option for pdflatex. You can scale and shift the halfring around to make it look a bit nicer if you want.

The text in the MWE below is taken from the Wikipedia article on hamza.

## pdflatex solution.

(tipa is only needed for the glottal stop, so you can remove it.)

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{newunicodechar}
\usepackage{arabtex}% For ع and ʾ
\usepackage{tipa}% For \textraiseglotstop
\usepackage{textcomp}% For \textsinglequote
\usepackage{graphicx}% For \scalebox
\newcommand{\righthalfring}{\begingroup\arabfalse\transtrue
\raisebox{1pt}{\scalebox{1}[1.3]{\RL{'}}\kern-3pt}\endgroup}
\newcommand{\ayn}{\begingroup\RL{}\endgroup}
\newunicodechar{ʔ}{\textglotstop}
\newunicodechar{ع}{\ayn}
\newunicodechar{ʾ}{\righthalfring}
\newunicodechar{ʼ}{'}
\begin{document}
There are different ways to represent hamza in Latin transliteration:
\begin{itemize}
\item In the International Phonetic Alphabet (IPA), the sound of the glottal
stop is represented by the letter ʔ, resembling a dotless question mark.
\item There is a tradition of using \textquotesingle, the simple apostrophe;
and a grave accent ‹\textasciigrave› represents \textasciigrave ayn (ع).
\item Some standard transliterations, such as DIN 31635, transliterate it
with a modifier letter right half ring ʾ and others such as ALA-LC with
the modifier letter apostrophe ʼ and sometimes substituted with the Right
Single Quotation Mark ’.
\end{itemize}
\end{document}


## lualatex/xelatex solution

I know you said you can't use lualatex or xelatex, but I include them for others. And they really are the way to go.

\documentclass{article}
\usepackage{fontspec}
\usepackage{newunicodechar}
\defaultfontfeatures[\rmfamily,\sffamily]{}
\setmainfont{Linux Libertine O}
\newcommand{\ayn}{\begingroup\notoarabic ع\endgroup}
\newunicodechar{ع}{\ayn}
\begin{document}
There are different ways to represent hamza in Latin transliteration:
\begin{itemize}
\item In the International Phonetic Alphabet (IPA), the sound of the glottal
stop is represented by the letter ʔ, resembling a dotless question mark.
\item There is a tradition of using ', the simple apostrophe; and a grave
accent ‹› represents ayn (ع).
\item Some standard transliterations, such as DIN 31635, transliterate it
with a modifier letter right half ring ʾ and others such as ALA-LC with
the modifier letter apostrophe ʼ and sometimes substituted with the Right
Single Quotation Mark ’.\looseness=-1
\end{itemize}
\end{document}


You could use the arabtex package, which works with pdflatex.

' is used to input hamza. See the arabtex manual for usage details of how hamza combines with its carrier.

It's also possible to use UTF-8 input encoding with arabtex. You need to use \usepackage{utf8}. You can change the input encoding with \setcode{utf8}.

\documentclass{article}
\usepackage{arabtex}
\usepackage{utf8}
\begin{document}
\RL{"' 'a 'i 'u}

\begin{RLtext}
"' 'a 'i 'u
\end{RLtext}

\setcode{utf8}

\RL{ء أَ إِ أُ}

\begin{RLtext}
ء أَ إِ أُ
\end{RLtext}
\end{document}
`

• I didn't have much luck with arabtex because of my limitations. This gives the appearance I want, but seem ugly. I use \setarab, \vocalize, \transtrue, \arabfalse, and then, for example: Ab\=u Bakr b. \RL{'|}Umar or \textrm{Ab\=u Bakr b. \RL{'|}Umar.}. – Haines Brown Oct 26 '18 at 22:30
• @HainesBrown, do you mean that you want to input Arabic as utf8? – David Purton Oct 27 '18 at 0:53
• I aim at a Latin transliteration of some Arabic words/names. My (limited) understanding is that LaTeX has access to a limited range of Unicode characters. Can't use utf8x because of conflicts; can't use Lua/XeLaTeX for reasons indicated. The hamza gutteral stop is not a glyph known to LaTeX, so I call on arabtex package as used in my prior example. It works, but is ugly and I wonder if there is a better way. – Haines Brown Oct 28 '18 at 15:51
• @HainesBrown, your question is very unclear. Do you want transliterated Arabic? Your question never mentions this. There is also not one true way to transliterate hamza. See en.wikipedia.org/wiki/Hamza#Latin_representations. Which one do you want? Are you sure about your reflected single quotation mark? That goes the wrong way according to all the Wikipedia options given. Please clarify your question. – David Purton Oct 28 '18 at 22:22
• I'm sorry my original question did not make sufficiently clear that I needed a LaTeX command to represent a transliterated Arabic hamza. Since I asked the question I find that the hamza is often transliterated using arabtext package with a LaTeX as \RL{'|}. How a hamza appears in Arabic depends on context, but in transliteration is it often what one gets with \RL{'|} (looks like a backward elevated lower case "c"). – Haines Brown Nov 12 '18 at 13:42