2

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[format=hang,labelfont=bf,font={small,rm},labelsep=quad]{caption}
\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:

rendered PDF output

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?

3
  • 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, 2019 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, 2019 at 17:15
  • gitlab.com/axelsommerfeldt/caption/issues/54
    – user2574
    Apr 13, 2019 at 17:16

2 Answers 2

0

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{bookmark}% <- added
\usepackage{bidi}

\KOMAoptions{captions=tableabove}% <- to get the correct spacing between caption and table
\addtokomafont{caption}{\normalfont\small}
\addtokomafont{captionlabel}{\bfseries}
\renewcommand*{\captionformat}{\quad}

\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:

enter image description here

1

Change the oder of packages:

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

\usepackage{booktabs}
\usepackage[format=hang,labelfont=bf,font={small,rm},labelsep=quad]{caption}
\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}

enter image description here

You must log in to answer this question.

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