Generalcaption problem

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
sudanix
Posts: 5
Joined: Sat Feb 20, 2010 10:04 pm

caption problem

Post by sudanix »

Hello,

i have the following tex code to highlight source code (using listings package).

Code: Select all

\documentclass[a4paper,oneside,headsepline,10pt]{scrbook}
\usepackage{color}
\usepackage{xcolor}
\usepackage{listings}

\usepackage{caption}
\DeclareCaptionFont{white}{\color{white}}
\DeclareCaptionFormat{listing}{\colorbox{gray}{\parbox{\textwidth}{#1#2#3}}}
\captionsetup[lstlisting]{format=listing,labelfont=white,textfont=white}

% This concludes the preamble
\begin{document}

\begin{lstlisting}[label=some-code,caption=Some Code]
public void here() {
        goes().the().code()
}
\end{lstlisting}
\end{document}
it work good, the output :
capen.PNG
capen.PNG (5.85 KiB) Viewed 1760 times
The problem appear when i use this code in my book, the gray box is disappear also caption name and its font is not appear good.

this is the code for my book(default language is arabic):

Code: Select all

\documentclass[a4paper,oneside,headsepline,10pt]{scrbook}
\usepackage{color}
\usepackage{xcolor}
\usepackage{fontspec}
\usepackage{listings}
\usepackage{caption}

\DeclareCaptionFont{white}{\color{white}}
\DeclareCaptionFormat{listing}{\colorbox{gray}{\parbox{\textwidth}{#1#2#3}}}
\captionsetup[lstlisting]{format=listing,labelfont=white,textfont=white}

\providecommand{\newXeTeXintercharclass}[1]{\edef #1\relax}
\usepackage{polyglossia}

\setmainlanguage{arabic}
\setotherlanguage{english}

\setmainfont[Script=Arabic,Scale=1.5,Mapping=arabicdigits]{Traditional Arabic}


\begin{document}

% arabic sentence will be here..

\begin{english}
\fontspec{Courier New}


\begin{lstlisting}[label=some-code,caption=Some Code]
public void here() {
        goes().the().code()
}

\end{lstlisting}
\end{english}


\end{document}
the output:
capar.PNG
capar.PNG (6.01 KiB) Viewed 1760 times
How i can solve this problem ?

Thanks.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

sudanix
Posts: 5
Joined: Sat Feb 20, 2010 10:04 pm

caption problem

Post by sudanix »

the problem is solved now.
This is bidi's bug and thanks for reporting. Before \begin{document} put:

\makeatletter
\@ifpackageloaded{caption}{\input{caption-xetex-bidi.def}}{}
\makeatother
Post Reply