应该掌握正确的提问姿势,提供最小工作示例。
阅读:https://ask.latexstudio.net/ask/article/644.html
文档具体采用的是哪一种字号(10pt?)? 是否调用caption宏包? 对间距的行为都有影响,因此MWE总是重要的。
既然已经在本站提过30+个问题,我不认为你不知道应该提供MWE...


应该掌握正确的提问姿势,提供最小工作示例。
阅读:https://ask.latexstudio.net/ask/article/644.html
10pt?)? 是否调用caption宏包? 对间距的行为都有影响,因此MWE总是重要的。

以下来自@u115385 分享:
模仿\raggedbottom、\flushbottom的方案:
\documentclass{article}
\usepackage[
paperwidth=120mm,
paperheight=80mm,
margin=10mm,
showframe
]{geometry}
\usepackage{lipsum}
\begin{document}
\makeatletter
\def\@texttop{\vskip \z@ \@plus 1fil}
\makeatother
\section{abc}
\lipsum[2-3]
\newpage
\section{def}
\lipsum[2][1-3]
\end{document}
忽然发现我有一点理解错...我以为你需要的是对所有文本没垂直居中的页面都居中... Anyway...
本着学习的心态,我咨询了 TSE 上circuitikz的大神 @cis
这里的目标是要实现「单端的」电位器元件Potentiometer,可以只使用其genericpotentiometershape 这一底层的 PGF 节点形状:

其他内容手动使用tikz的路径实现即可:
% https://ask.latexstudio.net/ask/question/17966.html
% https://tex.stackexchange.com/a/757977/322482
\documentclass[margin=5pt, multi=circuitikz]{standalone}
\usepackage{circuitikz}
\begin{document}
\begin{circuitikz}[
european,line width=1pt,line cap=round,
circuitikz/bipoles/thickness=1,% default = 2
% https://tex.stackexchange.com/a/758070/322482
% circuitikz/resistors/width=0.7,% default 0.8 ---> R and pR
circuitikz/bipoles/generic potentiometer/height 2=0.2,% default 0.3 --> only pR
% circuitikz/bipoles/generic/width=0.7,% default 0.8 --> only R
circuitikz/bipoles/generic/height=0.2,% default 0.3 --> only R
]
% R and Potentiometer
\draw (0,0)
to [rmeter, t=A, -*] (0,2) coordinate(A)
to [R, l_=R, name=r] (3,2) -- (4,2)
node[
genericpotentiometershape, %<-
anchor=west, label=below:R${}^\prime$,
] (pr) {};
% Battery and Potentiometer tap
\draw (0,0)
to[battery1] (3,0)
to[normal open switch, l_=S, n=S] (6,0)
|-(pr.wiper);
% Voltmeter
\coordinate (M) at ($(r)!.5!(pr)$);
\draw
(A) -- ++(0,1) coordinate(B)
to[rmeter, t=V] (B -| M)
-- (M) node[circ] {}; % node style circ <=> `-*'
\end{circuitikz}
\end{document}
补充一个测试记录:
以论文「Magnetic and mechanical hardening of nano-lamellar magnets using thermo-magnetic fields」为例
Step 1. 打开Nature官方链接:https://www.nature.com/articles/s41467-025-57571-6
Step 2. 找到「Cite this article」,点击下载「Download citation」将得到与你展示相同的一个「.ris」文件

『注意到上述示例的引用方式使用了「Article Number=2423」』
Step 3. 导入「Zotero」后使用原生的「bibtex」导出分类

这将得到如下的「refs.bib」文件:
@article{hanMagneticMechanicalHardening2025,
title = {Magnetic and mechanical hardening of nano-lamellar magnets using thermo-magnetic fields},
volume = {16},
issn = {2041-1723},
url = {https://doi.org/10.1038/s41467-025-57571-6},
doi = {10.1038/s41467-025-57571-6},
abstract = {High-performance magnetic materials based on rare-earth intermetallic compounds are critical for energy conversion technologies. However, the high cost and supply risks of rare-earth elements necessitate the development of affordable alternatives. Another challenge lies in the inherent brittleness of current magnets, which limits their applications for high dynamic mechanical loading conditions during service and complex shape design during manufacturing towards high efficiency and sustainability. Here, we propose a strategy to simultaneously enhance the magnetic and mechanical performance of a rare-earth-free multicomponent magnet. We achieve this by introducing nano-lamellar structures with high shape anisotropy into a cobalt–iron–nickel–aluminum material system through eutectoid decomposition under externally applied thermo-magnetic fields. Compared to the conventional thermally activated processing, the thermo-magnetic field accelerates phase decomposition kinetics, producing finer lamellae spacings and smaller eutectoid colonies. The well-tailored size, density, interface, and chemistry of the nano-lamellae enhance their pinning effect against the motion of both magnetic domain walls and dislocations, resulting in concurrent gains in coercivity and mechanical strength. Our work demonstrates a rational pathway to designing multifunctional rare-earth-free magnets for energy conversion devices such as high-speed motors and generators operating under harsh service conditions.},
language = {en},
number = {1},
journal = {Nature Communications},
author = {Han, Liuliu and Wang, Jin and Peter, Nicolas J. and Maccari, Fernando and Kovács, András and Schwaiger, Ruth and Gutfleisch, Oliver and Raabe, Dierk},
month = mar,
year = {2025},
pages = {2423},
}在zotero的策略下,默认将其保留为字段「pages」
Step 4 测试o( ̄▽ ̄)ブ 对于如下的MWEB:
\documentclass{article}
\usepackage{libertinus}
\usepackage[style=nature]{biblatex}
\begin{filecontents*}[overwrite]{refs.bib}
@article{hanMagneticMechanicalHardening2025,
title = {Magnetic and mechanical hardening of nano-lamellar magnets using thermo-magnetic fields},
volume = {16},
issn = {2041-1723},
url = {https://doi.org/10.1038/s41467-025-57571-6},
doi = {10.1038/s41467-025-57571-6},
abstract = {High-performance magnetic materials based on rare-earth intermetallic compounds are critical for energy conversion technologies. However, the high cost and supply risks of rare-earth elements necessitate the development of affordable alternatives. Another challenge lies in the inherent brittleness of current magnets, which limits their applications for high dynamic mechanical loading conditions during service and complex shape design during manufacturing towards high efficiency and sustainability. Here, we propose a strategy to simultaneously enhance the magnetic and mechanical performance of a rare-earth-free multicomponent magnet. We achieve this by introducing nano-lamellar structures with high shape anisotropy into a cobalt–iron–nickel–aluminum material system through eutectoid decomposition under externally applied thermo-magnetic fields. Compared to the conventional thermally activated processing, the thermo-magnetic field accelerates phase decomposition kinetics, producing finer lamellae spacings and smaller eutectoid colonies. The well-tailored size, density, interface, and chemistry of the nano-lamellae enhance their pinning effect against the motion of both magnetic domain walls and dislocations, resulting in concurrent gains in coercivity and mechanical strength. Our work demonstrates a rational pathway to designing multifunctional rare-earth-free magnets for energy conversion devices such as high-speed motors and generators operating under harsh service conditions.},
language = {en},
number = {1},
journal = {Nature Communications},
author = {Han, Liuliu and Wang, Jin and Peter, Nicolas J. and Maccari, Fernando and Kovács, András and Schwaiger, Ruth and Gutfleisch, Oliver and Raabe, Dierk},
month = mar,
year = {2025},
pages = {2423},
}
\end{filecontents*}
\addbibresource{refs.bib}
\begin{document}
hello\cite{hanMagneticMechanicalHardening2025}, world!
\printbibliography
\end{document}将得到:

style=nature...可能还需要一些biblatex选项...)
另附「谷歌学术镜像」导出的refs.bib文件:
@article{han2025magnetic,
title={Magnetic and mechanical hardening of nano-lamellar magnets using thermo-magnetic fields},
author={Han, Liuliu and Wang, Jin and Peter, Nicolas J and Maccari, Fernando and Kov{\'a}cs, Andr{\'a}s and Schwaiger, Ruth and Gutfleisch, Oliver and Raabe, Dierk},
journal={Nature Communications},
volume={16},
number={1},
pages={2423},
year={2025},
publisher={Nature Publishing Group UK London}
}也许找到稳定、靠谱的.bib源是一种智慧,也需要运气...
好像没有回答原始问题:
Article number (不是 pages) 在 BibTeX (bib) 参考文献应该如何表示?
「是否应该」应该是「参考文献的目录是否符合预期」的意思?
从上面例子来看,即使设置为「Pages」,对于「nature」样式,这个「article number」的表现是符合预期的。
注意到在 RIS 文件中 Article number 被放到了 SP 字段(如下),这个字段的含义大概是 start page。这应该也是错误的。
个人觉得不太应该怀疑 Nature 官网导出的.ris文件...根据wikipedia「https://en.wikipedia.org/wiki/RIS_(file_format)」的「RIS规范说明」,应该不算「错误」...我没进一步深入搜索了...

如果利用doi2bib工具,则会发现参考文献中没有Article number 2423
那我感觉是doi2bib的锅... 你可能是想报告doi2bib工具的bug? 新建issues
这是来自于 2020-2021 年的问题,当时没有妥善解决
如果当时有记录的链接,应该添加到这个页面,毕竟信息更多总是更方便后续查找的
类似的问答👇
如何使用latex打出类似向右推出、向左推不出的箭头? - kuing的回答 - 知乎
https://www.zhihu.com/question/622677788/answer/3217032851
基于luadraw宏包:
Notes: 需要自行安装、使用lualatex编译...
\documentclass[border=4pt]{standalone}
\usepackage{luadraw}
\begin{document}
\begin{luadraw}{name=implicit_function}
local g = graph:new{
window={-1,3.5,-2,2},size={10,10}
}
g:Linecap("round");g:Linewidth(8)
local F = function(x,y) return (x-2)^2+y^2-16/((x+2)^2) end
g:Dimplicit(F,{grid={500,500},draw_options="thick"})
g:Daxes(
{0,4,3},{
arrows="-stealth",
labelpos={"top","right"},
originpos={"none","none"}
}
)
g:Show()
\end{luadraw}
\end{document} 

代码不是看出来问题的,是复制,编译,多次测试debug之后才能解决的...
如果代码不可复制或不完整,别人测试就需要花费更多的时间...
\documentclass[tikz,border=5pt]{standalone}
\makeatletter
\def\tikz@plot@samples@recalc#1:#2\relax{%
\pgfmathparse{#1}%
\let\tikz@temp@start=\pgfmathresult%
\pgfmathparse{#2}%
\let\tikz@temp@end=\pgfmathresult%
\pgfmathparse{\tikz@temp@start + (\tikz@temp@end - \tikz@temp@start) / (\tikz@plot@samples - 1)}
\edef\tikz@plot@samplesat{\tikz@temp@start, \pgfmathresult, ..., \tikz@temp@end, \tikz@temp@end}
}
\makeatother
\begin{document}
\begin{tikzpicture}[very thin,domain=-1:{2*sqrt(2)}]
\draw[-stealth] (-1.5,0)--(3,0)node[scale=0.7,right]{$x$};
\draw[-stealth] (0,-3)--(0,3)node[scale=0.7,left]{$y$};
\node[label={[anchor=north east,yshift=-.1em]$o$}] {};
\draw plot[samples=300] (\x,{sqrt(16/(\x+2)^2-(\x-2)^2)});
\draw plot[samples=300] (\x, {-sqrt(16/(\x+2)^2-(\x-2)^2)});
\end{tikzpicture}
\end{document}
如果不是非要用「LaTeX」的话,最好的办法是使用类似「X-mind」的软件,有对应的模板。

同时可以导出为「.pdf」文件(这也是高清矢量图),这是最高效的办法。当然,如果你是要探索forest的功能上限,那这个问题也是很有意义的。
问题似乎并不难解决...虽然明显「xelatex」有严重的问题(「xelatex」什么时候彻底淘汰啊!!真该死啊!!)
另外,为何一定要使用polyglossia而不是babel,后者似乎没有"Contents"的目录问题,和ctex的兼容性更好。
首先其实你问了两个问题:
.toc里不慎引入脏东西导致的)目录的标题没有正确修改,相同的讨论可见:
省流:ployglossia内部也定义了\chinese,这导致了默认语言设置失效。可以使用如下的trick来避开重复的定义:
\let\mychinese\chinese
\let\chinese\relax
\setdefaultlanguage{chinese}
\setmainfont{FandolSong}
\let\chinese\mychinese章节条目显示为方框,其实解决方案也不太困难...
只要将
\begin{sanskrit}कृपयाविष्टमश्रुपूर्णाकुलेक्षणम्विषीदन्तमिदं\end{sanskrit}(或者同样在xe下有问题的)
\begin{otherlanguage}{sanskrit}
कृपयाविष्टमश्रुपूर्णाकुलेक्षणम्विषीदन्तमिदं
\end{otherlanguage}全部替换为
\textsanskrit{कृपयाविष्टमश्रुपूर्णाकुलेक्षणम्विषीदन्तमिदं}或者
\begin{otherlanguage*}{sanskrit}
कृपयाविष्टमश्रुपूर्णाकुलेक्षणम्विषीदन्तमिदं
\end{otherlanguage*}似乎则可以防止在.toc中写入脏东西(无论xe还是lua都work)
要把他们结合起来其实不太行,因为polyglossia似乎不允许分开设置西文和中文字体...可以先按下面这么凑合...
\documentclass[
UTF8,openany,
a4paper,zihao=-4,
fontset=none
]{ctexbook}
\usepackage[paperheight=17cm]{geometry}
\ctexset{
chapter/name = {第,章},
% section/name = {},
% contentsname = \hfill 目\ 录 \hfill,
}
\setCJKmainfont[BoldFont=KaiTi,ItalicFont=FangSong]{NSimSun}
\setmainfont[BoldFont=Times New Roman]{Times New Roman}
\usepackage{polyglossia}
\setotherlanguage{sanskrit}
\newfontfamily\sanskritfont[Script=Devanagari]{Sanskrit2003.ttf}
\begin{document}
\renewcommand{\contentsname}{目\ 录}%after \begin{document}!
\frontmatter
\tableofcontents
\chapter{导论}
梵语
\footnote{梵语(梵语:\textsanskrit{संस्कृता वाक्},Saṃskṛtā vāk,简称\begin{otherlanguage*}{sanskrit}संस्कृतम्\end{otherlanguage*},Saṃskṛtam;英语Sanskrit)属于印欧语系中印度–伊朗语族的印度–雅利安语支,是该语系中最古老的语言之一。和拉丁语一样,梵语已经成为一种属于学术和宗教的专门用语。虽然现代梵语的母语使用者非常少,但是因为梵文本身的特殊性,在现代佛教、印度教和耆那教的经典中依然可以随处找到梵语。古印度相信梵文是由梵天发明。}
优雅动听,是印度高等种姓以及更早雅利安人所说的语言,历史比其它任何已知语言都更为久远。
\chapter{梵语的格}
主格:用于句子的主语。宾格:用作直接宾语,也用于“to”表达的与格(间接宾语)。具格:在英语中用于“by”,“with”或“by means of”句式中。与格:在“for”,“to”或“toward”意思上使用。离格:在“of”和“from”意思上使用。
\begin{otherlanguage*}{sanskrit}
कृपयाविष्टमश्रुपूर्णाकुलेक्षणम्विषीदन्तमिदं
\end{otherlanguage*}
\mainmatter
\chapter{主格}
\textsanskrit{कृपयाविष्टमश्रुपूर्णाकुलेक्षणम्विषीदन्तमिदं}
\chapter{宾格}
\textsanskrit{कृपयाविष्टमश्रुपूर्णाकुलेक्षणम्विषीदन्तमिदं}
\chapter{具格}
\begin{otherlanguage*}{sanskrit}
कृपयाविष्टमश्रुपूर्णाकुलेक्षणम्विषीदन्तमिदं
\end{otherlanguage*}
\chapter{与格}
\textsanskrit{कृपयाविष्टमश्रुपूर्णाकुलेक्षणम्विषीदन्तमिदं}
\end{document}
事实上,如下的多个字体配置宏包功能可能相互冲突:
ctex(xeCJK/luatexja)bidibabelpolyglossia既然已经选定了使用polyglossia做杂语支持,一种workaround是可以直接使用polygollssia的框架,不过「字体选择似乎有些受限(无法实现西文用TNR中文用NSimSun)」且「会失去\ctexset与format的功能」...
polyglossia的方案没有细调的一份代码如下(使用titlesec和titletoc调整样式):
\documentclass[openany]{book}
\usepackage{zhlipsum}
\usepackage{zhnumber}
\usepackage{fontspec}
\usepackage{polyglossia}
% \setmainfont{Times New Roman}
% \setCJKmainfont{NSimSun}
% \setmainfont{NSimSun}
\setdefaultlanguage{chinese}
\setmainfont{Noto Serif CJK SC}
\setotherlanguage{sanskrit}
\newfontfamily\sanskritfont[Script=Devanagari]{Sanskrit2003.ttf}
\usepackage{setspace}%
\setstretch{1.5}%
\usepackage{titlesec}
\usepackage{titletoc}
\titleformat{\chapter}{\filcenter\Huge\bfseries}{第\zhnum{chapter}章}{1cm}{}
\titlecontents{chapter}[3.8em]{}{第\zhnumber{\thecontentslabel}章\quad}{}{\hfill\bfseries\thecontentspage}
\begin{document}
\frontmatter
\tableofcontents
\chapter{导论}
梵语\footnote{梵语(梵语:\begin{sanskrit}संस्कृता वाक्\end{sanskrit},Saṃskṛtā vāk,简称\begin{sanskrit}संस्कृतम्\end{sanskrit},Saṃskṛtam;英语Sanskrit)属于印欧语系中印度–伊朗语族的印度–雅利安语支,是该语系中最古老的语言之一。}优雅动听优雅动听,是印度高等种姓以及更早雅利安人所说的语言,这是一段中English 0123-4567英混排历史 history 比其它任何已知语言都更为久远。\zhlipsum[2]
\chapter{梵语的格}
主格:用于句子的主语。
\begin{sanskrit}कृपयाविष्टमश्रुपूर्णाकुलेक्षणम्विषीदन्तमिदं\end{sanskrit}
\mainmatter
\chapter{主格}
\begin{sanskrit}कृपयाविष्टमश्रुपूर्णाकुलेक्षणम्विषीदन्तमिदं\end{sanskrit}
\chapter{宾格}
\begin{sanskrit}कृपयाविष्टमश्रुपूर्णाकुलेक्षणम्विषीदन्तमिदं\end{sanskrit}
\chapter{具格}
\begin{sanskrit}कृपयाविष्टमश्रुपूर्णाकुलेक्षणम्विषीदन्तमिदं\end{sanskrit}
\chapter{与格}
\begin{sanskrit}कृपयाविष्टमश्रुपूर्णाकुलेक्षणम्विषीदन्तमिदं\end{sanskrit}
\end{document}
本人使用TeXstudio编辑器。因latex编译的.toc文件
为什么不从根源出发,直接修复.tex文件的问题。
但每次编译前都要修改文件太繁琐,想通过宏(Script Macros)命令解决。
从你的描述来看,这个问题和「对任意一个文本文件进行该操作」无异,只是这个文件恰好是「.toc」,因此可以认为这个问题和LaTeX其实不太相关。
曾尝试通过AI生成脚本,但执行总通不过。
你最好举例说明.toc文件的具体情况,具体要如何匹配「删除文件中全部有字符串\selectlanguage *{sanskrit}和\selectlanguage *[script=Devanagari,numerals=Devanagari]{sanskrit}的行;」。例如这里\selectlanguage其后是否总是有空格,是否除了这两种情况还可能有其他的情况,这都可能影响脚本的写法。
最好补充给一个.toc修改前的范例和预期的脚本处理结果。否则别人不容易复现和测试。
要注意阅读文档:
应该先明确这个「编辑宏」的功能支持哪些语法....「QFile未定义显然是因为TeXStudio的脚本功能不支持这个"类"...」
我稍微vibe了一下,下面这个脚本似乎可行:
function cleanToc() {
var texFile = app.getCurrentFileName();
if (!texFile) {
alert("没有打开任何文件。");
return;
}
var tocFile = texFile.replace(/\.[^.]+$/, "") + ".toc";
var content = readFile(tocFile);
if (content === undefined || content === null) {
alert("无法读取 " + tocFile);
return;
}
var lines = content.split(/\r?\n/);
var result = [];
var deleted = 0;
// 匹配所有 \selectlanguage *{sanskrit} 以及带可选参数的形式
var re = /^\s*\\selectlanguage\s*\*(?:\[[^\]]*\])?\{sanskrit\}/i;
for (var i = 0; i < lines.length; i++) {
var line = lines[i];
if (re.test(line.trim())) {
deleted++;
continue;
}
result.push(line);
}
writeFile(tocFile, result.join("\n"));
alert("清理完成:删除 " + deleted + " 行。\n文件:" + tocFile);
}
cleanToc();


其中
// 匹配所有 \selectlanguage *{sanskrit} 以及带可选参数的形式
var re = /^\s*\\selectlanguage\s*\*(?:\[[^\]]*\])?\{sanskrit\}/i;为匹配的正则表达式,可能要按需修改。
另外,为什么不从源头入手,「目录有问题」具体是哪里有问题?上述工作流非常不顺畅,而且路径也是写死的...
总的来说这个需求并不太合理....
\label{eq:06}」作为标签,设想你突然要增加一个编号公式,那么你很可能面临一次性修改eq:04~eq:20的窘境。可以使用有意义的名称例如「\label{eq:二次优化问题}」,这样引用也方便...aligned:\documentclass{article}
\usepackage[showframe]{geometry}
\usepackage{lipsum}
\usepackage{amsmath}
\begin{document}
\lipsum[2][1-5]
\begin{equation}
\begin{aligned}
\min _{a_{i}^{*}, a_{i}} \frac{1}{2} \sum_{i=1}^{n} \sum_{j=1}^{n} & \left(a_{i}^{*}-a_{i}\right)\left(a_{j}^{*}-a_{j}\right) \phi_{Z}\left(X_{i}\right)^{T} \phi_{Z}\left(X_{j}\right)-\sum_{i=1}^{n}\left[y_{i}\left(a_{i}^{*}-a_{i}\right)-\varepsilon\left(a_{i}^{*}+a_{i}\right)\right], \\
\text { s.t. } \quad & \sum_{i=1}^{n}\left(a_{i}^{*}-a_{i}\right)=0, \\
& 0 \leq a_{i}^{*}, a_{i} \leq C, \\
&%<-aligned in aligned inside equation;-)
\begin{aligned}
\phi_{Z}\left(X_{i}\right)^{T} \phi_{Z}\left(X_{j}\right)&=\varphi\left(K_{D E K F}\left(X_{i}, Z\right)\right)^{T} \varphi\left(K_{D E K F}\left(X_{j}, Z\right)\right), \\
& =\left\langle\varphi\left(K_{D E K F}\left(X_{i}, Z\right)\right), \varphi\left(K_{DEKF}\left(X_{j}, Z\right)\right)\right\rangle, \\
& =K\left(K_{D E K F}\left(X_{i}, Z\right), K_{D E K F}\left(X_{j}, Z\right)\right),
\end{aligned}
\end{aligned}
\end{equation}
\lipsum[2][1-5]
\end{document}
zref-clever的一个处理方案...目前最简便的方案还是需要修改elegantbook.cls...这对于已经frozen的项目是不友好的❗
.cls,则该模板已经不再是公开意义上的官方模板,不能再被叫做「elegantbook模板」,而只能是「myelegantbook模板」,且模板的使用者必须对该模板的修改负完全责任❗❗❗% elegantbook.cls#L1001-L1016
\DeclareTColorBox[auto counter,number within=\ELEGANT@thmcnt,usesamecnt,usecnt]{#1}{ g o t\label g }{
common,#3,
label type=#1,%<-add label type key here
IfValueTF={##1}
{ELEGANT@title={#1}{##1}}
{
IfValueTF={##2}
{ELEGANT@title={#1}{##2}}
{ELEGANT@title={#1}{}}
},
IfValueT={##4}
{
IfBooleanTF={##3}
{label={##4}}
{ELEGANT@label={#2}{##4}}
}
}若如此做,对于下面的MWE文件main.tex:
\documentclass[lang=cn,fontset=fandol]{elegantbook}
\geometry{paperheight=14cm}
\usepackage{zref-clever}
\zcRefTypeSetup{theorem}{
Name-sg={定理},name-sg={定理},
Name-pl={定理},name-pl={定理},
}
\zcRefTypeSetup{definition}{
Name-sg={定义},name-sg={定义},
Name-pl={定义},name-pl={定义},
}
\begin{document}
\chapter{111}
\begin{definition}{Wang定义}{Wang}
这是一个定义。
\end{definition}
\begin{theorem}{欧拉定理}{Euler}
这是一个定理。
\end{theorem}
\zcref{def:Osbert}
\zcref{def:Wong}
\zcref{def:Wang}
\chapter{222}
\begin{definition}{Wong定义}{Wong}
这是一个定义。
\end{definition}
\begin{definition}{Osbert定义}{Osbert}
这是一个定义。
\end{definition}
\begin{theorem}{欧几里得公理}{Euclide}
这是另一个定理。
\end{theorem}
\zcref{thm:Euler}
\zcref{thm:Euclide}
\end{document}将得到:

要想「不修改.cls文件」,关键在于在已经写死的\DeclareTColorBox{env}中,是否有简单的方法对每个env添加一个新的键值对...
不过要添加的label type恰好其值为#1,也不能说上面的实现是坏的。
Noted that:
tcolorbox在2023年才加入对zref-clever的支持elegantbook已经在2022-12-31停止维护...这个锅不太应该由本修改(改的不好)来背,算是「2025年」的今天需要为了一些版本更迭造成的时间摩擦付出一些小小的代价吧...如果有朝一日elegantbook能增加新的feature,本post也许可能提供些许帮助...
Hope it helps!
cleveref方案的一个处理方案感谢@听风看雨 的提示:
初始选项
crefname={bluebox}{blueboxes}实际上只是
\crefname{tcb@cnt@mybluebox}{bluebox}{blueboxes}换言之上述的第一个mwe可以有另一个「更内部」的实现:
\documentclass[12pt]{article}
\usepackage[
noheadfoot,
margin=8mm,
papersize={10cm,10cm},
]{geometry}
\usepackage{cleveref}
\usepackage{tcolorbox}
\newtcolorbox[
auto counter,
number within=section,
% crefname={bluebox}{blueboxes}
]{mybluebox}[2][]{
% label is label,% default value
colback=blue!5!white,
colframe=blue!75!black,
fonttitle=\bfseries,
title=Bluebox \thetcbcounter: #2,#1
}
% add here<-
\makeatletter
\crefname{tcb@cnt@mybluebox}{bluebox}{blueboxes}
\makeatother
\begin{document}
\section{Blue}
\begin{mybluebox}[label={myreference}]{My title}
This is an example.
\end{mybluebox}
\begin{mybluebox}[label={myreference2}]{My titletitle}
This is an example.
\end{mybluebox}
\noindent
\Cref{myreference}, \cref{myreference}\\
\Cpageref{myreference}, \cpageref{myreference}\\
\nameCref{myreference}, \namecref{myreference}\\
\labelcref{myreference}, \labelcpageref{myreference}\\
\Cref{myreference2}, \cref{myreference2}\\
\Cref{myreference,myreference2}, \cref{myreference,myreference2}\\
\end{document}同样可以得到:

这意味着我们在elegantlatex框架下,对于基于tcolorbox的fancy模式也只需要对相应的环境做如下的patch和cref设置即可:
% \usepackage{cleveref}
\makeatletter
\crefname{tcb@cnt@theorem}{\theoremname}{\theoremname}
\crefformat{tcb@cnt@theorem}{\theoremname~#2#1#3}
\crefmultiformat{tcb@cnt@theorem}{\theoremname~#2#1#3}{~和~#2#1#3}{,#2#1#3}{~和~#2#1#3}
\crefrangeformat{tcb@cnt@theorem}{\theoremname~#3#1#4~至~#5#2#6}
\crefname{tcb@cnt@definition}{\definitionname}{\definitionname}
\crefformat{tcb@cnt@definition}{\definitionname~#2#1#3}
\crefmultiformat{tcb@cnt@definition}{\definitionname~#2#1#3}{~和~#2#1#3}{,#2#1#3}{~和~#2#1#3}
\crefrangeformat{tcb@cnt@definition}{\definitionname~#3#1#4~至~#5#2#6}
\makeatother\documentclass[lang=cn,fontset=fandol]{elegantbook}
\geometry{paperheight=12cm}
\usepackage{cleveref}
\makeatletter
\crefname{tcb@cnt@theorem}{\theoremname}{\theoremname}
\crefformat{tcb@cnt@theorem}{\theoremname~#2#1#3}
\crefmultiformat{tcb@cnt@theorem}{\theoremname~#2#1#3}{~和~#2#1#3}{,#2#1#3}{~和~#2#1#3}
\crefrangeformat{tcb@cnt@theorem}{\theoremname~#3#1#4~至~#5#2#6}
\crefname{tcb@cnt@definition}{\definitionname}{\definitionname}
\crefformat{tcb@cnt@definition}{\definitionname~#2#1#3}
\crefmultiformat{tcb@cnt@definition}{\definitionname~#2#1#3}{~和~#2#1#3}{,#2#1#3}{~和~#2#1#3}
\crefrangeformat{tcb@cnt@definition}{\definitionname~#3#1#4~至~#5#2#6}
\makeatother
\begin{document}
\chapter{111}
\begin{definition}{\LaTeX 定义}{LaTeX}
这是\LaTeX{}的定义
\end{definition}
\begin{theorem}{欧拉定理}{Euler}
这是一个定理。
\end{theorem}
\begin{theorem}{毕达哥拉斯定理}{Bachagoras}
这是一个定理。
\end{theorem}
\cref{def:Osbert}
\cref{def:Wong,def:LaTeX,def:Wang}
\cref{def:Osbert,def:Wong,def:LaTeX,def:Wang}
\chapter{222}
\begin{definition}{Osbert定义}{Osbert}
这是一个定义。
\end{definition}
\begin{theorem}{欧几里得公理}{Euclide}
这是另一个定理。
\end{theorem}
\cref{thm:Euclide}
\cref{thm:Euler,thm:Bachagoras}
\cref{thm:Euler,thm:Bachagoras,thm:Euclide}
\chapter{333}
\begin{definition}{Wong定义}{Wong}
这是一个定义。
\end{definition}
\begin{definition}{Wang定义}{Wang}
这是一个定义。
\end{definition}
\end{document}这将得到:

问 如何调整图表标题与正文之间的间距