3

I am using Lyx to write a document in Arabic Language. My problem in numbering of the sections and subsections.

In arabic, text direction is from right to left. So when I created sections and subsections, say for example in the following shot:

enter image description here

So Section 2 is ok, but for subsection it should be ".1.2" (so that we read it from right to left correctly) but as you see in the shot it is ".2.1".

So please tell me there is a way to fix this. (please note that I depend on these section and subsections numbering to create Table Of Content automatically).

I hope my question is clear. Thanks in Advance

Please see the following sample code for debugging

      % Preview source code

%% LyX 2.1.2 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[11pt]{report}
\usepackage{fontspec}
\setmainfont[Mapping=tex-text]{Arial}
\setsansfont[Mapping=tex-text]{Arial}
\setmonofont{Arial}
\usepackage[a4paper]{geometry}
\geometry{verbose,tmargin=2.5cm,bmargin=2.5cm,lmargin=3.5cm,rmargin=2.5cm}
\usepackage{fancyhdr}
\pagestyle{fancy}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\usepackage{float}
\usepackage{setspace}
\onehalfspacing

\makeatletter
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
\fancyhf{}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0.4pt}
\fancyhead[L]{\nouppercase \leftmark}
\fancyhead[R]{\nouppercase \rightmark}
%\fancyfoot[L]{\scriptsize Design and Verification of MP3 Decoding Stage}
\fancyfoot[R]{\thepage}
%\fancyfoot[R]{\scriptsize Mohammed Ibrahim}

\makeatother

\usepackage{xunicode}
\usepackage{polyglossia}
\setdefaultlanguage{arabic}
\begin{document}

\section{المقدمات العامة }


\subsection{تعريفه: }

لغةً هو التحسين. اصطلاحاً هو علم يبحث في الكلمات


\subsection{موضوعه: }

الكلمات 


\subsection{نسبته: }

أحد العلوم


\end{document}
8
  • Welcome to TeX.SX! Yes i think its clear, but you can help us to help you by providing the code for a small compilable document that shows your problem called MWE. Just edit your question and add missing code.
    – Bobyandbob
    Mar 11, 2018 at 20:25
  • Does Problem with english number in xepersian package do the job? I tried with xelatex.
    – Bobyandbob
    Mar 11, 2018 at 20:29
  • Is the output in the PDF correct? Mar 11, 2018 at 20:39
  • OK. I know next to nothing about Arabic and RTL, but I think more information would be needed. In the source pane, select Complete document instead of Body only, or whatever is selected, and copy-paste that instead. After pasting the code into your question, select it and click the button marked {}, which will highlight it properly as code. Mar 11, 2018 at 20:47
  • @TorbjørnT, I hope the sample code is clear now
    – moibrahim
    Mar 11, 2018 at 20:54

1 Answer 1

1

I have a feeling this is not really the right way to do this. But here at least is a work around. It won't affect your display in LyX, but should output correctly.

Add this to your preamble:

% force numbered labels to be set RTL
\makeatletter
\def\SepMark#1{\gdef\@SepMark{\hboxR{#1}}}%
\makeatother
\SepMark{.}

MWE

\documentclass{article}
\usepackage{polyglossia}
\setdefaultlanguage{arabic}
\setmainfont{Arial}[Script=Arabic]
% force numbered labels to be set RTL
\makeatletter
\def\SepMark#1{\gdef\@SepMark{\hboxR{#1}}}%
\makeatother
\SepMark{.}
\begin{document}
\section{المقدمات العامة}
\subsection{تعريفه:}
لغةً هو التحسين. اصطلاحاً هو علم يبحث في الكلمات
\subsection{موضوعه:}
الكلمات 
\subsection{نسبته:}
أحد العلوم
\end{document}

enter image description here

Concerning LyX

In LyX, you probably need a bit more. In Document --> Settings --> LaTeX Preamble, add

\AtBeginDocument{%
  \def\SepMark#1{\gdef\@SepMark{\hboxR{#1}}}%
  \SepMark{.}%
}

The \AtBeginDocument is needed because by default LyX will add polyglossia after the code one adds in the preamble. And so I guess the SepMark will be modified back to it's default. (It's not necessary to add \makeatletter/\makeatother because LyX inserts those.)

0

You must log in to answer this question.

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