引用章节时出现问题

引用章节时出现问题

我目前正在完成我的论文。由于我刚接触 Latex,所以我在所见即所得的软件中编写了 99% 的文档,然后将其导出为 Latex 项目,并对其进行了一些修改,使其成为一个不错的项目。我快完成了,但我发现了两个问题,其中之一是引用章节时,编译后的文本没有反映引用的标签。

\chapter{Introducción}

\label{cap:1}

\hypertarget{sec:1.1}{\section{Sistemas de error de foco y medio óptico de almacenamiento}\label{sec:1.1}}

This is a reference to Chapter \ref{cap:1}. And this is a reference to Section \ref{sec:1.1.1}.
Here I mean to reference chapter two, but it compiles like a section to Section one point three like so  \ref{cap:2}.
Which is the last label before label "cap:2".


{\color[rgb]{0.2627451,0.2627451,0.2627451}
\hypertarget{sec:1.1.1}{\subsection{Reseña}}\label{sec:1.1.1}}

我得到的是:

在此处输入图片描述

章节、小节和小节都引用正确。第一章根本没有引用,其他章节的引用被编译为对最后一个有效标签的引用。我查看了其他问题和其他示例,似乎都没有这个问题。

我将每一章都写在单独的文件中,然后将它们包含在主文件中,如下所示:

%Empiezo a contar las páginas en arábigos
        \pagenumbering{arabic}
            % Agrego los capítulos
            \setcounter{chapter}{1}
            \include{Capitulo_I/Capitulo_I}
            \setcounter{chapter}{2}
            \setcounter{section}{0}
            \setcounter{equation}{0}
            \setcounter{table}{0}
            \setcounter{figure}{0}
                \include{Capitulo_II/Capitulo_II}

我的序言很乱,因为我是从一本关于 Latex 的书中摘取的,然后添加了我需要的东西,有些是由合作者添加的,我把它复制到这里以防万一。

\documentclass[a4paper, 11pt, twoside, openright, titlepage]{book}
\frontmatter
    % Basic packages
    \usepackage[spanish]{babel}
    \usepackage{float} % For new floating environments
    \usepackage{stmaryrd,amssymb,amsmath} % For mathematical symbols and equations
    \usepackage{array} % For arrays of equations
    \usepackage{epsfig,graphicx,subfigure} % For inserting figures
    \usepackage{sidecap}
    \sidecaptionvpos{figure}{c}
    \usepackage{wrapfig} % For wraping texts around tables and figures
    \usepackage{tabularx} % For auto-adjusted column widths in tables
    \usepackage{multirow} % For merging cells in tables
     \usepackage{multicol} %Para usar varias columnas
        \setlength{\columnsep}{0.5cm}
    \usepackage{longtable} % For multi-page tables
    \usepackage{rotating} % For rotating a page (landscape) or inclined texts
    \usepackage{caption} % For adjusting captions of tables and figures
    \captionsetup[table]{skip=10pt}
    \usepackage{color} % For writing colored texts
    \usepackage{setspace} % For adjusting line spacing
    %\usepackage{boxedminipage,fancybox} % For boxed texts
    %\usepackage{shadow} % For creating shaded box
    \usepackage{natbib} % For bibliographic references
    \usepackage{varioref} % For referring through \vref{} & \vpageref{}
    \usepackage{url} % For citing URL
    \usepackage{makeidx} % For generating index
    \usepackage[top=2.5cm,bottom=2.5cm,left=2.5cm,right=2.5cm,head,foot]{geometry}
   
    
    \usepackage[utf8]{inputenc} %para escribir acentos (letras no anglosajonas)
    \setcounter{secnumdepth}{4} %para que ponga 1.1.1.1 en subsubsecciones
    \setcounter{tocdepth}{4} % para que ponga subsubsecciones en el indice
    \usepackage{hyperref} % Para Hyperenlaces
    \usepackage{supertabular}
    \usepackage{hhline}
    \makeatletter
        \newcommand\arraybslash{\let\\\@arraycr}
    \makeatother
    %\usepackage{siunitx}
    \usepackage[table]{xcolor}
    \usepackage[graphicx]{realboxes}
    \usepackage{rotating}
    \usepackage{pdflscape}
    \usepackage{afterpage}
    \usepackage{textcomp}
    \usepackage[capitalise]{cleveref}
    %
    \makeindex % Generate index
    % Blank space adjustment
    \abovecaptionskip % Skips extra space above a caption
    \belowcaptionskip % Skips extra space below a caption
    \raggedbottom % Top aligning a page leaving space at the bottom
    % User-defined new commands
    \definecolor{ugray}{gray}{0.25} %User-defined gray color ‘ugray’
    \newcommand{\tgray}{\textcolor{ugray}} % ‘\tgray{}’ for writing in user-defined ‘ugray’
    \newcommand{\tred}{\textcolor{red}} % ‘\tred{}’ for writing in red
    \newcommand{\vctr}[1]%
    {\mbox{\boldmath{$#1$}}} % Prints x as a vector through \vctr{x}
    %\newtheorem{thm}{Theorem} % Environment ‘thm’ for writing theorems
    %\newtheorem{dfn}{Definition} % Environment ‘dfn’ for writing definitions
    %\newtheorem{lem}{Lemma} % Environment ‘lem’ for writing lemmas
    
    \DeclareMathOperator{\sen}{sen}
    \DeclareMathOperator{\tg}{tg}
    \DeclareMathOperator{\arctg}{arctg}
    \DeclareMathOperator{\tgh}{tgh}
    

    \addto\captionsspanish{\renewcommand{\listfigurename}{Índice de Figuras}}
    \addto\captionsspanish{\renewcommand{\listtablename}{Índice de Tablas}}
    \addto\captionsspanish{\renewcommand{\tablename}{Tabla}}
    \definecolor{verdecito}{rgb}{0.7, 0.95, 0.8} 
    
    \newcommand\scalemath[2]{\scalebox{#1}{\mbox{\ensuremath{\displaystyle #2}}}}

任何帮助都非常感谢。谨致问候!

答案1

它是一个真的从未记录的模板开始不是一个好主意,最好从\documentclass{book}一个空的序言开始,只添加你知道你需要的东西。

您的主要问题在于

\frontmatter

这绝不应该出现在序言中,而应该(如果使用的话)出现\begin{document}在前面几页之后,以\mainmatter恢复正常行为。

\frontmatter禁用章节计数和标记,为目录等内容提供未编号的标题。

如果你删除它,那么章节编号将恢复,你也可以替换

            \setcounter{chapter}{1}
            \include{Capitulo_I/Capitulo_I}
            \setcounter{chapter}{2}
            \setcounter{section}{0}
            \setcounter{equation}{0}
            \setcounter{table}{0}
            \setcounter{figure}{0}
                \include{Capitulo_II/Capitulo_II}

经过

            \include{Capitulo_I/Capitulo_I}
            \include{Capitulo_II/Capitulo_II}

不要epsfig在任何文档中加载包,而只加载您使用的包(您不太可能使用您正在加载的大多数包),例如您是否同时拥有 supertabular 和 longtable?

\hypertarget{sec:1.1}{\section{Sistemas de error de foco y medio óptico de almacenamiento}\label{sec:1.1}}

可以简单地

\section{Sistemas de error de foco y medio óptico de almacenamiento}\label{sec:1.1}

尽管最好避免使用数字\label{Sistemas-de-error}或诸如此类的东西。

构造

    \abovecaptionskip % Skips extra space above a caption
    \belowcaptionskip % Skips extra space below a caption

实际上是

    \abovecaptionskip=\belowcaptionskip 

因此将上面的跳过设置为下面的跳过(在书中默认为 0pt),如果行是按照其他顺序排列的,则它会将它们都设置为 10pt。

相关内容