2

I'm typesetting an Arabic document using XeLaTeX. I'm using it for about a year now.

The problem I couldn't solve or find a solution for yet is when putting two figures side-by-side, the figures are in the correct order (RTL) in the document but they are reversed in the list of figures.

My minimal working example:

\documentclass{report}
\usepackage{polyglossia}
\setmainlanguage{arabic}
\newfontfamily\arabicfont[Script=Arabic,Scale=1]{KacstOne}

\newcommand{\dblimg}
  [7][ht]{{\begin{figure}[#1]
             \begin{minipage}{0.48\textwidth}\centering
               \includegraphics[width=#2\textwidth]{#3}
               \caption[#4]{\centering #4}
             \end{minipage}\hfill
             \begin{minipage}{0.48\textwidth}\centering
               \includegraphics[width=#5\textwidth]{#6}
               \caption[#7]{\centering #7}
             \end{minipage}
           \end{figure}
         }}

\begin{document}
\listoffigures
\dblimg{1}{a.jpg}{111}
       {1}{a.jpg}{222}

\end{document}

The output: enter image description here

The \dblimg takes the width, path, and caption of the two images.

As you can see, Figure 1 (on the right) is listed before Figure 2; the figures are in the correct order in the document, but not in the list of figures.

1 Answers1

2

First with caption package you can remove figures from lof with \caption[]{your caption}, then you can replace them with manual entry

\addcontentsline{lof}{subsection}{\arabic{tempfig}\qquad your caption}

Where tempfig is a counter which store the value of figure counter before side by side images

\documentclass{article}
\usepackage{graphicx}
\usepackage{caption}
\usepackage{polyglossia}
\setmainlanguage{arabic}
\newfontfamily\arabicfont[Script=Arabic,Scale=1]{Amiri}

\newcounter{tempfig}

\newcommand{\dblimg}
  [7][ht]{%
  \setcounter{tempfig}{\value{figure}}
  \stepcounter{tempfig}
  \addcontentsline{lof}{subsection}{\arabic{tempfig}\qquad #4}
  \stepcounter{tempfig}
  \addcontentsline{lof}{subsection}{\arabic{tempfig}\qquad #7}
  \begin{figure}[#1]
             \begin{minipage}{0.48\textwidth}\centering
               \includegraphics[width=#2\textwidth]{#3}
               \caption[]{\centering #4}
             \end{minipage}\hfill
             \begin{minipage}{0.48\textwidth}\centering
               \includegraphics[width=#5\textwidth]{#6}
               \caption[]{\centering #7}
             \end{minipage}
           \end{figure}
         }

\begin{document}

\listoffigures

\dblimg{1}{example-image}{111}
       {1}{example-image}{222}

\end{document}

enter image description here

Salim Bou
  • 17,021
  • 2
  • 31
  • 76
  • I found 2 issues:
    1. If Fig number is prefixed (e.g., with the chapter number), it will be w/o the prefix in LOF.
    2. The space between Fig number and caption in LOF is fixed, but all captions should be aligned.

    After searching and trying, the solution for 1 is using \thefigure directly, and for 2 is to add {\protect\numberline{\thefigure}#4}. So before \begin{figure} we need \stepcounter{figure}\addcontentsline{lof}{section}{\protect\numberline{\thefigure}#4} twice (for each image), and after \end{figure} we need \addtocounter{figure}{-2}

    – Noureddin Jan 28 '17 at 14:52
  • In this case you get شكل ٣ and شكل ٤, I think you mean: add \addtocounter{figure}{-2} before captions of figures – Salim Bou Jan 28 '17 at 19:53
  • Good catch! My code (in the previous comment) fixes the numbers in LOF but increases the figures numbers in the document by 2. This is the revised code; it should work fine now. – Noureddin Jan 29 '17 at 03:51