0

Writing a book in Persian, I use \usepackage{listing} in the preamble to include a source code into appendix. However, whenever I refer to a table or figure throughout the text, the table/figure number that appears has a different ordering from the table/figure number itself. For instance, the text shows a reference to table 5.2 but the table is numbered like 2,5 in its caption. Once I delete \usepackage{listing}, everything gets ok. I use TeXLive and Texstudio.

Sample code:

\documentclass{book}
\usepackage{listings}
\usepackage{makeidx}
\makeindex
\usepackage{textgreek}
\usepackage{longtable,ltxtable}
\usepackage[toc,page]{appendix}
\usepackage[table]{xcolor}
\usepackage{pdflscape}
\usepackage{adjustbox}
\usepackage{rotating,tabularx}
\usepackage[bottom,hang]{footmisc}% These two lines set the space between footnote number and text
\setlength{\footnotemargin}{1em}
\makeatletter%To get latin numbers for LTR footnotes and Persian numbers for Persian RTL footnotes
\def\@makeLTRfnmark{\hbox{\@textsuperscript{\latinfont\@thefnmark}}}
\renewcommand\@makefntext[1]{%
\parindent 1em%
\noindent
\hb@[email protected]{\hss\if@RTL\@makefnmark\else\@makeLTRfnmark\fi}#1}
\makeatother
\usepackage{microtype}%To prevent \cite to spill over the margin
\linespread{1.7}
\setcounter{secnumdepth}{5} %to have subsubsections numbered
\usepackage{chngcntr}
\usepackage{placeins} %This package and the following block of codes ensure that figures stay in their respective subsection
\makeatletter
\AtBeginDocument{%
\expandafter\renewcommand\expandafter\subsection\expandafter
{\expandafter\@fb@secFB\subsection}%
\newcommand\@fb@secFB{\FloatBarrier
    \gdef\@fb@afterHHook{\@fb@topbarrier \gdef\@fb@afterHHook{}}}%
\g@addto@macro\@afterheading{\@fb@afterHHook}%
\gdef\@fb@afterHHook{}%
}
\makeatother
\usepackage[a4paper]{geometry}
\geometry{tmargin=3cm,bmargin=3cm,lmargin=3cm,rmargin=3cm}
\widowpenalty10000
\clubpenalty10000
\usepackage[toc,page]{appendix}
\usepackage[colorlinks,citecolor=blue]{hyperref}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{textcomp}
\usepackage{multirow}
\usepackage{natbib}
\usepackage{tikz}
\usepackage{graphicx}
\usepackage{afterpage}
\usepackage{subcaption}
\usepackage{eurosym}
\usepackage[affil-it]{authblk}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage[utf8]{inputenc}
\usepackage{booktabs,fixltx2e}
\usepackage[font=small,labelfont=bf]{caption}
\usepackage{epstopdf}
\usepackage{mathtools}
\setcounter{MaxMatrixCols}{10}
\usepackage{fancyhdr}
\usepackage[nottoc]{tocbibind}
\usepackage{emptypage}
\usepackage{float}
\floatstyle{boxed}
\usetikzlibrary{decorations.pathreplacing}
\usetikzlibrary{decorations.pathmorphing, patterns,shapes}
\providecommand{\U}[1]{\protect\rule{.1in}{.1in}}
\newtheorem{proposition}{پروپوزیشن}
\newtheorem{lemma}{لم}
\newtheorem{assumption}{فرض}
\newtheorem{definition}{تعریف}
\newtheorem{corollary}{نتیجه‌گیری}
\numberwithin{proposition}{chapter}
\numberwithin{lemma}{chapter}
\numberwithin{assumption}{chapter}
\numberwithin{definition}{chapter}
\numberwithin{corollary}{chapter}
\renewcommand\bibname{مراجع}
\usepackage[extrafootnotefeatures]{xepersian}
\settextfont[Scale=1.3]{Yas} % Persian default font for the text
\setlatintextfont[Scale=1.3]{Times New Roman} % Latin default font for the text
\setdigitfont[Scale=1.3]{Yas} % Number's font
\defpersianfont\mynewfont[Scale=1.3]{XB Niloofar} % define new Persian font
\defpersianfont\mynewfontenglish[Scale=1.4]{Arial} % define new Latin font
\begin{document}
\chapter{فصل اول}
اینجا چیزی نمی‌نویسیم تا شماره جدول در فصل بعد با شماره فصل متفاوت باشد.
\chapter{فصل دوم}
در این فصل یک جدول را امتحان می‌کنیم. نمونه آن جدول \ref{table} است.
\begin{table}
    \caption{جدول بلند}
    \begin{tabular}{p{0.2\linewidth} p{0.35\linewidth} p{0.05\linewidth} 
p{0.2\linewidth}}
        \hline نام متغیر & مرجع & تواتر & دوره زمانی
        \\ \hline 
        اول & دوم & سوم & چهارم \\                      
        \hline
        \label{table}
    \end{tabular}
\end{table}
\end{document}

1 Answer 1

1

I don't have the problem you've talked about. My output is as follows:

enter image description here

Maybe you should update your bidi and xepersian packages.

You must log in to answer this question.

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