1

I use latex for my thesis but my language is persian and I have to use xepersian package . recently I have a problem and when I use algorithm and algorithmic package , my algorithm'code become disassemble for example my code get right align and ny numeric is arabic , what can I do ??

1
  • 3
    You can start by showing us an example of your current output. This should be accompanied by code that starts with \documentclass and ends with \end{document} and allows the community to replicate the behaviour.
    – Werner
    Apr 1, 2019 at 21:31

1 Answer 1

0

If you need the caption label and its numbering to be in Farsi and right aligned but your code in English and left align:

\begin{algorithm}
    \caption{ PUMPED-CONFIGURATION(n)}
    \begin{latin}
        \begin{algorithmic}[1]
            \STATE $V\gets 0$
            \WHILE {$|V|\neq n$}
            \STATE $v \gets RANDOM-SAMPLE()$
            \STATE $valid\gets TRUE$
            \FORALL { $ v' \in V,v\neq v'$}
            \IF {$r(v)\cap r(v')\neq 0$}
            \STATE $ valid \gets FALSE$
            \ENDIF
            \ENDFOR
            \IF {$valid$}
            \STATE $ V\gets V \cup \{v\}$
            \ENDIF
            \ENDWHILE
            \RETURN{ $V$}
        \end{algorithmic}
    \end{latin}
\end{algorithm}

First

If you need the caption label, the numbering, and your code in English and left aligned:

\begin{latin}
    \begin{algorithm}
        \caption{ PUMPED-CONFIGURATION(n)}
        \begin{algorithmic}[1]
            \STATE $V\gets 0$
            \WHILE {$|V|\neq n$}
            \STATE $v \gets RANDOM-SAMPLE()$
            \STATE $valid\gets TRUE$
            \FORALL { $ v' \in V,v\neq v'$}
            \IF {$r(v)\cap r(v')\neq 0$}
            \STATE $ valid \gets FALSE$
            \ENDIF
            \ENDFOR
            \IF {$valid$}
            \STATE $ V\gets V \cup \{v\}$
            \ENDIF
            \ENDWHILE
            \RETURN{ $V$}
        \end{algorithmic}
    \end{algorithm}
\end{latin}

Second

If you need the caption label, the numbering, and your code in Farsi and right aligned:

\renewcommand{\algorithmicif}{\textbf{اگر}}
\renewcommand{\algorithmicthen}{\textbf{آنگاه}}
\renewcommand{\algorithmicelse}{\textbf{وگرنه}}
\renewcommand{\algorithmicprint}{\textbf{چاپ کن}}
\renewcommand{\algorithmicendif}{\textbf{پایان اگر}}
\begin{algorithm}
    \caption{الگوریتم هم‌رنگ‌سازی چندبانده.} \label{alg:multibandblending}
    \begin{algorithmic}[1]
        \REQUIRE تصاویر $A$ و $B$.\\
        \ENSURE تصویر $S$ حاصل از  نیمه‌ی سمت چپ $A$ و نیمه‌ی سمت راست $B$
        \STATE هرمهای لاپلاسین $LA,LB$ از تصاویر $A,B$ ساخته می‌شوند.
        \STATE هرم لاپلاسین سومی به نام $LS$ با کپی کردن نیمه‌های سمت چپ $LA$ و سمت راست $LB$ ساخته می‌شود.
        \STATE تصویر نهایی $S$ با گسترش هر سطح هرم $LS$ و جمع آن با سطح بعدی حاصل خواهد شد.   
        \IF{$mod(a,2)==0$}
        \PRINT $a$ زوج است.
        \ELSE 
        \PRINT $a$ فرد است.  
        \ENDIF
    \end{algorithmic}
\end{algorithm}

Third

1
  • your answer is complete and I used and benefited it, thank you very much
    – mosi
    Jun 29, 2019 at 20:32

You must log in to answer this question.

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