我最近发现了“cref”。对于公式、图形和表格非常实用。但对于引用多个部分,它不起作用。
具体例子:
(顺便说一下,抱歉标签太长)
Chapters \mref{par: Theoretical Background OPF SOPF SOPF in load space,par: Theoretical Background OPF SOPF SOPF in load space in practice}
给出:
第 2.7.5.2 章、第 2.7.5.3 章
作为输出,而
Chapters \cref{par: Theoretical Background OPF SOPF SOPF in load space,par: Theoretical Background OPF SOPF SOPF in load space in practice}
给出:
章节??2.7.5.2??2.7.5.3
作为输出。
为什么会这样?我该怎么办?
更新:
我在下面粘贴了一个小的 .tex 示例文件:
\documentclass[a4paper]{article}
\usepackage[ireport]{KTHEEtitlepage}
% Packages used in the main document for this particular example:
\usepackage{url}
\usepackage{amstext}
\usepackage[english]{babel} % swedish
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{hyperref}
\usepackage{amsmath}
\usepackage{amsfonts} % mathbb
\usepackage{xparse}
\usepackage{dsfont}
\usepackage{graphicx}
\usepackage{tikz}
\usepackage{pgf}
\usepackage{pgfplots}
\usetikzlibrary{plotmarks}
\usepackage{pgfmath}
\usepackage[nocompress]{cite}
\usepackage{hyperref}
\usepackage[capitalize]{cleveref}
\newcommand{\sgn}{\operatorname{sgn}}
\ExplSyntaxOn
\NewDocumentCommand{\mref}{m}{\quinn_mref:n {#1}}
\seq_new:N \l_quinn_mref_seq
\cs_new:Npn \quinn_mref:n #1
{
\seq_set_split:Nnn \l_quinn_mref_seq { , } { #1 }
\seq_pop_right:NN \l_quinn_mref_seq \l_tmpa_tl
% ( % print the left parenthesis
\seq_map_inline:Nn \l_quinn_mref_seq
{ \ref{##1},\nobreakspace } % print the first references
\exp_args:NV \ref \l_tmpa_tl % print the last or only one
% ) % print the right parenthesis
}
\ExplSyntaxOff
\begin{document}
\ititle{This is a report, Revision date 2016-10-21}
\isubtitle{This is the subtitle}
\iauthor{Lars Abrahamsson}
\idate{2016}
\irefnr{Report number 345474574567457}
\iaddress{At research group \\
At department \\
At University }
\makeititle
\setcounter{tocdepth}{5}
\setcounter{secnumdepth}{5}
% Everything below is exactly as for a normal document and
% the layout of that document should not be affected in any
% way by the title page.
\title{The title}
\author{The Author}
\tableofcontents
\listoftables
\listoffigures
\maketitle
\section{Test 1}
\label{sec: Test 1}
sdgdffg
\section{Test 2}
\label{sec: Test 2}
xfbgdfhhfd
Please, refer to \cref{sec: Test 1,sec: Test 3}
\section{Test 3}
\label{sec: Test 3}
Please, refer to Chapters \mref{sec: Test 1,sec: Test 2}.
\paragraph{Paragraph with short label}
\label{par: Short Name}
fff
Just cref: \cref{par: Short Name}
\subsubsection{Balle}
\label{subsubs: balle}
Just cref: \cref{subsubs: balle}
\end{document}
第 2 页(相关页面)的输出将变成如下图所示:
答案1
完成您的代码以创建一个最小示例,唯一的问题是我需要删除Chapters
并使用\Cref
才能正确使用大写字母。
\documentclass{book}
\usepackage{cleveref}
\begin{document}
\chapter{a}\label{par: Theoretical Background OPF SOPF SOPF in load space}
\chapter{b}\label{par: Theoretical Background OPF SOPF SOPF in load space in practice}
\Cref{par: Theoretical Background OPF SOPF SOPF in load space,par: Theoretical Background OPF SOPF SOPF in load space in practice}
\end{document}
但是,在章节标签中使用 Unless 会让人感到困惑par:
。我建议改用chap:
or或其他形式。(当然,ch:
Unlesspar
是您所用语言中 for 的缩写。)chapter
答案2
您需要提供说明
\crefname{paragraph}{paragraph}{paragraphs}
\Crefname{paragraph}{Paragraph}{Paragraphs}
告知cleveref
在排版与计数器关联的对象的交叉引用时应使用哪个标签paragraph
。
如果您要subparagraph
在文档中使用编号级标题,并且需要使用 进行交叉引用\cref
,则还需要提供以下说明:
\crefname{subparagraph}{paragraph}{paragraphs}
\Crefname{subparagraph}{Paragraph}{Paragraphs}
我不会使用“小段落”作为标签——它对我来说看起来很笨重。