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

注册于 3年前

回答
449
文章
0
关注者
15

@u26254 有一个2023年才出现的子库tikz-nfold: https://ctan.org/ctan-ann/pkg/tikz-nfold

\documentclass[tikz,border=5pt]{standalone}
\usetikzlibrary{nfold}
\begin{document}

\tikz\draw[double,teal] (0,0) rectangle (1,1);

\tikz\draw[double distance=1pt,nfold=3,violet] (0,0) rectangle (1,1);

\tikz\draw[line join=round, double distance=4pt, nfold=4, magenta] (0,0) rectangle (1,1);

\end{document}

image.png

Refs: https://tex.stackexchange.com/a/692283/322482

描述不完整

请尽可能补充更多的信息,一步步告诉别人你做了什么,以便别人复现你的问题...

例如:

由于siunitxphysics宏包冲突报错,故删去相关部分并停止使用physics宏包

具体删除了哪个文件的哪个部分,原先所谓「siunitxphysics宏包冲突报错」的报错信息是什么?

使用模板【非官方】天津大学的 LaTeX 试卷模板编写试卷

你贴的链接需要20积分下载,这意味着每个想回答问题的人都得花20积分,这对潜在的回答者不友好...

报错信息如下图,具体表现为无法编译文件,无法生成*.log*.toc*.aux等文件。

你图示的报错信息是从清除辅助文件开始的,并不完整,如有可能,应该补充完整。

但修改后仍无法编译文件,且重新下载原模板并打开也无法编译。

在重新编译的时候你是否删除了全部中间辅助文件再开始(?)


另外,不知为什么,我从链接处下载的文件中的设置文件名为:TJ-exam-8kai-settings.tex

而在TJ-exam-8kai.tex中的第二行却只有\input{settings}

\documentclass[AutoFakeBold,twocolumn,zihao=-4,UTF8,answers]{ctexart} % 
% \input{settings} 
\input{TJ-exam-8kai-settings}% 我做的替换

这点你完全没提到,情况是相同的吗?


由于latexmk会自动执行多个编译命令,只是方便了运行,但是不方便debug. 所以最好依次执行xelatex等一系列命令查看报错信息.

在windows11+TL2025上使用xelatex TJ-exam-8kai.tex编译上面的代码是可以得到.log的(不知道为什么.log上传不了...):

注意其中最后几行:

% Line 1497  TJ-exam-8kai.log
[2]
! Emergency stop.
<inserted text> }\endwrite 
                           
l.109 \end{document}
                    
Unbalanced write command

且此时是可以顺利得到PDF文件的:

image.png

至此,问题的关键是找到为何会出现Unbalanced write command...


进一步简化问题:

\documentclass[AutoFakeBold,twocolumn,zihao=-4,UTF8]{ctexart}% 
% \input{settings} 
% \input{TJ-exam-8kai-settings}
\begin{document} 
  
\section{\textbf{填空题}(aaa)}

\end{document}

! Emergency stop.<inserted text> }\endwrite报错

但是

\documentclass[AutoFakeBold,twocolumn,zihao=-4,UTF8]{ctexart}% 
% \input{settings} 
\input{TJ-exam-8kai-settings}
\begin{document} 
  
\section{\textbf{填空题}(aaa)}

\end{document}

则会出现上述报错,至此TJ-exam-8kai-settings.tex中必定有问题.

稍微做一些简化,你可以把代码删减到:

\documentclass{ctexart}% 
\ctexset{section={number = \bfseries\chinese{section}}}
\usepackage{zref-lastpage}
\begin{document} 
  
\section{\textbf{填空题}hello}

你好!

\end{document}

同样会得到:

[1]
! Emergency stop.
<inserted text> }\endwrite

l.10 \end{document}

的问题...

image.png

事实上这里没必要用\bfseries,可以把TJ-exam-8kai-settings.tex中的

\ctexset{section={
        name = {,、\hspace*{-5mm}},
        number = \bfseries\chinese{section},
        format = {\zihao{-4}},
        beforeskip = 9pt,
        afterskip = 4pt
       }}

修改为

\ctexset{section={
        name = {,、\hspace*{-5mm}},
        number = \chinese{section},
        format = {\zihao{-4}},
        beforeskip = 9pt,
        afterskip = 4pt
       }}

既可以避免上述的问题。

另外,这个模板并不新,真的一定要用吗?!


BTW, 还要注意到这个模板似乎是13-14年写的,tasks包还报了如下的一个警告:

Package tasks Warning: You've tried setting command `\NewTasks ' on line 56.
(tasks)                However, command `\NewTasks ' is deprecated. Please use
(tasks)                command `\NewTasksEnvironment ' instead. Refer to the
(tasks)                manual for details.

自己做修改,留做习题....

具体是什么问题,两者有什么差异,请尽可能详细描述

不要只是提供几个代码片段让别人做猜测...


Edit

似乎 是因为.sty中 会默认启用expl3环境,因此_会被转义...

% MyTemplate.sty
%==============  MyTemplate.sty  ==============%
\NeedsTeXFormat{LaTeX2e}[2020-10-01]
\ProvidesExplPackage{MyTemplate}{2025-09-21}{1.1}{My personal utility macros}
% \NewDocumentCommand{\comb}{m m}{\mathrm{C}_{#1}^{#2}}% 这样写显示效果会有问题
\NewDocumentCommand{\comb}{m m}{\mathrm{C}\sp{#2}\sb{#1}} 

\endinput
% main.tex
\documentclass{article}
\usepackage{MyTemplate}
\begin{document}

before $\comb{n}{i}$ after

\end{document}

image.png

Ref: https://tex.stackexchange.com/a/698751/322482

虽然有一些神秘的baseline微调...

\documentclass{article}
\usepackage{fourier}
\usepackage{amsmath}
\usepackage{nicematrix}
\usepackage{tikz}
\usepackage{lipsum}
\begin{document}

\lipsum[2]

\[
R_o = 
\begin{bNiceArray}{ccc}[margin,last-row]
    \begin{tikzpicture}
    \clip (-.75,-.25) rectangle (1,3);
    \draw 
    (-.45,0) -- ++(0,2.25)
    (0.0,0) -- ++(0,2.25)
    node[above] {$K$}
    (+.45,0) -- ++(0,2.25);
    \end{tikzpicture}
    & 
    \begin{tikzpicture}[baseline=-1.25cm]
    \draw 
    (0,0) rectangle (1.5,1.5)
    (.75,1.5) node[above] {$K$}
    (1.5,.75) node[right] {$K$}
    ;
    \end{tikzpicture}
    & 
    \begin{tikzpicture}[baseline=-2cm]
    \draw 
    (0,-.5) --  ++(2,0)
    (0,0) -- ++(2,0) node[right] {$K$}
    (0,.5) -- node[midway,above] {$M$} ++(2,0);
    \end{tikzpicture} \\
    \mathbf{S} 
    & 
    % \mathbb{E}(\mathbf{a}\mathbf{a}^H) 
    \tikz[baseline=5.5ex]{
        \node (O) {non-singular};
        \node at (0,1) {$\mathbb{E}(\mathbf{a}\mathbf{a}^H) $}edge[latex-] (O.north);
    }
    &
    \mathbf{S}^H
\end{bNiceArray}
\]

\lipsum[2]

\end{document}

image.png

@u35231 提问要言之有物

能不能细致的讲一下randques.sty包的使用

这个包是什么,他不在CTAN上,你是从何获取?

论坛里提到过,他是运行频频出错

具体是论坛的哪里提到过?在哪里运行出错?报错信息是什么?

或者论坛里没人提到的probsoln.sty

这个包CTAN上有,你要如何细致呢,要实现什么目标?是否仔细阅读过宏包文档和他给的例子

https://ctan.org/topic/random

请补充给出你想用这个随机数如何生成内容的一个具体的完整例子。


翻阅远古提问,我猜测你是想要实现「随机抽题」

既然你已经提到

需要设置随机数生成的种子以确保文档中生成的内容每次编译都相同

言外之意是你已经有一个可以基于randques实现生成随机内容的文档,请提供这个文档的完整源代码,这样才能找到最合适的固定 random seed 的方法。


另外,关于randques宏包的官方下载来源,也建议你贴一个链接.是否是: https://www.latexstudio.net/archives/8366.html?

👉 randques.pdf
👉 test.tex
👉 test.pdf

image.png

也可以使用luadraw:

\documentclass[12pt]{standalone}
\usepackage[svgnames]{xcolor}
\usepackage[3d]{luadraw}
\usepackage{fouriernc}
\begin{document}
\begin{luadraw}{name=elippse-circle}
local g = graph3d:new{window={-5,5,-5,5}, viewdir={120,60}, size={12,12}}
g:Linejoin("round"); g:Linewidth(4)
Hiddenlinestyle = "dashed"
local k = 4
local R = 3
local Z0 = 3
local C1 = cone(Origin,k*vecK,R,100,true)
local C2 = cone(Origin, -k*vecK,R,100,true)
local P2 = {M(0,0,-Z0),vecK} -- plan de coupe
local P1 = {M(0,0,Z0-1),vecI + 2*vecK } -- plan de coupe
local I1 = g:Intersection3d(C1,P1)
local I2 = g:Intersection3d(C2,P2) 
g:Dcone(Origin,k*vecK,R,{color="orange"}) g:Dcone(Origin,-k*vecK,R,{color="orange"})
g:Lineoptions("solid","Navy",12)
g:Dedges(I1,{hidden=true})
g:Dedges(I2,{hidden=true}) 
g:Show()
\end{luadraw}
\end{document} 

image.png

\documentclass[12pt]{standalone}
\usepackage[svgnames]{xcolor}
\usepackage[3d]{luadraw}
\usepackage{fouriernc}
\begin{document}
\begin{luadraw}{name=elippse-cylinder}
local g = graph3d:new{window={-5,5,-5,5}, viewdir={120,60}, size={12,12}}
g:Linejoin("round"); g:Linewidth(6)
Hiddenlinestyle = "dashed"
local k = 6
local R = 3
local Z0 = 2
local C = cylinder(Origin,k*vecK,R,100,true)
local P = {M(0,0,Z0),vecI + 2*vecK} -- plan de coupe
local I1 = g:Intersection3d(C,P)
g:Dcylinder(Origin,k*vecK,R,{color="gray"}) 
g:Lineoptions("solid","Navy",12)
g:Dedges(I1,{hidden=true})
g:Show()
\end{luadraw}
\end{document} 

image.png

just curious: 这个链接究竟问了几个问题(?)


texhigh 环境中,怎样不打印「显式空格」?我希望能使用「不可见空格」
%\THSetCharReplacement{\ }{\ }%%\textvisiblespace 手册写道:texhigh已设置。这是什么意思?
texhigh使用打字机族时,是否支持两端对齐?

问题一:

对于你的mwe,直接使用latexmk -pdf --shell-escape编译即可得到不可见空格

\documentclass{article} 
\usepackage{texhigh} 
\begin{document}
\begin{texhigh}
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. 
\end{texhigh}
\end{document}

image.png

而若根据文档3.3节中的内容加上char-replacements={\ =\textvisiblespace},可以局部设置texhigh环境显示visable space

\documentclass{article} 
\usepackage{texhigh} 
\begin{document}
\begin{texhigh}[char-replacements={\ =\textvisiblespace}]
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. 
\end{texhigh}
\end{document}

清除所有辅助文件后编译可以得到:

image.png


问题二:

你似乎没有指出具体是在文档的哪个部分(?)例如(?):

image.png


问题三:

也许有关:https://ask.latexstudio.net/ask/question/17271.html

P.S.你上面的提问内容意味着让「每一位潜在的回答者」都要花20积分下载,这会大大打击回答的热情,你显然应该上传文件。(帮你做了...)

注意,由于latexmk会同时进行多个操作,并不利于定位问题debug和简化问题,同时压缩包中包含的.latexmkrc命令默认的配置为pdflatex,这与模板不契合,且在这里恶行累累,做测试的时候务必不要使用这个.latexmkrc配置.(到底是哪里在流传这份.latemkrc配置...)

请说明你的两种情况下的编译命令,如有报错信息,也应该提供。由于链接中还包含了latexmkrc配置,使用latexmkxelatex编译在这个例子里是大不相同的.

  • 使用TL21编译成功
  • 使用新版本(具体是哪个版本),编译命令是?

Edited:

texpage平台使用xelatex测试的编译结果为:

TL21正常
TL22不正常
TL23不正常
TL24不正常
TL25不正常(不interrupt编译过程,但是编译效果也是不正确的)

Re-Edited:

Description

首先一个主要的观点是,conbine模块和combinet宏包已经和现在的latex2e内核格格不入,cfr在这里提到:

don't use combine with current latex.

combineCTAN主页上,这个包已经有十几年没有根据新的内核做适配和更新了...

This Package seems not to be maintaned anymore. It is not working with current distributions (since at least November 2020). See for instance the following comments on github: https://tex.stackexchange.com/questions/591145/extra-endgroup-error-when-using-the-combine-document-class

累累罪状

1.本问题OP遇到的\contentsline参数问题:

直接使用TL22及以上编译会得到如下错误:

LaTeX Error: Something's wrong--perhaps a missing \item.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              
                                                  
l.4 \contentsline
                  {coltocauthor}{\numberline {}钱学森 \hskip 1em\relax 乌家培}{8}
Try typing  <return>  to proceed.
If that doesn't work, type  X <return>  to quit.

可以看一下编译生成的main.toc文件:

% main.toc
\contentsline {coltoctitle}{\numberline {}组织管理的技术——系统工程}{1}
\contentsline {coltocauthor}{\numberline {}钱学森 \hskip 1em\relax 许国志 \hskip 1em\relax 王寿云}{1}
\contentsline {coltoctitle}{\numberline {}组织管理社会主义建设的技术——社会工程}{2}
\contentsline {coltocauthor}{\numberline {}钱学森 \hskip 1em\relax 乌家培}{2}
\contentsline {coltoctitle}{\numberline {}军事系统工程}{3}
\contentsline {coltocauthor}{\numberline {}钱学森 \hskip 1em\relax 王寿云 \hskip 1em\relax 柴本良}{3}

注意到这里的\contentsline只吞下3个参数:

  • {coltocauthor}
  • {\numberline {}钱学森 \hskip 1em\relax 乌家培}
  • {8}

而在source2e.pdf中提到,在2021-11以后,为了兼容hypperref\contentsline现在已经修改为四参数形式。这也正是在TL21之后不能正确编译的原因。

image.png

要想暂时patch这个问题也很简单,重新声明一个默认使用三参数(置第四个为空)的即可。

实现留做习题,读者自行实现不难🐶。

2.不能直接使用,需要对\begingroup做patch

这也正是上述模板中main.tex的Line20-22使用的patch:

\makeatletter
\let\document\c@ladocument\begingroup%
\makeatother

3.与fancyhdr的兼容性不好

参考链接:https://tex.stackexchange.com/a/348189/322482

\begin{papers}
\makeatletter\let\@makecol\latex@makecol\makeatother
\import{sub}
\end{papers}

4.与tikz/newtx/xcolor的兼容性同样不好

使用TL22及以上编译会得到:

! Undefined control sequence.
\set@color ...\@pdfcolorstack push{\current@color 
                                                  }\aftergroup \reset@color 
l.6 \end{document}

参考链接:https://tex.stackexchange.com/q/723346/322482


..

还有多少兼容性问题,需要多少patch呢?

一定非用这个combine不可吗?完全有很多方案实现类似的多个\maketitle的效果(^_^)建议不要再用这个模板,不要再用这个很久无人维护的文档类。

@u7867 我来补充点信息吧..

MWE中的问题

首先你的mwe.tex中:

% line 13

\begin{table}[htb]
    \caption{Title} \label{tab24022314}
    \begin{threeparttable}%[htb]
        \setlength{\tabcolsep}{1pt}
        \begin{tabular}{|c|c|}}%<-多了一个「}」
        \hline
        a & b  \\ 
        c & d  \\ 
        \hline
    \end{tabular}
    \begin{tablenotes}
        \item The conditions 
    \end{tablenotes}
\end{threeparttable}
\end{table}

作为用户应该做的

我猜测你是在这里下载到的模板,在提问时,对于可公开获取的内容,理应贴出来下载链接,这样更方便保证来源的官方性.

从上述的页面可以下载到:

作为用户,在使用之前务必熟读user-manual!!!同时熟悉模板给的示例问题,并结合手册逐段做理解...

我假定你也不想去读Osvert Wang说的源码sn-jnl.cls文件...

编译你的代码可以得到如下错误:

! Package threeparttable Error: Illegal nested threeparttable environments.

See the threeparttable package documentation for explanation.
Type  H <return>  for immediate help.
 ...

l.12            \setlength
                 {\tabcolsep}{1pt}
?

什么是nested threeparttable environments呢?

你这里是table内嵌threeparttable再内嵌tabular.

事实上此时tablethreeparttable都提供了浮动环境来让tabular浮动...

作为用户,应该始终熟读「User Manual」再使用!!!

其中的7.3节告诉了正确的使用方式,和啸行老师提到的一致:

image.png

再在上面的示例中找对应的用法,此时已经自动实现了三线表:

image.png

作为用户,如果仔细阅读过「User Manual」和「示例代码」,其实是不会做出手动调用threeparttable并作神必嵌套这件事的...

你没看 sn-jnl.cls 文件,1324行已经有 \usepackage{threeparttable} 了,从1332行开始又重新定义了 table 环境,重定义里用了 threeparttable

找到那一段重定义的源码:

% sn-jnl.cls Line 1323~1350
\usepackage[figuresright]{rotating}%
\usepackage{threeparttable}

\let\tableorg\table%
\let\endtableorg\endtable%

\let\sidewaystableorg\sidewaystable%
\let\endsidewaystableorg\endsidewaystable%

\renewenvironment{table}[1][]%
{\begin{tableorg}[#1]%
\begin{center}
\begin{threeparttable}
\tablebodyfont%
\renewcommand\footnotetext[2][]{{\removelastskip\vskip3pt%
\let\tablebodyfont\tablefootnotefont%
\hskip0pt\if!##1!\else{\smash{$^{##1}$}}\fi##2\par}}%
}{\end{threeparttable}\end{center}\end{tableorg}}

\renewenvironment{sidewaystable}[1][]%
{\begin{sidewaystableorg}[#1]%
\begin{center}
\begin{threeparttable}
\tablebodyfont%
\renewcommand\footnotetext[2][]{{\removelastskip\vskip3pt%
\let\tablebodyfont\tablefootnotefont%
\hskip0pt\if!##1!\else{\smash{$^{##1}$}}\fi##2\par}}%
}{\end{threeparttable}\end{center}\end{sidewaystableorg}}

所以"什么是nested threeparttable environments呢?"

因为此时的table内部已经是一个threeparttable,所以你在table内部用threeparttable就是在嵌套threeparttable环境...

我也来贡献一个答案,如果我来画这个图的「精确形式」的话,我会先搜答案:

image.png

答案给了我们一个新的条件:「AB/AD=7/4」

至此我们其实已经可以唯一确定这个图形了

  • 绘制AB=7,作直角三角形ABD,其中AD=4
  • 根据勾股定理计算出BD=√4²+7²=√65
  • 由于BD/CD=3/4,因此CD=4√65/3
  • 更进一步可以得到AC=AD+DC=4+4√65/3
  • 最后计算BC的长度为√AB²+AC²

图形的唯一确定是不太难的,此时45°的条件已经和现有的比例条件是可以互推的。但是画图的难点在于,如何让线段BC保持水平,我下面的代码利用了三角函数的方法来确定A/B/C的精确坐标。

\documentclass[border=5pt]{standalone}
\usepackage{tkz-euclide}
\begin{document}
\begin{tikzpicture}[scale=.5]
  \def\c{7}
  \def\b{\fpeval{4+4*sqrt(65)/3}}
  \def\a{\fpeval{sqrt(\c^2+\b^2)}}
  \def\myangle{\fpeval{atan(\b/\c)}}% radians
  \tkzDefPoint(0,0){B}
  \tkzDefPoint(\c*cos(\myangle),\c*sin(\myangle)){A}
  \tkzDefPoint(\a,0){C}
  \tkzDrawPolygon[thick](A,B,C)
  % 取点「D」,满足「AD」=「4/7AB」= 4
  \tkzDefPointWith[linear normed,K=4](A,C) \tkzGetPoint{D}
  % ref: https://ask.latexstudio.net/ask/question/17889.html
  \tkzDrawSegment[thick](B,D)
   % 取点「D」,满足「AD」=「DE」= 4
  \tkzDefPointWith[linear normed,K=4](D,B) \tkzGetPoint{E}
  \tkzDrawSegment[thick](E,C)
    \tkzMarkRightAngle[semithick,size=.6](B,A,C)
    \tkzMarkAngle[semithick,size=.6](C,E,D)
    \tkzLabelAngle[pos=1.25](C,E,D){$45^\circ$}
    \tkzLabelPoint[above](A){$A$}
    \tkzLabelPoint[left](B){$B$}
    \tkzLabelPoint[right](C){$C$}
    \tkzLabelPoint[above right=-2pt](D){$D$}
    \tkzLabelPoint[below](E){$E$}
\end{tikzpicture}
\end{document}

image.png

  • 给出三条边长度的表达式
  • 利用边AB与AC的长度求倾斜角∠ABC的三角函数值
  • 利用三角函数关系给出A、B、C三个点的坐标
  • 利用AD=4/7AB以及DE=AD的关系,取点,连接

从画图的角度来看,个人觉得预先做一些计算会更容易画一些...

另外这题是真难啊,得积累积累做题经验...

off-topic: 在typst中这不是很困难...

Hello, world. #box(baseline: 100%-.75em)[
    + aaaa
    + bbbb
    + cccc
    + dddd
    + eeeee Hello, world. #box(baseline: 100%-.75em)[
            + aaaa
            + bbbb
            + cccc ahahah hahhaha aaaaa #box(baseline: 100%-.75em)[
              + aaaa
              + bbbb
              + cccc
          ] 
  ] 
]

image.png

等@雾月 老师做介绍吧

贴个省流版,前几天已经更新了极其友好的中文文档,我个人觉得这个问题可能会得到RTFM的回答...

https://github.com/Sophanatprime/texhigh-rs/blob/main/README-zh_CN.md

https://github.com/Sophanatprime/texhigh/blob/main/texhigh-zh_CN.pdf

image.png

另一个方案是基于luadraw(需要自行安装并用lualatex编译)

\documentclass[12pt]{standalone}
\usepackage[svgnames]{xcolor}
\usepackage[3d]{luadraw}
\usepackage{fouriernc}
\begin{document}

\begin{luadraw}{name=project_line_3D}
    local g = graph3d:new{
        window3d={-1,3,-2,3,-2,2},
        window={-3,3,-3,2},
        viewdir={30,60},
        size={10,10},
        border=true
    }
    g:Linejoin("round")
    g:Linewidth(4)
    Hiddenlines = true
    Hiddenlinestyle = "dashed"
    local A,B,C = M(0,1,0), M(3,2,0), M(2.5,0,1)
    local D = dproj3d(C,{B,A-B}) -- 返回C在直线d:{B,A-B}的投影
    g:Ddots3d({A,B,C,D})
    g:Dscene3d(
        g:addAxes(Origin, {arrows=1,arrowscale=0.75,color="blue"})
    )
    g:Dpolyline3d({{A,B,C,A}, {C,D}})
    g:Dangle3d(C,D,A,0.2)
    g:Dlabel3d(
        "$A$",A,{pos="N"},
        "$B$",B,{pos="S"},
        "$C$",C,{pos="N"},
        "$D$",D,{pos="E"}
    )
    g:Show()
\end{luadraw}
\end{document} 

image.png

更建议从源头上解决问题。

在记笔记时发现有些SQL语言的关键字并未能被 minted 环境识别出来,被当成普通字符处理,输出为黑色。但强迫症让我想去手动修改未被上色的关键字以保证笔记效果。例如DATABASE关键字无法被SQL正确识别为高亮。

注意到minted是基于pygments的,因此所有支持的语言和关键字应该查看这里

我没有仔细搜索,但是

  • DATABASES 不是 SQL的关键字
  • DATABASESMySQL的关键字

所以可以考虑治本...

\documentclass[fontset=fandol]{ctexart}
\usepackage[margin=1cm]{geometry}
\usepackage[svgnames]{xcolor}
\usepackage{minted}
\begin{document}

\begin{minted}[
    bgcolor = gray!10,
    breaklines = true
]{MySQL}
    DATABASES Explorer
    -- 按产品类别和季度统计销售数据
    SELECT
    product_category,  -- 产品类别
    quarter,           -- 季度(1-4)
    total_sales,       -- 总销售额
    order_count,       -- 订单数量
    avg_order_value    -- 平均客单价(总销售额/订单数)
    FROM (
    -- 子查询:计算每个订单的销售额,并提取年份和季度
    SELECT
        product_category,
        -- 提取订单日期的年份和季度(兼容 MySQL、PostgreSQL、SQL Server)
        DATE_FORMAT(order_date, '%Y') AS year,
        QUARTER(order_date) AS quarter,
        order_id,
        SUM(unit_price * quantity) AS order_sales  -- 单订单销售额 = 单价×数量
    FROM
        sales
    WHERE
        order_date >= '2023-01-01'  -- 筛选2023年数据
        AND order_date < '2024-01-01'
        AND unit_price > 0  -- 排除异常数据(单价为0的订单)
    GROUP BY
        product_category, year, quarter, order_id  -- 按订单粒度聚合
    ) AS order_details
    -- 外层聚合:按类别和季度统计
    GROUP BY
    product_category, quarter
    -- 按类别升序、季度升序排序
    ORDER BY
    product_category ASC,
    quarter ASC;
\end{minted}

\end{document}

image.png

至于如何「自定义minted的关键字」,按照这里的说法,这似乎不是一个LaTeX的问题,而是一个Python层面的问题....

有空可以研究一下补上,挖坑😀

发布
问题