多行公式里有括号的数学公式
是什么意思?按照你的mwe,编译出来的效果为:

除了需要使用\text{其他}而不是只在数学公式内直接打其他之外,并没有明显的问题。建议使用目标示意图表示“多行公式里有括号的数学公式”的准确效果。
如果想要编号的不同样式,可见下面的maybe related link:
多行公式里有括号的数学公式
是什么意思?按照你的mwe,编译出来的效果为:

除了需要使用\text{其他}而不是只在数学公式内直接打其他之外,并没有明显的问题。建议使用目标示意图表示“多行公式里有括号的数学公式”的准确效果。
如果想要编号的不同样式,可见下面的maybe related link:
请提供一个完整的可编译的文档例子,例如format.cls具体是什么,只提供一个切片很难回答这一问题。
一个基于natbib的例子如下,需要使用pdf-bibtex-pdf-pdf或者latexmk -pdf命令编译:
\documentclass{article}
\begin{filecontents*}[overwrite]{reference.bib}
@article{1966Calculation,
author = {AAAA},
year = {1966},
title = {Calculation of the Influence of the Earth's Magnetic Field on the Magnetic Field of the Moon},
}
@article{1972Influence,
author = {BBBB},
year = {1972},
title = {The Influence of Earth's Magnetic Field in Exploring the world},
}
@article{2000The,
author = {CCCC},
year = {2000},
title = {The The The The paper named The The The},
}
\end{filecontents*}
\usepackage[numbers,sort&compress]{natbib}
\bibliographystyle{unsrtnat}
\begin{document}
I want to cite these papaer at here\cite{1966Calculation,1972Influence,2000The} but not there!
\bibliography{reference}
\end{document}
根据我自己给自己做的MWE(真是有够好笑了呢)
\documentclass[12pt,a4paper,openany,twoside]{ctexbook}
\usepackage{geometry}
\begin{filecontents*}[overwrite]{paper.bib}
@article{1966Calculation,
author = {AAAA},
year = {1966},
title = {Calculation of the Influence of the Earth's Magnetic Field on the Magnetic Field of the Moon},
}
@article{1972Influence,
author = {BBBB},
year = {1972},
title = {The Influence of Earth's Magnetic Field in Exploring the world},
}
@article{2000The,
author = {CCCC},
year = {2000},
title = {The The The The paper named The The The},
}
\end{filecontents*}
\usepackage[numbers,sort&compress]{natbib}%加上这一行即可...
\paperheight=15cm % 只是为了截图在同一张图内
\begin{document}
\tableofcontents
\chapter{绪\quad 论}
\section{标题}
\subsection{副标题}
这是引用\cite{1966Calculation,1972Influence,2000The}的结果——我想我能吞下玻璃而不伤身体。
\bibliographystyle{gbt7714-2005}
\bibliography{paper.bib}
\addcontentsline{toc}{chapter}{参考文献}
\end{document}
BTW,你是否看过基础教程lshort-zh-cn的6.1节....
提供在网上可以公开获得的代码时最好应该贴代码链接而不是直接上传文件,所以相比于直接上传jiazhu.dtx,更好的办法是贴这个官方链接。
参考muzimuzhi在这个链接中提供的方法,需要使用如下的方法编译:
先使用xetex jiazhu.dtx释放jiazhu.sty以及jiazhu.ins等文件
再使用xelatex jiazhu.dtx在当前目录下已有jiazhu.sty的前提下可以获得jiazhu.pdf的帮助文档
只需要使用release的ctex-kit中最新版本(截至2025-03-03,只要在2024-03-19之后即可)的ctxdoc.cls即可顺利编译jiazhu.dtx。为避免版本困惑,这里贴一个截至2025-03-03(其实是2024-03-19)开发版本的ctxdoc.cls。ctxdoc.cls
一个简略的说明:2023年10月份JosephWright将l3kernel中部分命令的x-type替换为e-type展开这一软性更新,直接影响了作为测试文档类的l3doc.cls中的部分命令,而ctxdoc.cls由于依赖了l3doc.cls文档类,而jiazhu.dtx又依赖于ctxdoc.cls。
上面的上游l3doc.cls中的修改对应的ctxdoc.cls部分命令的修改已经在2023年-2024年间陆续被PR,但由于ctex发版较慢,目前CTAN上的ctxdoc.cls仍然是2022-06-05发版的v2.5ctex-kit版本,上面“对部分命令的修改已经在2023年~2024年间陆续被PR(#704) ”并未体现在用户的TeXLive2024/2025中。
目前已经发现的ctxdoc.cls中的命令替换和对应的PR(都已经被merged,因此使用开发版本但未发版的ctxdoc.cls即可):
\__codedoc_get_hyper_target:xN被替换为\__codedoc_get_hyper_target:eN 这一替换可见PR #678\tl_replace_all:Non被替换为\tl_replace_all:NVn 这一替换可见PR #700\__codedoc_macroname_prefix:o以及\__codedoc_macroname_suffix:N #2命令 这一替换可见PR #703
类似的问题在这个latexstudio提问的评论区以及这个关于fduthesis的源文件编译问题还有这个易经宏包的说明文档也有提到过,最简单的办法都是是直接使用被PR后最新版(而非CTAN上最后发版的2022年的ctex-kit)的ctxdoc.cls,当然,也可以如上手动备份并修改ctxdoc.cls的部分命令。
安装开发版本的ctex-kit也很简单,克隆仓库后到ctex目录下执行l3build install,就会自动安装到用户目录的texmf目录,在编译时优先被调用。
atxy_blip老师在这个issues里提到的基于l3build使用开发版本的ctex-kit的方法可以直接安装到texmf路径内。当然如果保险起见,也可以手动备份或者只添加到当前目录。
Release "jiazhu-beta" 包含了编译好的jiazhu.pdf。截至 2025-03-02,jiazhu.dtx在发这个非正式版后,只有一个重构的提交f85a422,所以那份jiazhu.pdf够用了,jiazhu包的使用者没有自行编译文档的必要性。想自行编译文档的,就超出了使用者范畴,可以尝试如前所述git clone的步骤。
muzimuzhi老师在这个issues提到的直接获得jiazhu.pdf的方法。此处顺便贴一份jiazhu.pdf的文件。jiazhu.pdf
在我这里可以正常编译:

啸行老师指出:
建议你用二分法找找错误出现的地方
简单补充下这句话的意思,下次请务必自己给出最简代码,也能帮助你定位错误,不要提出标题为“不知道什么错误 烦死了 内容都是完整的”的问题了,你完全可以在探索之后问出“如何在行间公式内输入中文”一类的标题。
\documentclass{article}
\usepackage{ctex,amsmath}
\title{二队关于插值的理解(主要来源与司守奎老师)}
\author{二队\and 为啥\thanks{这次我了解到并知道怎么会用脚注了}
\and 就是
\and 就是就是}
\date{\today}
\begin{document}
\maketitle
\section{导言}
在数学建模过程中,通常要处理由试验、测量得到的大量数据或一些过于复杂而不便于计算的函数表达式,针对此情况,很自然的想法就是,构造一个简单的函数作为要考察教据或复杂函数的近似。插值和拟合就可以解决这样的问题。\par
至于拟合先就抛开不谈。\par
说到插值首先得明白插值能干什么,什么时候适合用,我觉得这比插值本身这件事情重要,所以本文会先就谈谈不同的插值方法的适合情况,进而说明对应的插值方法。\par
\section{一维插值}
\subsection{相关概念}
已知好多数据点,假设有n+1个互不相同的观测点$x_0,x_1,x_2,\ldots,x_n$处的观测值,寻求一个近似曲线(或叫做近似函数),使其满足
\begin{equation}
f(x_i) = y_i,i=0,1,\ldots,n。\label{pythagorean}
\end{equation}
对于任意的非观测点$\hat{x}(\hat{x} \neq x_i,i=0,1,\ldots,n)$,要估计该点的函数值就可以用$f(\hat{x})$。通常此类问题称为插值问题。而求近似函数\eqref{pythagorean}的方法称为插值方法。\par
观测点$x_i(i=0,1,\ldots,n)$称为插值节点,$f(x)$称为插值函数(也称之前说过的近似函数,近似曲线),式\eqref{pythagorean}称为插值条件,含$x_i(i=0,1,\ldots,n)$的最小区间$[a,b]$称为插值区间。$f(\hat{x})$为x在$\hat{x}$处的插值。\par
值得注意的是,若$\hat{x}\in[a,b]$,则称为内推,否则称为外推。所以有什么影响呢,插值方法一般适用于内推的情况。外推需谨慎,仅适用于短期预测,长期预测可靠性低。
如果插值函数为多项式函数,则称插值方法为多项式插值。之前说过用什么插值方法取决与求什么类型的插值函数。
这周确实忙,所以先就说一下牛顿插值跟拉格朗日插值。而且应该对于数据预处理还要学很长时间。
\subsection{拉格朗日插值方法}
求插值多项式比较方便的做法不是待定系数法解方程。而是巧妙的构造一组基函数。
\begin{equation}
l_i(x) =\frac{(x - x_0)\cdots(x - x_{i-1})(x - x_{i+1})\cdots(x - x_n)}{(x_i - x_0)\cdots(x_i - x_{i-1})(x_i - x_{i+1})\cdots(x_i,x_n)}
则$l_i(x)$是n次多项式,满足
\begin{equation}
\end{document}报错信息为:
LaTeX Warning: Reference `pythagorean' on page 2 undefined on input line 21.
! Missing $ inserted.
<inserted text>
$
l.29大约是在29行有问题以上的代码显然还不是最简
于是我们试试注释25行之前,\begin{document}之后的代码:
\documentclass{article}
\usepackage{ctex,amsmath}
\title{二队关于插值的理解(主要来源与司守奎老师)}
\author{二队\and 为啥\thanks{这次我了解到并知道怎么会用脚注了}
\and 就是
\and 就是就是}
\date{\today}
\begin{document}
\subsection{拉格朗日插值方法}
求插值多项式比较方便的做法不是待定系数法解方程。而是巧妙的构造一组基函数。
\begin{equation}
l_i(x) =\frac{(x - x_0)\cdots(x - x_{i-1})(x - x_{i+1})\cdots(x - x_n)}{(x_i - x_0)\cdots(x_i - x_{i-1})(x_i - x_{i+1})\cdots(x_i,x_n)}
则$l_i(x)$是n次多项式,满足
\begin{equation}
\end{document}再次编译,发现问题仍然存在:
! Missing $ inserted.
<inserted text>
$
l.13这说明删对了,接着继续尝试删除代码,由于正文区已经剩下的内容很少了...
\documentclass{article}
\usepackage{ctex,amsmath}
\begin{document}
\begin{equation}
l_i(x) =\frac{(x - x_0)\cdots(x - x_{i-1})(x - x_{i+1})\cdots(x - x_n)}{(x_i - x_0)\cdots(x_i - x_{i-1})(x_i - x_{i+1})\cdots(x_i,x_n)}
则$l_i(x)$是n次多项式,满足
\begin{equation}
\end{document}同样可以复现你的问题(有相同的报错),所以问题就出现在上面的这一段中。
通过上面的操作,你也可以发现问题其实就集中在equation环境中...也就不会提出“不知道什么错误 烦死了 内容都是完整的”这样的标题了...
从昨晚交流群的信息来看,你编译名为未命名12.tex在texpad中显示出了中文“未命名”乱码之外一切正常
我猜测texpad仅仅是把终端的结果经过parser放到error panel而已,因此texpad不应该被怪罪,问题应该出现在你的终端编码不支持中文上

我建议你在终端测试如下六个文件:
xelatex编译看看效果xelatex编译看看效果xelatex编译看看报错信息xelatex编译看看报错信息pdflatex编译pdflatex编译提供这六种情况在终端是否乱码,同时请尝试按下图提供你当前终端的默认编码方式:

时隔半年,我尝试了一下...
其实对于大致了解texlive基本语法的用户,从上面的代码微调到texlive支持的样式并不难,但是对于初学者来说,很难分辨如何修改回退。此外你的截图中的需求有一些不合理之处,比如不应该用章节目录来和TOC的对齐情况相比较:
我修改了CCT一些奇怪的设置,在TEXLIVE下一个可行的例子是:
\documentclass[a4paper,twoside,12pt]{ctexbook}
\renewcommand\baselinestretch{1.414}
\usepackage{amsmath, amsthm, amssymb, amscd}
\usepackage{makecell,booktabs}
% \usepackage{float}
\usepackage{mathrsfs}
% \usepackage{latexsym}
\usepackage{setspace}
% \usepackage{makeidx}
\usepackage{graphicx}
\usepackage{enumitem}
\usepackage{tocbibind}
\usepackage{fancyhdr}
\allowdisplaybreaks
\newtheorem{theorem}{\indent 定理}[section]
\newtheorem{corollary}[theorem]{\indent 推论}
\newtheorem{lemma}[theorem]{\indent 引理}
\newtheorem{proposition}[theorem]{\indent 命题}
\newtheorem{nature}[theorem]{\indent 性质}
\newtheorem{definition}[theorem]{\indent 定义}
\newtheorem{remark}[theorem]{\indent 注记}
\newtheorem{example}[theorem]{\indent 例}
\newcommand{\cndash}{\rule{0.2em}{0pt}\rule[0.35em]{1.6em}{0.05em}\rule{0.2em}{0pt}}
\renewcommand{\proofname}{\bf{\indent 证明}}
\def\Box{\hfill\square}
%%%%%%%%%%%%%%%%%%%
\numberwithin{equation}{section}
\topmargin=0.5cm
\oddsidemargin=20pt
\evensidemargin=0pt
\textwidth=15.1cm
\textheight=22.5cm
%%%%%%%%%%%%%%%%%
\makeatletter
\def\ps@headings{%
\def\@oddfoot{\hfill\thepage\hfill}
\def\@evenfoot{\hfill\thepage\hfill}
\def\@evenhead{\thepage\hfil\slshape\leftmark}
\def\@oddhead{\slshape\rightmark\hfil\thepage}
\let\@mkboth\markboth
\def\chaptermark##1{%
\markboth {% !!!
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter
\chaptername \ \ % !!!
\fi
\fi
##1}{}}% !!!
\def\sectionmark##1{%
\markright {% !!!
\ifnum \c@secnumdepth >\z@
\sectionname \ \ % !!!
\fi
##1}}}% !!!
\renewcommand{\@oddhead}{\protect\footnotesize{%
\begin{minipage}{\textwidth}
{\heiti \hfill \ziju{0.5} 家里蹲大学博士学位论文
\hfill} \\
\begin{tabular*}{\textwidth}{@{}l@{\extracolsep{\fill}}r@{}}%
{\kaishu \leftmark} & { \kaishu \rightmark}
\\ \hline \hline\vspace{2pt}
\end{tabular*}
\end{minipage}
}}
\renewcommand{\@evenhead}{\@oddhead}
\makeatletter
\@addtoreset{equation}{section}
\makeatother
\renewcommand\contentsname{目 \ 录}
\renewcommand\bibname{参考文献}
\begin{document}
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 摘要 %%%%%%%%%%%%%%%
% \newpage
\pagenumbering{Roman}\thispagestyle{plain}
\chapter*{摘 \ 要}
\addcontentsline{toc}{chapter}{摘 \ \ \ \ 要}
在第一章中, 我们主要阐述本文所讨论问题的背景及研究现状, 并简要介绍本文的主要工作以及相关的预备知识和一些记号.
\bigskip
\textbf{\zihao{4}\textbf{关键词}:} 临界指数;\ Lusternik-Schnirelman定理.
\newpage
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% End of 摘要 %%%%%%%%%%%%%%%
\thispagestyle{plain}%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% The Abstract of Thesis %%%
\chapter*{Abstract}
\addcontentsline{toc}{chapter}{\large Abstract}
In this thesis, we want to introduce that...
\bigskip
\textbf{\zihao{4}\textbf{Keywords}:} Lusternik-Schnirelman theory.
\newpage
\thispagestyle{plain}
\tableofcontents
\newpage
\pagenumbering{arabic}
\setcounter{page}{1}
\chapter{引 言}
本章介绍了与本文所研究课题相关的背景知识, 发展概况以及我们所做的主要工作. 本章介绍了与本文所研究课题相关的背景知识, 发展概况以及我们所做的主要工作.
\section{问题的背景及研究现状}
\chapter{第一章}
\section{问题的背景及研究现状}
\begin{thebibliography}{99}
\bibitem{ass} AAAA
\bibitem{bss} BBBB
\end{thebibliography}
% %%%%%%%%%%%致谢
\newpage\thispagestyle{empty}\chapter*{\zihao{2} 致 \ \ \ 谢}
\addcontentsline{toc}{chapter}{致\ \ \ \ \ 谢}\bigskip
aaa这里是致谢...
\chapter*{攻读XX学位期间发表的学术论文}
\addcontentsline{toc}{chapter}{攻读XX学位期间发表的学术论文}\vskip 20pt
\begingroup\zihao{4}
\begin{enumerate}[itemsep=15pt]%
\item 1
\item 2
\item 3
\end{enumerate}
\endgroup
\end{document}



务必要有熟练使用TeXLive语法的功能的能力,才能比较好的用好这种转换,不然很容易一步一卡,非常打击自信心。同时也建议,如非必要,不要使用基于CTeX套装的古早模板。
我还没看你expl3的实现,但是当我们发现在某个模板中lastpage表现异常的时候,我们应该首先在标准文档类中尝试一下lastpage的功能,这样可以确定是文档类设置的冲突问题还是lastpage的问题,@u101077 老师给出的示例已经可以说明,这个问题来源于els-cas-templates模板造成的可能冲突。
同时我们发现els-cas-templates模板已经在TL中包含,因此我们可以做如下的最简测试:
\documentclass{cas-sc}%由于OP的MWE中例子为单列,因此采用`cas-sc`
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{lastpage}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\headrulewidth}{0pt}
\cfoot{Page~\thepage~of~\pageref{LastPage}}
\begin{document}
\lipsum[1-20]
\begin{figure}
\centering
\includegraphics[width=\textwidth]{example-image}
\caption{Example image}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=\textwidth]{example-image}
\caption{Example image}
\end{figure}
\end{document}els-cas-templates模板定义了lastpage用以显示总页数,但是如果文档最后放置浮动体,则总页数只是有文字的最后一页
一方面....上面的直接调用cas-sc的MWE并无法体现你的问题,所以首先你应该补充基于els-cas-templates的MWE,以体现这一点。

另一方面关于你写的自我l3实现,很精彩。这里唯一的小瑕疵是patch的时间不对。我想从结果你也能猜出,\lastpage展开为\thepage的时间仅仅是在排版完所有文本(不包括浮动体)所致,在lthooks-doc.pdf和ltshipout-doc.pdf中我们可以找到应该在浮动体排版结束之后再加入这个patch:
因此我探索出的一个方法是用\AddToHook{shipout/lastpage},这样可以保证在浮动体被浮动算法排版之后再展开\lastpage为\thepage:
(我也不是很懂输出例程(output rountine),无法给出更详细的解释...)
但总而言之,修改后的mwe如下:
\documentclass{article}
\usepackage{graphicx}
\usepackage{lipsum}
\makeatletter
\ExplSyntaxOn
\iow_new:N \l_lastpage_file
\file_if_exist:nTF{\c_sys_jobname_str.page}
{
\file_input:n{\c_sys_jobname_str.page}
}
{
\cs_set_eq:NN \lastpage \relax
}
% \AtEndDocument{%
\AddToHook{shipout/lastpage}{%
\iow_open:Nn \l_lastpage_file{\c_sys_jobname_str.page}
\iow_now:Nx \l_lastpage_file
{
\cs_set:Npn \exp_not:N \lastpage
{
\thepage
}
}
\iow_close:N \l_lastpage_file
}
\cs_new:Npn \__first_foot:
{
\parbox[t]{\textwidth}
{~\hfill Page~\thepage{}~of~ \lastpage}
}
\cs_set_eq:NN \@evenfoot \__first_foot:
\cs_set_eq:NN \@oddfoot \__first_foot:
\ExplSyntaxOff
\makeatother
\begin{document}
\lipsum[1-50]
\begin{figure}
\centering
\includegraphics[width=\textwidth]{example-image}
\caption{Example image}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=\textwidth]{example-image}
\caption{Example image}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=\textwidth]{example-image}
\caption{Example image}
\end{figure}
\begin{figure}
\centering
\includegraphics[width=\textwidth]{example-image}
\caption{Example image}
\end{figure}
\end{document}若如此做可以得到:
此外我的l3编程经验并不多,而且对于l3file模块也不够了解,但我仍感觉你的这一段实现似乎有点不太符合逻辑:
\file_if_exist:nTF{\c_sys_jobname_str.page}
{%
\file_input:n{\c_sys_jobname_str.page}
}
{%
\cs_set_eq:NN \lastpage \relax
}设想如果一个10页的文档首先被编译,那么.page文档首先展开得到\lastpage=10,如果之后添加了部分内容,这个文档变为15页,但是上面的逻辑仍然会得到\lastpage=10,这反复读取.page似乎不利于多次编译,或者需要用户在第一次编译之后使用latexmk -c删除,我不太明白这一设计的目的是什么,如果已有.page就直接使用(为了节省编译时间咩?)如果我来写的话,我反而会担心这一辅助文件记录了上一次编译的信息,所以应该会是类似这样的删除.page的伪代码思路:
\file_if_exist:nT{\c_sys_jobname_str.page}
{%
%\file_input:n{\c_sys_jobname_str.page}
<DELETE FILE> \c_sys_jobname_str.page
}
\cs_set_eq:NN \lastpage \relax因为我不会改,也与本问题无关,因此我没改动。也希望原题主能解释下这里如此设计的思路,以上...
一个彩蛋...似乎旧版本的lastpage使用的也是\AtEndDocument...我有点感到迷惑,是不是旧版的lastpage.sty就会导致这一问题呢...(所以是我不能复现的原因(?),我的版本是2024-07-07 v2.1c):

我觉得比较好的方式是用fancyhdr实现.....
单纯使用fancyhdr宏包的实现可以是这样:
\documentclass[fontset=ubuntu]{ctexbook}
\usepackage{geometry}
\usepackage{zhlipsum}
\usepackage{fancyhdr}
\fancyhead[C]{\large\textbf{中~国~科~学~技~术~大~学~博~士~学~位~论~文}\vskip1ex}
\renewcommand{\chaptermark}[1]{%
\markboth{\normalfont\large\CTEXthechapter\quad #1}{}}
\renewcommand{\sectionmark}[1]{\markright{\normalfont\large\textrm{\S\thesection\quad #1}}}
\fancyhead[L]{\leftmark}
\fancyhead[R]{\rightmark}
\fancyfoot[C]{\thepage}
\fancyfoot[L,R]{}
\renewcommand{\headrule}{\hrule height .8pt \vspace*{1mm}\hrule height .8pt\vspace*{1mm}}
\setlength{\headsep}{.5in}
\pagestyle{fancy}
\begin{document}
\chapter{第一章第一章第一章的名字啊啊啊啊}
\section{第一节节名}
\zhlipsum[1-8]
\chapter{第二章第二章第二章的名字啊啊啊啊}
\section{第二节节名}
\zhlipsum[1-8]
\end{document}
PS. OP的原MWE中出现摘要页部分重叠,是什么情况?你可以自行试试把上面的内容加到你的模板中试试效果😀

避免让人觉得你是个刚刚打开模板的用户,没有经过任何尝试,然后想"伸手"直接获得这一页眉样式。
甩过长的代码上来只会大大降低别人查看并尝试解答的概率。由于以上的原因,尝试合并到你的模板中的事你得自己做了...如有其他问题,请给mwe并提新的提问。
我不能复现你的问题,我的listings版本是v1.10c。
\documentclass{ctexart}
\usepackage{zhlipsum}
\usepackage{listings}
\usepackage[svgnames]{xcolor}
\lstset{
basicstyle=\ttfamily,
breaklines=true,
keywordstyle=\bfseries\color{NavyBlue},
keywords={as, and, assert, break, class, continue, def, del, elif, else, except, exec, finally, for, from, global, if, import, in, is, lambda, not, or, pass, print, raise, return, try, while, with, yield},
emph={},
emphstyle=\bfseries\color{Rhodamine},
commentstyle=\itshape\color{black!50!white},
stringstyle=\bfseries\color{PineGreen!90!black},
columns=flexible,
numbers=left,
numbersep=1em,
numberstyle=\footnotesize,
frame=single,
framesep=0em,
}
\begin{document}
\zhlipsum[1]
\begin{lstlisting}[language=Python]
import matplotlib.pyplot as plt # 绘制图形的库
from matplotlib_venn import venn2 # 绘制二元韦恩图的库,如果是三元则是 venn3
plt.figure(figsize=(8, 8)) # 初始化设置图形的尺寸
\end{lstlisting}
\zhlipsum[2]
\end{document}
请提供你的完整MWE,从\documentclass开始到\end{document}结束。
从评论区中下载book.tex删除无关部分之后,新的MWE(也就是你所说的“另一个样子”的\lstset)如下:
\documentclass[a4paper]{book}
\usepackage[utf8]{inputenc}
\usepackage{geometry}
\usepackage{tikz}
\usepackage[dvipsnames]{xcolor}
\usepackage{ctex}
\usepackage{listings}
\lstset{
basicstyle=\ttfamily, % 设置字体族
breaklines=true, % 自动换行
keywordstyle=\bfseries\color{NavyBlue}, % 设置关键字为粗体,颜色为 NavyBlue
emph=[1]{}, % 指定强调词,如果有多个,用逗号隔开
emph=[2]{as},
emphstyle=[1]\bfseries\color{Rhodamine}, % 强调词样式设置
emphstyle=[2]\bfseries\color{NavyBlue},
commentstyle=\itshape\color{black!50!white}, % 设置注释样式,斜体,浅灰色
stringstyle=\bfseries\color{PineGreen!90!black}, % 设置字符串样式
columns=flexible,
numbers=left, % 显示行号在左边
numbersep=1em, % 设置行号的具体位置
numberstyle=\footnotesize, % 缩小行号
frame=single, % 边框
framesep=0em % 设置代码与边框的距离
}
\begin{document}
\begin{lstlisting}[language=Python]
import matplotlib.pyplot as plt # 绘制图形的库
from matplotlib_venn import venn2 # 绘制二元韦恩图的库,如果是三元则是 venn3
plt.figure(figsize=(8, 8)) # 初始化设置图形的尺寸
\end{lstlisting}
\end{document}在我的电脑上(windows11 TeXLive2024)也正常:
as不变色的最小工作示例,而不是把大段的(几百行的代码)发上来,没人会看。主要版本差异目前定位于xcolor与listings宏包上

Bug 复现使用TL20243月版本frozen version的v1.10版本的listings.sty:

BTW,恭喜你发现了华点.
另外,提供MWE总是能帮助自己和他人方便定位错误的....
图书馆要闭馆惹(逃了逃了)...略微匆忙地用resizebox给了一种缩放&对齐的方法...
\documentclass{book}
\usepackage{amsfonts}
\usepackage{amsmath,amsthm,amssymb,amscd}
\usepackage{graphicx}
\usepackage{ctex}%使用此包可输入中文
\usepackage{tikz}
\usetikzlibrary{patterns}%条纹
\allowdisplaybreaks
\newtheorem{theorem}{\indent 定理}[section]
\newtheorem{remark}[theorem]{\indent 注记}
\makeatletter
\newcommand{\rmnum}[1]{\romannumeral #1}
\newcommand{\Rmnum}[1]{\expandafter\@slowromancap\romannumeral #1@}
\makeatother
\begin{document}
\begin{figure}[htbp]
\begin{minipage}{.49\textwidth}
\centering
\label{tu1}
\resizebox{\textwidth}{4cm}{%
\begin{tikzpicture}
\draw [very thick,-] (-2.8,3.5) -- (5.8,3.5);
\draw [very thick,-] (-2.8,-1.5) -- (5.8,-1.5);
\path [draw, very thick, ->] node at (-.2,-.2) {$o$} (0,0) -- (2.5,0) node at (2.7,0.2) {$\vec{v}$};
\path [draw, very thick, ->](0,0) -- (0,1.7) node[right] {$\vec{u}$};
\path [draw, very thick, color=blue, ->] (0,0) -- (2,1.5)
node at (2.2,1.2) {$x$};
\node at (6.5,2.5) {$\mathbb{R}^{2}$};
\node at (-1.5,1.5) {{\color{red}$O$}};
\draw [very thick, color=red,dashed,-] (-2.5,-1) .. controls (-1,-1.5) and (1.5,1)..(5.5,-1.2);
\draw [very thick, color=red,dashed,-] (-2.5,2) .. controls (-1,1.5) and (1.5,3)..(5.5,2.2);
\end{tikzpicture}%
}
\caption{$\mathbb{R}^{2}$ 上带状示意图}
\end{minipage}\qquad
\begin{minipage}{.49\textwidth}
\centering
\label{tu2}
\resizebox{\textwidth}{4cm}{%
\begin{tikzpicture}
\path [draw, very thick, ->] node at (-.2,-.2) {$O$} (-0.5,0) -- (8,0) node[anchor=north] {$x$};
\path [draw,very thick, ->](0,-0.5) -- (0,6.1) node[anchor=east] {$y$};
\node at (7.5,5.5) {$\mathbb{R}^{2}$};
\draw[very thick,blue,dashed,-] (0.5,0.5) -- (6.5,0.5) -- (6.5,5) --(0.5,5)--(0.5,0.5);
\draw[pattern=north west lines] (3,3) circle (1.5);
\draw [color=red] (3,3) circle (1.5);
\node [fill=white,rounded corners,below of=3] at (2.5,4) {$B$};
\node at (2,1.3) {$ {\color{red}\partial B=B_{0}}$};
\draw (5,3) circle (1.2);
\node at (6.2,1) {$\Lambda$};
\node at (5.5,3) {$S$};
\end{tikzpicture}
}
\caption{$\mathbb{R}^{2}$ 上环绕示意图}
\end{minipage}
\end{figure}
\end{document}
你确实可以通过调整大小(指定width参数)来让浮动算法修改位置:
\documentclass{article}
\usepackage{ctex}
\usepackage{graphicx}
\title{关于近20年的中国GDP数据的描述性统计(2003-2022)}
\author{第二组~乔鑫凯~李梦琪~郭建程}
\date{2月22日}
\begin{document}
\maketitle
箱线图又称为盒须图、盒式图或箱形图,是一种用作显示数据分散情况资料的统计图,因形状如箱子而得名。
下方给出了一个用来反映2003年至2022年中国GDP数据总量分布情况的箱线图
\begin{figure}[hbp]
\centering
\includegraphics[width=.5\textwidth]{example-image}
\caption{箱线图}
\end{figure}
\end{document}
注意:
\author内的空格不会在pdf内体现,可以替换为tierexample-image替换(请texdoc mwe),不然在别人的电脑上无法编译\includegraphics{untitled1}[hbp]这个写法是谁教你的...可见群主的介绍,[hbp]是浮动体的参数@
000 提交文件点击这里:
提交代码请用围栏代码块语法,或者选中代码文本后点击这里:
做一miumiu补充:
\maketitle应该放在正文部分用于排版封面 \begin{document}之后\caption应该用于浮动体环境内,请查看lshort-zh-cn的3.9节PS.若有回答令你满意,请点击采纳此回答。
问 align环境里想用cases环境 也就是想实现多行公式里有括号的公式这次我有end了