Sagittarius Rover
Sagittarius Rover
这家伙很懒,什么也没写!

注册于 3年前

回答
495
文章
0
关注者
19

补充一个测试记录:

以论文「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」文件

image.png

『注意到上述示例的引用方式使用了「Article Number=2423」』

Step 3. 导入「Zotero」后使用原生的「bibtex」导出分类

image.png

这将得到如下的「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}

将得到:

image.png

官网下效果对比(我不太确定官网是不是就是style=nature...可能还需要一些biblatex选项...)

image.png


另附「谷歌学术镜像」导出的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规范说明」,应该不算「错误」...我没进一步深入搜索了...

image.png

如果利用 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} 

image.png

image.png

请给完整、可复制的代码。

代码不是看出来问题的,是复制,编译,多次测试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}

image.png

如果不是非要用「LaTeX」的话,最好的办法是使用类似「X-mind」的软件,有对应的模板。

image.png

同时可以导出为「.pdf」文件(这也是高清矢量图),这是最高效的办法。当然,如果你是要探索forest的功能上限,那这个问题也是很有意义的。

问题似乎并不难解决...虽然明显「xelatex有严重的问题(「xelatex」什么时候彻底淘汰啊!!真该死啊!!)

另外,为何一定要使用polyglossia而不是babel,后者似乎没有"Contents"的目录问题,和ctex的兼容性更好。

最佳实践

首先其实你问了两个问题:

  • 标题为“Contents”而非“目录”
  • 章节条目显示为方框(这是由于在.toc里不慎引入脏东西导致的)

针对Question1:

目录的标题没有正确修改,相同的讨论可见:

省流:ployglossia内部也定义了\chinese,这导致了默认语言设置失效。可以使用如下的trick来避开重复的定义:

\let\mychinese\chinese
\let\chinese\relax
\setdefaultlanguage{chinese}
\setmainfont{FandolSong}
\let\chinese\mychinese

针对Question2:

章节条目显示为方框,其实解决方案也不太困难...

只要将

\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}

image.png

事实上,如下的多个字体配置宏包功能可能相互冲突:

  • ctex(xeCJK/luatexja)
  • bidi
  • babel
  • polyglossia

既然已经选定了使用polyglossia做杂语支持,一种workaround是可以直接使用polygollssia的框架,不过「字体选择似乎有些受限(无法实现西文用TNR中文用NSimSun)」且「会失去\ctexsetformat的功能」...

基于纯polyglossia的方案

没有细调的一份代码如下(使用titlesectitletoc调整样式):

\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}

image.png

本人使用TeXstudio编辑器。因latex编译的PDF文件目录有显示问题,需编译前修改.toc文件

为什么不从根源出发,直接修复.tex文件的问题。

但每次编译前都要修改文件太繁琐,想通过宏(Script Macros)命令解决。

从你的描述来看,这个问题和「对任意一个文本文件进行该操作」无异,只是这个文件恰好是「.toc」,因此可以认为这个问题和LaTeX其实不太相关。

曾尝试通过AI生成脚本,但执行总通不过。

你并未提供别人可以复现的所有必要信息。

你最好举例说明.toc文件的具体情况,具体要如何匹配「删除文件中全部有字符串\selectlanguage *{sanskrit}\selectlanguage *[script=Devanagari,numerals=Devanagari]{sanskrit}的行;」。例如这里\selectlanguage其后是否总是有空格,是否除了这两种情况还可能有其他的情况,这都可能影响脚本的写法。

最好补充给一个.toc修改前的范例和预期的脚本处理结果。否则别人不容易复现和测试。


Edited:

要注意阅读文档:

应该先明确这个「编辑宏」的功能支持哪些语法....「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();

但是你没有提供别人可以复现的条件...我无法测试...

Before

image.png

Run

image.png

After

image.png

其中

    // 匹配所有 \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}

image.png

基于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}

将得到:

image.png

要想「不修改.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}

同样可以得到:

image.png

这意味着我们在elegantlatex框架下,对于基于tcolorboxfancy模式也只需要对相应的环境做如下的patchcref设置即可:

% \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

Code

\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}

这将得到:

image.png

既然我在这里提到:

期待你自行探索wrapfig,wrapfig2以及夏老师的text-figure宏包的使用方法

稍微补充一下其他的方案:

基于两个minipage环境:

\documentclass[fontset=fandol]{ctexart}
\usepackage{showframe}
\usepackage{enumitem}
\usepackage{mathtools}
\usepackage{amsfonts}
\begin{document}
    \section{基于\texttt{minipage}的方案}
    \noindent 已知$\triangle ABC$中,$AB=AC=12$厘米,$BC=9$厘米,点$D$为$AB$中点。
    \par\vspace*{8pt}\noindent
    \begin{minipage}{.7\linewidth}%
        \begin{enumerate}[
            label={(\arabic*)},
            labelindent=1em,
            labelwidth=0.2em,
            labelsep=0.2em,
            leftmargin=3em,
            % parsep=-2pt,
            nosep,%<-我更推荐这个选项
        ]
        \item 如果点$P$在线段$BC$上以3厘米秒的速度由$BC$运动,同时点$Q$在线段$CA$上由$C$点向$A$点运动。若点$Q$的运动速度与点$P$的运动速度相等,当运动1秒时,$\triangle BPD$与$\triangle CQP$是否全等?若点$Q$的运动速度与点$P$的运动速度不相等,当点$Q$的运动速度为多少时,$\triangle BPD \cong \triangle CPQ$?
        \item 若点$Q$以(1)中,的速度从点 $C$ 出发,点 $P$ 以原来运动速度从点$B$出发,都逆时针沿$\triangle ABC$三边运动,多长时间$P$与$Q$第一次相遇,此时在$\triangle ABC$哪条边上相遇?
        \end{enumerate}
    \end{minipage}%
    \begin{minipage}{.3\linewidth}
        \begin{center}
            \includegraphics[width=3.5cm,height=6cm]{example-image-duck}
        \end{center}
    \end{minipage}%
\end{document}

基于text-figure宏包

这个包是@u10945 基于写的,没有发在CTAN上,需要自行下载(需要在这里获取text-figure_usermanual.pdf
)...如非必要,可以不使用...

我在这里做演示,也同样只是锻炼一下自己"一题多解"的能力...

\documentclass[fontset=fandol]{ctexart}
\usepackage{showframe}
\usepackage{enumitem}
\usepackage{mathtools}
\usepackage{amsfonts}
\usepackage{text-figure}
\begin{document}
    \section{基于\texttt{text-figure}的方案}
    \noindent 已知$\triangle ABC$中,$AB=AC=12$厘米,$BC=9$厘米,点$D$为$AB$中点。
    \textfigure[fig-pos = right,text-ratio=.68]{
        \begin{enumerate}[
            label={(\arabic*)},
            labelindent=1em,
            labelwidth=0.2em,
            labelsep=0.2em,
            leftmargin=3em,
            nosep,%<-我更推荐这个选项
        ]
        \item 如果点$P$在线段$BC$上以3厘米秒的速度由$BC$运动,同时点$Q$在线段$CA$上由$C$点向$A$点运动。若点$Q$的运动速度与点$P$的运动速度相等,当运动1秒时,$\triangle BPD$与$\triangle CQP$是否全等?若点$Q$的运动速度与点$P$的运动速度不相等,当点$Q$的运动速度为多少时,$\triangle BPD \cong \triangle CPQ$?
        \item 若点$Q$以(1)中,的速度从点 $C$ 出发,点 $P$ 以原来运动速度从点$B$出发,都逆时针沿$\triangle ABC$三边运动,多长时间$P$与$Q$第一次相遇,此时在$\triangle ABC$哪条边上相遇?
        \end{enumerate}
    }{
        \includegraphics[width=3.5cm,height=6cm]{example-image-duck}
    }
\end{document}

image.png

基于wrapstuff宏包

\documentclass[fontset=fandol]{ctexart}
\usepackage{showframe}
\usepackage{enumitem}
\usepackage{mathtools}
\usepackage{amsfonts}
\usepackage{wrapstuff}
\usepackage{lipsum}%
\begin{document}
    \section{基于\texttt{wrapstuff}的方案}
    
    \lipsum[2]

    \noindent 已知$\triangle ABC$中,$AB=AC=12$厘米,$BC=9$厘米,点$D$为$AB$中点。
    \begin{wrapstuff}[r,top=0] 
        \includegraphics[width=3.5cm,height=6cm]{example-image-duck}
    \end{wrapstuff} 
    \begin{enumerate}[
        label={(\arabic*)},
        labelindent=1em,
        labelwidth=0.2em,
        labelsep=0.2em,
        leftmargin=3em,
        nosep,%<-我更推荐这个选项
    ]
    \item 如果点$P$在线段$BC$上以3厘米秒的速度由$BC$运动,同时点$Q$在线段$CA$上由$C$点向$A$点运动。若点$Q$的运动速度与点$P$的运动速度相等,当运动1秒时,$\triangle BPD$与$\triangle CQP$是否全等?若点$Q$的运动速度与点$P$的运动速度不相等,当点$Q$的运动速度为多少时,$\triangle BPD \cong \triangle CPQ$?
    \item 若点$Q$以(1)中,的速度从点 $C$ 出发,点 $P$ 以原来运动速度从点$B$出发,都逆时针沿$\triangle ABC$三边运动,多长时间$P$与$Q$第一次相遇,此时在$\triangle ABC$哪条边上相遇?
    \end{enumerate}
    \wrapstuffclear

    \lipsum[2]
\end{document}

image.png

需要指出的是,wrapstuff实现的是「图文环排」,而不只是「图文并排」。前者的难度远高于后者,详见wrapstuff文档。

image.png

加上overlay.

\documentclass{ctexbeamer}
\usepackage{tikz}
\usetikzlibrary{calc}
\setbeamertemplate{footline}{
   %\hspace*{-0.2pt}%
  \begin{tikzpicture}
    \def\r{1pt}
    \def\d{0.3pt}
    \coordinate (A) at (0,1.3em);
    \coordinate (B) at ($(A)+(0:{\paperwidth-(\r)-(\d)})$);
    \draw[red,overlay] (A)--(B);
    \fill[fill=white,line width=\d] (B) circle (\r);
    \node[anchor=south west,inner sep=0pt,outer sep=0pt,fill=red] at (0,0){\color{white}测试测试测试};
  \end{tikzpicture}
}
\begin{document}
\begin{frame}
  测试
\end{frame}
\end{document}

具体原因我也不是非常清楚,因为\draw (A)--(B);会向左增大整个tikzpicturebounding box.
我相信其他坛友能给出更详细的解释...

image.png

阅读: 提问的智慧

请言之有物

  • 具体是什么国家标准?
  • 具体的下载链接是什么?
  • 你是如何编译的?
  • 上面的信息是报错信息?还是?

要避免模糊的描述让别人做猜测,同时要小心XY-problem

提问最好给个具体的例子,并指明预期效果,否则让人很难理解...

试试...

\documentclass{beamer}
\usetheme{moloch}
\usepackage{etoolbox}
\makeatletter
\newcount\beamer@sectionstartframe
\beamer@sectionstartframe=1
\apptocmd{\beamer@section}{\addtocontents{nav}{\protect\headcommand{%
            \protect\beamer@sectionframes{\the\beamer@sectionstartframe}{\the\c@framenumber}}}}{}{}
\apptocmd{\beamer@section}{\beamer@sectionstartframe=\c@framenumber\advance\beamer@sectionstartframe by1\relax}{}{}
\AtEndDocument{\immediate\write\@auxout{\string\@writefile{nav}%
        {\noexpand\headcommand{\noexpand\beamer@sectionframes{\the\beamer@sectionstartframe}{\the\c@framenumber}}}}}{}{}
\def\beamer@startframeofsection{1}
\def\beamer@endframeofsection{1}
\def\beamer@sectionframes#1#2{%
    \ifnum\c@framenumber<#1%
    \else%
    \ifnum\c@framenumber>#2%
    \else%
    \gdef\beamer@startframeofsection{#1}%
    \gdef\beamer@endframeofsection{#2}%
    \fi%
    \fi%
}
\newcommand\insertsectionstartframe{\beamer@startframeofsection}
\newcommand\insertsectionendframe{\beamer@endframeofsection}
\makeatother

\setbeamertemplate{headline}{
    \Large\sffamily 
    \inteval{\insertframenumber - \insertsectionstartframe + 1} 
    /
    \inteval{\insertsectionendframe - \insertsectionstartframe + 1}
}

\begin{document}
\begin{frame}sec=0,framenumber=1\end{frame}
\begin{frame}sec=0,framenumber=2\end{frame}
\begin{frame}sec=0,framenumber=3\end{frame}
\section{Sec1}
\begin{frame}sec=1,framenumber=1
    \begin{itemize}
        \item<1-> First item
        \item<2> Second item
        \item<3-> Third item
    \end{itemize}
\end{frame}
\begin{frame}sec=1,framenumber=2\end{frame}
\begin{frame}sec=1,framenumber=3\end{frame}
\section{Sec2}
\begin{frame}sec=2,framenumber=1\end{frame}
\begin{frame}sec=2,framenumber=2\end{frame}
\section{Sec3}
\begin{frame}sec=3,framenumber=1\end{frame}
\begin{frame}sec=3,framenumber=2\end{frame}
\begin{frame}sec=3,framenumber=3\end{frame}
\begin{frame}sec=3,framenumber=4
    \begin{itemize}
        \item<1-> First item
        \item<2-> Second item
        \item<3> Third item
        \item<4-> Third item
    \end{itemize}
\end{frame}
\begin{frame}sec=3,framenumber=5\end{frame}
\end{document}

output_1.png

发布
问题