雾月
雾月
这家伙很懒,什么也没写!

注册于 3年前

回答
184
文章
2
关注者
19

改为

\begin{beamer}[fragile]
...
\end{beamer}

https://tex.stackexchange.com/questions/253760/

另外你 \usetikzlibrary{datavisualization} 写了两次。不能写在正文里,应该写在导言区。

titlesec 目前可能并不兼容 AMS 文档类:https://tex.stackexchange.com/questions/543478/

如果只是想改一下 \section 的字体,可以在导言区加上:

\makeatletter
% \def\contentsnamefont{\bfseries} % 如果要改Contents
\def\section{\@startsection{section}{1}%
  \z@{.7\linespacing\@plus\linespacing}{.5\linespacing}%
  {\normalfont\large\bfseries\centering}}
\makeatother

想把 Abstract 加粗,只要把你贴出的那段代码

\item[\hskip\labelsep\scshape\abstractname.]

里的 \scshape 改成 \bfseries 即可。最好在导言区重定义 abstract 环境,而不修改 amsart.cls 文件。

另外,如果要查看某个文档类里的某个命令或环境的定义,.dtx 文件不是最好的选择,它可能包含无关代码,查看对应的 .cls 文件即可。

\documentclass{ctexbook}
\usepackage[left=2cm,right=2cm,top=.6cm,bottom=2.2cm]{geometry}
\usepackage{amsmath,amsthm}
\usepackage{xcolor,ninecolors}
\usepackage{tikz}
\usetikzlibrary{shadows}
\usepackage[most]{tcolorbox}

\usepackage{zhlipsum}

\makeatletter

\definecolor{CyaN}{HTML}{dbe1e5}
\colorlet{OrangE}{yellow!20!orange}
\colorlet{BluE}{cyan!70!blue}
\colorlet{ReD}{red!20!orange}
\colorlet{GreeN}{yellow!40!green}
\definecolor{nuanbai}{HTML}{f5f5f5}

\tcbset{my@basic@thm/.style={enhanced jigsaw, breakable, 
  enlarge left by=-3.5mm, width=\textwidth+3.5mm, boxrule=0pt, 
  top=2pt, bottom=2pt, left=2.5mm, frame hidden}}
\newcommand{\@my@newtheorem@n}[1]{\ERROR}
\newcommand{\@my@newtheorem@nn}[2]{%
  \@ifundefined{#1}{\@my@newtheorem{#1}#2}{\@my@renewtheorem{#1}#2}}
\NewDocumentCommand{\@my@newtheorem}{ m m o +m }
  {\IfNoValueTF{#3}{\newtheorem{#1}{#2}}{\newtheorem{#1}{#2}[#3]}%
    \tcbset{my@#1@thmstyle/.style={#4}}%
    \tcolorboxenvironment{#1}{my@basic@thm, my@#1@thmstyle}}
\NewDocumentCommand{\@my@renewtheorem}{ m m o +m }
  {\IfNoValueTF{#3}{\renewtheorem{#1}{#2}}{\renewtheorem{#1}{#2}[#3]}%
    \tcbset{my@#1@thmstyle/.style={#4}}}

\tcbset{my@basic@tcbthm/.style={detach title,}}
\newcommand{\@my@newtcbtheorem@n}[1]{\@my@newtcbtheorem@nn{#1}{}}
\newcommand{\@my@newtcbtheorem@nn}[2]{%
  \@ifundefined{#1}{\@my@newtcbtheorem{#1}{#2}}{\@my@renewtcbtheorem{#1}{#2}}}
\newcommand{\@my@newtcbtheorem}[2]{%
  \tcbset{my@#1@tcbthmstyle/.style={#2}}%
  % 这个地方把标题保存到 \tcbtitletext 里,在后面的 overlay 需要对应修改,
  % 其它不变的内容放在单独的样式里就好
  \NewTColorBox{#1}{ O{} O{} o }
    {my@basic@tcbthm, my@#1@tcbthmstyle, title={##2}, IfNoValueF={##3}{label={##3}}, ##1}}
\newcommand{\@my@renewtcbtheorem}[2]{\tcbset{my@#1@tcbthmstyle/.style={#2}}}

\pgfkeys{/mytcbtheorem/.is family}
\newcommand{\mytcbtheoremset}{\pgfqkeys{/mytcbtheorem}}

\ExplSyntaxOn
\cs_new_protected:Npn \mynewtheorem 
  { \keyval_parse:NNn \@my@newtheorem@n \@my@newtheorem@nn }
\cs_new_protected:Npn \mynewtcbtheorem
  { \keyval_parse:NNn \@my@newtcbtheorem@n \@my@newtcbtheorem@nn }
\ExplSyntaxOff
\makeatother

%% 定义定理
\mynewtheorem{
  defi={\textbf{定义}}[section]{colback=CyaN!80, borderline west={1.5mm}{0mm}{ReD}},
  thm={\textbf{定理}}[section]{colback=CyaN, borderline west={1.5mm}{0mm}{CyaN!80!black}},
  lem={\textbf{引理}}[section]{colback=CyaN!80, borderline west={1.5mm}{0mm}{BluE}},
  prop={\textbf{命题}}[section]{colback=CyaN!80, borderline west={1.5mm}{0mm}{OrangE}},
  exam={\textbf{题}}[chapter]{colback=CyaN!80, borderline west={1.5mm}{0mm}{DarkGreen}},
  cor={\textbf{推论}}[chapter]{colback=CyaN!80, borderline west={1.5mm}{0mm}{violet}},
}
\renewcommand{\proofname}{\textbf{证明.}}
\newtheorem*{remark}{\textbf{注}}

\makeatletter
\newcommand{\my@theorem@overlay@unbroken}{
      %%============== First ==============%% 
  \fill[black!60] ([xshift=1cm,yshift=5pt]frame.north west)-- ([xshift=0.8cm,yshift=0cm]frame.north west)--([xshift=1.2cm,yshift=0cm]frame.north west)--cycle;
  \node[rectangle, text=white, drop shadow={opacity=.3, shadow xshift=0.1cm}, inner sep=1.5mm,fill=purple5,
anchor=west,rounded corners=3pt,font=\normalsize] at ([xshift=0cm,yshift=-3.mm]frame.north west) {\phantom{\rule{1.2em}{0pt}}\bf   \Theorem\ \thetcbthm.~\tcbtitletext};
  \fill[color=purple5,drop shadow={opacity=0.3,shadow xshift=.3pt}] 
      ([xshift=1cm,yshift=5pt]frame.north west) {[rounded corners=3pt]--++(-1cm-5pt,0)}--++(0,-1cm-5pt)--cycle;
      \fill[color=black!60] ([xshift=-5pt,yshift=-1cm]frame.north west)--([xshift=0cm,yshift=-0.8cm]frame.north west)-- ([xshift=0cm,yshift=-1.2cm]frame.north west)--cycle;
      %%============== End ==============%% 
  \fill[purple5,drop shadow={opacity=0.3,shadow xshift=-0.008\linewidth,shadow yshift=0.0016\linewidth}] 
  ([xshift=-0.05\linewidth,yshift=-5pt]frame.south east) {[rounded corners=3pt]--++(0.05\linewidth+5pt,0)}--++(0,0.05\linewidth+5pt)--cycle;
  \fill[black!60] ([xshift=-0.05\linewidth,yshift=-5pt]frame.south east) -- ([xshift=-0.04\linewidth,yshift=0pt]frame.south east)-- ([xshift=-0.06\linewidth,yshift=0pt]frame.south east)--cycle;
  \fill[black!60] ([xshift=5pt,yshift=0.05\linewidth]frame.south east)-- ([yshift=0.04\linewidth]frame.south east) -- ([yshift=0.06\linewidth]frame.south east)--cycle;
}
\newcommand{\my@theorem@overlay@first}{
  \fill[black!60] ([xshift=1cm,yshift=5pt]frame.north west)-- ([xshift=0.8cm,yshift=0cm]frame.north west)--([xshift=1.2cm,yshift=0cm]frame.north west)--cycle;
  \node[rectangle, text=white, drop shadow={opacity=.3, shadow xshift=0.1cm}, inner sep=1.5mm,fill=purple5, anchor=west,rounded corners=3pt,font=\normalsize] at ([xshift=0cm,yshift=-3.mm]frame.north west) {\phantom{\rule{1.2em}{0pt}}\bf  \Theorem\ \thetcbthm.~\tcbtitletext};
  \fill[color=purple5,drop shadow={opacity=0.3,shadow xshift=.3pt}] 
        ([xshift=1cm,yshift=5pt]frame.north west) {[rounded corners=3pt]--++(-1cm-5pt,0)}--++(0,-1cm-5pt)--cycle;
  \fill[color=black!60] ([xshift=-5pt,yshift=-1cm]frame.north west)--([xshift=0cm,yshift=-0.8cm]frame.north west)-- ([xshift=0cm,yshift=-1.2cm]frame.north west)--cycle;
}
\newcommand{\my@theorem@overlay@last}{
  \fill[purple5,drop shadow={opacity=0.3,shadow xshift=-0.008\linewidth,shadow yshift=0.0016\linewidth}] 
  ([xshift=-0.05\linewidth,yshift=-5pt]frame.south east) {[rounded corners=3pt]--++(0.05\linewidth+5pt,0)}--++(0,0.05\linewidth+5pt)--cycle;
  \fill[black!60] ([xshift=-0.05\linewidth,yshift=-5pt]frame.south east) -- ([xshift=-0.04\linewidth,yshift=0pt]frame.south east)-- ([xshift=-0.06\linewidth,yshift=0pt]frame.south east)--cycle;
  \fill[black!60] ([xshift=5pt,yshift=0.05\linewidth]frame.south east)-- ([yshift=0.04\linewidth]frame.south east) -- ([yshift=0.06\linewidth]frame.south east)--cycle;
}
\newcounter{tcbthm}
\mytcbtheoremset{
  theorem name/.store in=\Theorem,
  theorem autoref name/.store in=\tcbthmautorefname,
  theorem the counter/.store in=\thetcbthm,
  theorem style/.code=\tcbset{my@theorem@tcbthmstyle/.style={#1}},
}
% 定义和设置tcb定理
\mytcbtheoremset{
  theorem name=定理,
  theorem autoref name=\bfseries 定理,
  theorem the counter=\thesection.\arabic{tcbthm},
  % theorem style={}, % 改变样式
}
\mynewtcbtheorem{
  theorem={
    arc=3pt,breakable,enhanced,colback=nuanbai,boxrule=0pt,top=8mm,
    fuzzy shadow={-0.6mm}{0.6mm}{0mm}{0.3mm}{white!50!gray},% 上
    fuzzy shadow={0.6mm}{-0.6mm}{0mm}{0.3mm}{fill=white!40!gray},%下
    opacityframe=0, opacityback=0.98,
    fontupper=\itshape, step={tcbthm},
    before pre=\smallskip, after app=\smallskip,
    overlay unbroken=\my@theorem@overlay@unbroken,
    overlay first=\my@theorem@overlay@first,
    overlay last=\my@theorem@overlay@last,
  },
}
\makeatother

\begin{document}

\chapter{章}
\section{结}

\zhlipsum[1][name=zhufu]

\begin{thm}
\zhlipsum[1][name=zhufu]
\end{thm}

\begin{theorem}
\zhlipsum[2][name=zhufu]
\end{theorem}

\end{document}

这样定义的和你的效果一样:
image.png

把长的代码保存到一个命令里,把重复使用的保存到一个命令(或 style)里。

用到 LaTeX3 的只有一个地方。键值设置可以用 pgfkeys 实现,不需要用 LaTeX3。

下一个问题和这个问题无关,应该分别提问。
我修改了代码,可以使用 ys/frame/not at break 这个键来设置不显示断开位置的线,还增加了设置透明度的选项,用法如下:

\begin{tcolorbox}[enhanced,ys style,breakable,pad at break=2mm,
  ys/frame/not at break,ys/frame/fill opacity=0.2]
\zhlipsum[2-20][name=zhufu]
\end{tcolorbox}

代码见 https://gitee.com/Sophanatprime/SomeTeXMacro/blob/main/style/tcbstyle1.tex
https://github.com/Sophanatprime/SomeTeXMacro/blob/main/style/tcbstyle1.tex

tcolorbox 里的 multicols 环境不能分页。
可以参考:https://tex.stackexchange.com/questions/304722

另外一种实现方式是,在 multicols 外面加上一个 tcolorbox 盒子。
https://gitee.com/Sophanatprime/cus/tree/dev/(或 https://github.com/Sophanatprime/cus/tree/dev)。
通过 patch multicols 环境,在它的外面套上一个盒子。
实现的代码在 cus.module.box.tex 文件里,支持 tcolorbox 盒子的代码在 cus.library.tcb.tex 文件里。
image.png
移植这个功能也不难。

这是因为每个汉字的高度和深度并不一定相同。都加上一个 \strut 就行了。
如果觉得 \strut 太大,可以

\newcommand\mystrut{\vrule height .8em depth 0.2em width 0pt\relax}

自己调整 heightdepth 到一个合适的值就行了。

tikzoverlay 本来就“不占空间”,它把图片叠在文字上。删掉之后还要把 \titlespacing 设置的间距改回来。

\documentclass{article}
\usepackage{graphicx} % Required for inserting images
\usepackage{tikz}
\usepackage{varwidth}
\usetikzlibrary{shadows,calc}
\usepackage[explicit]{titlesec}
\titleformat{\section}
{}
{}
{-.5em} %左右移动\thesection标签位置
{\mysectionformat{#1}}

\newcommand{\mysectionformat}[1]{%
\makebox[0pt][l]{\def\rad{7pt}\def\Rad{3.5pt}\def\tlength{3cm}\def\theight{0.8cm}%
\begin{tikzpicture}%[remember picture,overlay]
    \coordinate (sec) at (.6cm,0);
    \fill[color=teal!80!black] ([xshift=\tlength-\Rad,yshift=5pt]sec.north west) coordinate (secnw) to[out=0,in=90,looseness=0.7] ([xshift=\tlength+0.5*\Rad]sec.north west) coordinate (NW)--([xshift=-2*\rad]NW)--cycle;
    \path[fill=teal,drop shadow={opacity=0.3,shadow xshift=.05cm,shadow yshift=-.05cm}]
    ([xshift=\rad,yshift=5pt]sec.north west) coordinate (topleft) to[out=180,in=0,looseness=1] ([xshift=-3*\rad,yshift=-\theight]sec.north west) --([xshift=\tlength-4*\rad,yshift=-\theight]sec.north west) coordinate (bottomright) to[out=0,in=180] ([xshift=\tlength,yshift=5pt]sec.north west) --cycle;
    \draw[teal,line width=0.5pt] (NW)--++(.8\linewidth,0);
    \coordinate (SecName) at ($(topleft)!0.5!(bottomright)$);
    \node[text=white,font=\rmfamily\large\bfseries] at (SecName) {Sec \thesection};
    \node[text=black,font=\rmfamily\bfseries\Large,below right] (secnum) at ([shift={(.1cm,-.16cm)}]secnw) {\begin{varwidth}{.8\linewidth}\setlength\baselineskip{22.5pt}#1\end{varwidth}};
\end{tikzpicture}}}

\titlespacing{\section}{0pt}{0pt}{0pt}
\title{test}
\author{1479840692 }
\date{March 2023}
\usepackage{lipsum}
\begin{document}

\maketitle

\section{Introduction}
\lipsum[1]
\section{\lipsum[2]}
\lipsum[3]
\end{document}

至于加上 \makebox[0pt][l] 则是避免盒子 overfull。

提问的信息太少。
如果使用 biblatex 宏包,可以使用它提供的 heading 键修改:

% 导言区
\defbibheading{subsecbib}[\bibname]{\subsubsection*{#1}}

% 输出参考文献的位置
\printbibliography[heading=subsecbib]

如果使用 natbib 宏包,则

\usepackage{natbib}
\renewcommand{\bibsection}{\subsection*{\bibname}}

如果使用默认的输出方式,即 \bibliography,则需要修改 thebibliography 环境,一个可能的修改是:

% \usepackage{etoolbox}
\patchcmd{\thebibliography}{\chapter*}{\subsection*}{}{\ERROR}

不要直接修改 \@captype,改成这样:

\newcommand\figcaption{\captionsetup{type=figure}\caption} 
\newcommand\tabcaption{\captionsetup{type=table}\caption} 

或者

\newcommand\figcaption{\setcaptiontype{figure}\caption} 
\newcommand\tabcaption{\setcaptiontype{table}\caption} 

\tag 里加上 tabular 就可以了。

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\newcommand{\tagarray}[2][r]{\refstepcounter{equation}%
  \tag*{\tabcolsep\z@ \jot\z@ \begin{tabular}{#1}#2\end{tabular}}}
\makeatother

\begin{document}

\begin{equation}
\boxed{D_p = \int_a^b \mathrm{d}x} \tagarray{(\theequation)\\(diffusion coefficient)}\label{wd}
\end{equation}

\end{document}

image.png

step and label={tcbthm}{#3} 改成 step={tcbthm}, IfBlankF={#3}{label={#3}}
你这个代码问题太多了,为什么要先定义 wwtheorem,再定义一个 theorem 呢,直接用 \NewTColorBox 就行了,再加上 before pre=\smallskip, after app=\smallskip,或者用环境钩子。
还有,应该这么写 \begin{wwtheorem}[#1]{#2}{#3}
还有 wwtheorem 的定义里,#1 前面没有加上逗号。

MWE:

\documentclass{ctexart}
\usepackage{xcolor}
\colorlet{nuanbai}{gray!1}
\usepackage{ninecolors}
\usepackage{tikz}
\usetikzlibrary{calc,shadows}
\usepackage[many]{tcolorbox}
\tcbuselibrary{breakable,xparse} % 旧版本要 xparse

\newcounter{tcbthm}
\def\tcbthmautorefname{\bf 定理}
\newcommand{\Theorem}{定理}
\NewTColorBox{theorem}{O{} O{} o}
  {arc=3pt,breakable,enhanced,colback=nuanbai,boxrule=0pt,top=8mm,
    fuzzy shadow={-0.6mm}{0.6mm}{0mm}{0.3mm}{white!50!gray},% 上
    fuzzy shadow={0.6mm}{-0.6mm}{0mm}{0.3mm}{fill=white!40!gray},%下
    opacityframe=0, opacityback=0.98,
    fontupper=\itshape, step={tcbthm}, IfNoValueF={#3}{label={#3}},
    before pre=\smallskip, after app=\smallskip,
    overlay unbroken = {
      \fill[black!60] ([xshift=1cm,yshift=5pt]frame.north west)-- ([xshift=0.8cm,yshift=0cm]frame.north west)--([xshift=1.2cm,yshift=0cm]frame.north west)--cycle;
            %标题 %更改有效
            \node[rectangle, 
    text=white, drop shadow={opacity=.3, shadow xshift=0.1cm},
    inner sep=1.5mm,fill=purple5,
    anchor=west,rounded corners=3pt,
    font=\normalsize] at ([xshift=0cm,yshift=-3.mm]frame.north west)%
    {\phantom{\rule{1.2em}{0pt}}\bf   \Theorem\ \thetcbthm.~#2};
            \fill[color=purple5,drop shadow={opacity=0.3,shadow xshift=.3pt}] 
            ([xshift=1cm,yshift=5pt]frame.north west) {[rounded corners=3pt]--++(-1cm-5pt,0)}--++(0,-1cm-5pt)--cycle;
      \fill[color=black!60] ([xshift=-5pt,yshift=-1cm]frame.north west)--([xshift=0cm,yshift=-0.8cm]frame.north west)-- ([xshift=0cm,yshift=-1.2cm]frame.north west)--cycle;
            %%============================%% End
            \fill[purple5,drop shadow={opacity=0.3,shadow xshift=-0.008\linewidth,shadow yshift=0.0016\linewidth}] 
            ([xshift=-0.05\linewidth,yshift=-5pt]frame.south east) {[rounded corners=3pt]--++(0.05\linewidth+5pt,0)}--++(0,0.05\linewidth+5pt)--cycle;
            \fill[black!60] ([xshift=-0.05\linewidth,yshift=-5pt]frame.south east) -- ([xshift=-0.04\linewidth,yshift=0pt]frame.south east)-- ([xshift=-0.06\linewidth,yshift=0pt]frame.south east)--cycle;
            \fill[black!60] ([xshift=5pt,yshift=0.05\linewidth]frame.south east)-- ([yshift=0.04\linewidth]frame.south east) -- ([yshift=0.06\linewidth]frame.south east)--cycle;
        },%上面是实际控制代码,下面的代码仅在跨页分割时生效
    overlay first = {%跨页时生效
    \fill[black!60] ([xshift=1cm,yshift=5pt]frame.north west)-- ([xshift=0.8cm,yshift=0cm]frame.north west)--([xshift=1.2cm,yshift=0cm]frame.north west)--cycle;
            %标题 %跨页时生效
    \node[rectangle, 
    text=white, drop shadow={opacity=.3, shadow xshift=0.1cm},
    inner sep=1.5mm,fill=purple5,
    anchor=west,rounded corners=3pt,
    font=\normalsize] at ([xshift=0cm,yshift=-3.mm]frame.north west)%
    {\phantom{\rule{1.2em}{0pt}}\bf  \Theorem\ \thetcbthm.~#2};
    \fill[color=purple5,drop shadow={opacity=0.3,shadow xshift=.3pt}] 
            ([xshift=1cm,yshift=5pt]frame.north west) {[rounded corners=3pt]--++(-1cm-5pt,0)}--++(0,-1cm-5pt)--cycle;
            \fill[color=black!60] ([xshift=-5pt,yshift=-1cm]frame.north west)--([xshift=0cm,yshift=-0.8cm]frame.north west)-- ([xshift=0cm,yshift=-1.2cm]frame.north west)--cycle;
        },%保持边缘的变化
        overlay last = {%跨页时生效
            %%============================%% End
            \fill[purple5,drop shadow={opacity=0.3,shadow xshift=-0.008\linewidth,shadow yshift=0.0016\linewidth}] 
            ([xshift=-0.05\linewidth,yshift=-5pt]frame.south east) {[rounded corners=3pt]--++(0.05\linewidth+5pt,0)}--++(0,0.05\linewidth+5pt)--cycle;
            \fill[black!60] ([xshift=-0.05\linewidth,yshift=-5pt]frame.south east) -- ([xshift=-0.04\linewidth,yshift=0pt]frame.south east)-- ([xshift=-0.06\linewidth,yshift=0pt]frame.south east)--cycle;
            \fill[black!60] ([xshift=5pt,yshift=0.05\linewidth]frame.south east)-- ([yshift=0.04\linewidth]frame.south east) -- ([yshift=0.06\linewidth]frame.south east)--cycle;
        },
     #1}
\begin{document}

\begin{theorem}%[][][],三个可选参数,第一个是键值,第二个是标题,第三个是 label
测试1
\end{theorem}

\begin{theorem}
测试2
\end{theorem}
\end{document}

做不到。
这种效果要对图片本身进行操作。
你看到的 tikz 里的 shading 和 shadow 都是由 PDF 阅读器完成的,这类计算对 tikz 来说太复杂了。

\newcommand\bookseries[1]{\def\@bookseries{#1}}

\newcommand* 相当于 \def,它定义的命令的参数不能有 \par
\newcommand 相当于 \long\def,它定义的命令的参数可以有 \par

有三种方式:

  • 使用 unicode-math 设置数学字体,range 键可以设置仅使用字体的某些字符;会改变全局的数学字体
  • 使用 unicode-math\setmathfontface,然后像使用 \mathrm 一样使用,不能改符号的字体
  • 使用 \DeclareMathRadical 之类的来改个别符号
\documentclass{standalone}
\usepackage{tikz,amsmath}
\usepackage{xcolor}
\usepackage{xeCJK}
\usepackage{unicode-math}
\newfontfamily\prof[Path=MyFonts/]{ArchitectsDaughter.ttf}
%% 第一种
\setmathfont{Latin Modern Math}
\setmathfont{ArchitectsDaughter.ttf}[range={up/{num},`+,`=},Path=MyFonts/]

%% 第二种
\setmathfontface\mathprof{ArchitectsDaughter.ttf}[Path=MyFonts/]

\begin{document}
\begin{tikzpicture}
\node[blue,font=\fontsize{20}{0}\selectfont] at (0,5) {\prof 0.02+0.015=0.035 };
%% 第一种
\node[red,font=\fontsize{20}{0}\selectfont] at (0,4) {$0.02+0.015=0.035$};
\node[red,font=\fontsize{20}{0}\selectfont] at (0,3) {$\sqrt{0.0004}+0.015=0.035$};

%% 第二种
\node[red,font=\fontsize{20}{0}\selectfont] at (0,2) {$\sqrt{\mathprof{0.0004}}\mathprof{{}+0.015=0.035}$};
\end{tikzpicture}
\end{document}

tocloft 中,是由 \cftpartfillnum \cftchapfillnum \cftsecfillnum \cftsubsecfillnum 等命令输出页码的。
要实现第二种效果,需要重定义对应的 \cft..fillnum 命令:

\makeatletter
\renewcommand{\cftsecfillnum}[1]{%
  {\cftsecleader}\nobreak
  \makebox{\cftsecpagefont #1}\cftsecafterpnum\par
}
\makeatother

image.png

\documentclass{ctexart}
\usepackage[titles]{tocloft}
\begin{document}
\renewcommand{\cftsecdotsep}{0.5}
\renewcommand{\cftsubsecdotsep}{0.5}
\renewcommand{\cftdot}{$\cdot$}
\renewcommand{\cftsecpagefont}{\rmfamily}
\cftsetpnumwidth{1em}
\makeatletter
\renewcommand{\cftsecfillnum}[1]{%
  {\cftsecleader}\nobreak
  \makebox{\cftsecpagefont #1}\cftsecafterpnum\par
}
\makeatother
\tableofcontents
\setcounter{page}{9}
\section{示例}
\clearpage
\subsection{示例}
\end{document}

发布
问题