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}
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}
Thanks.