## LaTeX forum ⇒ Fonts & Character Sets ⇒ Text direction of Arabic in table Topic is solved

Information and discussion about fonts and character sets (e.g. how to use language specific characters)
Ahmed Sokar
Posts: 4
Joined: Wed Jul 27, 2016 9:43 am

### Text direction of Arabic in table

Hello,

I want to write arabic in table
\documentclass[14pt]{article}\usepackage[utf8]{inputenc}\usepackage[LAE]{fontenc}\usepackage[german,arabic]{babel}  \begin{document}محمد - أحمد           \begin{tabular}[]{|c|c|}\hline                 محمد & أحمد          \\\hline         \end{tabular} \end{document}

The result is

Untitled.png (3.02 KiB) Viewed 2356 times

So how can i force the text direction from right to left in the table?
Last edited by Ahmed Sokar on Wed Jul 27, 2016 10:50 am, edited 1 time in total.

Johannes_B
Site Moderator
Posts: 3668
Joined: Thu Nov 01, 2012 4:08 pm
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.

Stefan Kottwitz
Posts: 8735
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:
Hi Ahmed,

welcome to the forum!

If anything doesn't work, save it in a box. That's good for TikZ nodes, but also for tabular content or content that shows issues within another environment.

Declare a box:

\newsavebox{\mybox}

Use it, in this case we chose the array package to define a new column type, here C for right to left centered:

\usepackage{array}\newcolumntype{C}{>{\begin{lrbox}{\mybox}}c<{\end{lrbox}\AR{\unhbox\mybox}}}

\begin{tabular}[]{|C|C|...

Complete example:

\documentclass[14pt]{article}\usepackage[utf8]{inputenc}\usepackage[LAE]{fontenc}\usepackage[german,arabic]{babel} \newsavebox{\mybox}\usepackage{array}\newcolumntype{C}{>{\begin{lrbox}{\mybox}}c<{\end{lrbox}\AR{\unhbox\mybox}}}\begin{document}محمد - أحمد           \begin{tabular}[]{|C|C|}\hline                 محمد & أحمد          \\\hline         \end{tabular} \end{document}

That's similar to what Salim Bou suggested.

Stefan

Ahmed Sokar
Posts: 4
Joined: Wed Jul 27, 2016 9:43 am
That worked

thank you!