From f99f4526cf65f64f9128b513590aa5eabcbae2b2 Mon Sep 17 00:00:00 2001 From: Rizhong Lin Date: Thu, 30 May 2024 14:39:56 +0800 Subject: [PATCH] fix: multiple cleveref items in Chinese --- sections/03_reference.tex | 24 ++++++++++++++++++++++++ style/tongjithesis.sty | 14 ++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/sections/03_reference.tex b/sections/03_reference.tex index 9158d05..b892726 100644 --- a/sections/03_reference.tex +++ b/sections/03_reference.tex @@ -141,4 +141,28 @@ \section{引言} \end{Verbatim} 这样,使用 \verb|\cref| 命令引用定理对象时,就会自动生成“请参见命题 X”的效果。 +需要同时引用几个并列的对象时,可以直接使用 \verb|\cref| 命令,例如: +\begin{Verbatim} +请参见\cref{sec:introduction,sec:conclusion}。 +请参见\cref{sec:introduction,sec:conclusion}。 +请参见\cref{sec:introduction,sec:math,sec:reference,sec:float}。 +请参见\cref{sec:introduction,sec:math,sec:reference,,sec:float}。 +请参见\cref{sec:introduction,sec:reference,sec:conclusion}。 +请参见\cref{sec:introduction,sec:reference,sec:conclusion,% + algo:algorithm,fig:parallel1,lst:fibonacci}。 +\end{Verbatim} + +这样,就可以在文档中产生“请参见章节 X 和 Y”的效果,其中 X 和 Y 为标签所在章节的编号: +\begin{itemize} + \item 请参见\cref{sec:introduction,sec:conclusion}。 + \item 请参见\cref{sec:introduction,sec:conclusion}。 + \item 请参见\cref{sec:introduction,sec:math,sec:reference,sec:float}。 + \item 请参见\cref{sec:introduction,sec:math,sec:reference,,sec:float}。 + \item 请参见\cref{sec:introduction,sec:reference,sec:conclusion}。 + \item 请参见\cref{sec:introduction,sec:reference,sec:conclusion,% + algo:algorithm,fig:parallel1,lst:fibonacci}。 +\end{itemize} + +上面的例子中,我们展示了如何使用 \verb|\cref| 命令引用多个并列的对象。在引用多个对象时,\pkg{cleveref} 宏包会自动根据对象类型生成正确的引用词汇,并使用适当的连接词将多个对象连接起来。 + 总之,交叉引用是撰写文档时非常有用的功能,可以方便读者查找相关内容。在使用交叉引用时,可以选择使用 \verb|\ref| 命令手动指定引用词汇,也可以使用 \verb|\cref| 命令自动根据对象类型生成引用词汇。同时,\pkg{cleveref} 宏包可以帮助用户自动设置正确的引用词汇,提高文档的可读性。 \ No newline at end of file diff --git a/style/tongjithesis.sty b/style/tongjithesis.sty index 0d73303..974d542 100644 --- a/style/tongjithesis.sty +++ b/style/tongjithesis.sty @@ -174,7 +174,16 @@ \crefname{proof}{证明}{证明} \crefname{algorithm}{算法}{算法} \crefname{listing}{代码}{代码} - +% 连续引用的连接词需改为中文 +\newcommand{\crefpairconjunction}{ 和~} +\newcommand{\crefmiddleconjunction}{、} +\newcommand{\creflastconjunction}{ 和~} +\newcommand{\crefpairgroupconjunction}{ 和} +\newcommand{\crefmiddlegroupconjunction}{、} +\newcommand{\creflastgroupconjunction}{ 和} +\newcommand{\crefrangeconjunction}{ 至~} +% \newcommand{\crefrangepreconjunction}{} +% \newcommand{\crefrangepostconjunction}{} % 一些文档中用到的 logo \usepackage{hologo} @@ -187,5 +196,6 @@ \fvset{% breaklines=true, % enable line breaking linenos=true, % show line numbers - mathescape=true % enable math mode escape + mathescape=true, % enable math mode escape + breakanywhere=true, % allow line breaks anywhere }