# Caption formatting does not work with bidi

I am using the caption package to format figure and table captions. However, this breaks for longtable tables when the package bidi is loaded.

Here is a minimal example:

\documentclass{scrartcl}
\usepackage{lmodern}
\usepackage[xetex,pdfborder={0 0 0}]{hyperref}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{booktabs}
\usepackage{bidi}

\title{A Test}
\author{Author}
\date{\today}

\begin{document}

\maketitle

This is a paragraph.

\begin{figure}
\centering
\includegraphics[width=\textwidth]{Image_1.jpg}
\caption{An image}
\end{figure}

\begin{table}
\centering
\caption{A simple table}
\begin{tabular}{ll}
\toprule
A cell & and another one \\
and a third & and a fourth \\
\bottomrule
\end{tabular}
\end{table}

\begin{longtable}{ll}
\caption{A long table}\\
\toprule
A cell & and another one \\
and a third & and a fourth \\
\bottomrule
\end{longtable}

\end{document}


This is the result:

The captions formatting works for regular table and figure captions, and it also works for longtable as long as the bidi package is not loaded.

Any ideas how to fix this?

• I just took a short look into bidi and had already screamed out loud. It overwrites longtable code, too, so what should I (as maintainer of the caption package) do about it? Overwrite it again (\AtBeginDocument) if bidi is loaded? Furthermore it uses internal code of the caption package which will change in the near future. Its author does not follows rule #1 when writing LaTeX packages: Only use internal code of dead (=unmaintained) LaTeX package. Otherwise contact the package author and figure out a proper interface. – user2574 Apr 13 '19 at 16:58
• ...this shows one of the biggest problems with LaTeX: There is no community of "LaTeX package authors", everyone is just writing dirty patches and nobody is talking with affected package authors, there is no quality control at all, the package interfaces in LaTeX have not seen any improvements in decades etc. – user2574 Apr 13 '19 at 17:15
• gitlab.com/axelsommerfeldt/caption/issues/54 – user2574 Apr 13 '19 at 17:16

You are using the KOMA-Script class scrartcl. So you can use its features to format the captions as desired:

\documentclass{scrartcl}
\usepackage{lmodern}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{booktabs}

\usepackage[pdfborder={0 0 0}]{hyperref}
\usepackage{bidi}

\KOMAoptions{captions=tableabove}% <- to get the correct spacing between caption and table

\title{A Test}
\author{Author}
\date{\today}

\begin{document}

\maketitle

This is a paragraph.

\begin{figure}
\centering
\rule{\textwidth}{1cm}
\caption{An image}
\end{figure}

\begin{table}
\centering
\caption{A simple table}
\begin{tabular}{ll}
\toprule
A cell & and another one \\
and a third & and a fourth \\
\bottomrule
\end{tabular}
\end{table}

\begin{longtable}{ll}
\caption{A long table}\\
\toprule
A cell & and another one \\
and a third & and a fourth \\
\bottomrule
\end{longtable}

\end{document}


Result:

Change the oder of packages:

\documentclass{scrartcl}
\usepackage{lmodern}
\usepackage[xetex,pdfborder={0 0 0}]{hyperref}
\usepackage{graphicx}

\usepackage{booktabs}
\usepackage{longtable}
\usepackage{bidi}

\title{A Test}
\author{Author}
\date{\today}

\begin{document}

\maketitle

This is a paragraph.

\begin{table}
\centering
\caption{A simple table}
\begin{tabular}{ll}
\toprule
A cell & and another one \\
and a third & and a fourth \\
\bottomrule
\end{tabular}
\end{table}

\begin{longtable}{ll}
\caption{A long table}\\
\toprule
A cell & and another one \\
and a third & and a fourth \\
\bottomrule
\end{longtable}

\end{document}