[英]Latex chapter refrencing giving the last chapter last section reference
我在引用一章时遇到问题。 我在每个标题下面都使用了一个标签,但它没有给出正确的参考。 我尝试了一些修复,但没有奏效(nameref、varioref、cleveref)
我的乳胶代码如下
\documentclass[12pt,a4paper]{book}
\usepackage[utf8]{inputenc}
\usepackage[french,arabic,english]{babel}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\graphicspath{{images/}}
\usepackage{float}
\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry}
\usepackage{arabtex}
\usepackage{multirow}
\usepackage{threeparttable}
\usepackage{utf8}
\usepackage{longtable}
\usepackage{url}
\usepackage[colorinlistoftodos]{todonotes}
\usepackage{breakcites}
\usepackage{hhline}
\usepackage{xcolor}
\usepackage{colortbl}
%\usepackage{asect}
\usepackage{tocbibind}
\usepackage{tocloft}
\usepackage{acro}
\input{annexes/abreviations}
\usepackage[colorlinks]{hyperref}
\hypersetup{
colorlinks=true,
linkcolor=blue,
filecolor=magenta,
urlcolor=cyan,
citecolor=violet
}
% ref packages
\usepackage{nameref}
% folowing must be in this order
\usepackage{varioref}
\usepackage{hyperref}
\usepackage{cleveref}
\begin{document}
\input{chapters/chap1.tex}
\input{chapters/chap2.tex}
\input{chapters/chap3.tex}
\input{chapters/chap4.tex}
\bibliographystyle{apalike}
\bibliography{bibliography}
\end{document}
在第 1 章
\chapter{title1}
\label{chap1}
here is defined the label{chap1}
\section{section1}
this is section1
\section{section1}
this is section1
\section{section1}
this is section1
在第 3 章
\chapter{title3}
\label{chap3}
text reference Chapter \ref{chap1}
但是,参考资料显示了第 1 章的最后一节
我正在使用 texmaker 快速构建来编译代码。 这是背面的完整示例https://www.overleaf.com/read/rxkmhxcbcgqc我们还可以注意到,引用第一章是行不通的。
一个最小的非工作示例是
\documentclass{book}
\usepackage[arabic,english]{babel}
\begin{document}
\chapter{title}\label{key}
test \ref{key}
\end{document}
您可以使用https://tex.stackexchange.com/a/238442/36296 中的方法解决此问题
\documentclass{book}
\usepackage[arabic,english]{babel}
\makeatletter
\def\@part[#1]#2{%
\addtocontents{toc}{\xstring\select@language{\main@Arabi@language}}%
\if@rl\SAV@@part[\textRL{#1}]{\textRL{#2}}%
\else\SAV@@part[\textLR{#1}]{\textLR{#2}}%
\fi}
\def\@spart#1{%
\addtocontents{toc}{\xstring\select@language{\main@Arabi@language}}%
\if@rl\SAV@spart{\textRL{#1}}%
\else\SAV@spart{\textLR{#1}}%
\fi}
\def\@chapter[#1]#2{%
\addtocontents{toc}{\xstring\select@language{\main@Arabi@language}}%
\if@rl\SAV@@chapter[\textRL{#1}]{\textRL{#2}}%
\else\SAV@@chapter[\textLR{#1}]{\textLR{#2}}%
\fi}
\def\@schapter#1{%
\addtocontents{toc}{\xstring\select@language{\main@Arabi@language}}%
\if@rl\SAV@schapter{\textRL{#1}}%
\else\SAV@schapter{\textLR{#1}}%
\fi}
\makeatother
\begin{document}
\chapter{title}\label{key}
test \ref{key}
\end{document}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.