不带标号的标题居中问题

发布于 2021-05-16 22:30:16

想居中不带编号的标题,并在目录中显示,但是出现了这种情况QQ图片20210516222904.png
发行版:TeXLive2020
VScode编写
MWE:

\documentclass{article}
\usepackage{ctex}
\usepackage{graphicx,titletoc}
\newcommand*{\song}{\CJKfamily{zhsong}} % 宋体
\newcommand*{\hei}{\CJKfamily{zhhei}} % 黑体
\newcommand*{\kai}{\CJKfamily{zhkai}} % 楷书
\renewcommand{\baselinestretch}{1.25}    % 1.5倍行距
\newcommand{\erhao}{\fontsize{22pt}{33pt}\selectfont}
\newcommand{\sanhao}{\fontsize{16pt}{24pt}\selectfont}
\newcommand{\sihao}{\fontsize{14pt}{21pt}\selectfont}
\newcommand{\xiaosi}{\fontsize{12pt}{18pt}\selectfont}
\newcommand{\wuhao}{\fontsize{10.5pt}{\baselineskip}\selectfont}
\ctexset{
    section={
        format={\zihao{3}\heiti},
        name={},
        aftername={\hspace{1em}},
        number=\arabic{section},
    },
    subsection={
        format={\zihao{4}\heiti},
        name={},
        aftername={\hspace{1em}},
        number={\arabic{section}.\arabic{subsection}},
    },
    subsubsection={
        format={\zihao{-4}\heiti},
        name={},
        aftername={\hspace{1em}},
        number={\arabic{section}.\arabic{subsection}.\arabic{subsubsection}},
    },
    paragraph={
        format={\zihao{-4}\heiti},
        name={},
        aftername={\hspace{1em}},
        number={\arabic{section}.\arabic{subsection}.\arabic{subsubsection}.\arabic{paragraph}}
    },
    appendix={
        name={附录,:},
        number=\arabic{section},
    }
}
\titlecontents{section}
    [0mm]
    {\xiaosi \hei \vspace{7.5pt}}%
    {\contentslabel{6.35mm}}%
    {}%
    {{~\titlerule*[0.6pc]{$.$}~\contentspage}}%
\titlecontents{subsection}
    [3.175mm]
    {\xiaosi \song \vspace{7.5pt}}%
    {\contentslabel{9.525mm}}%
    {}%
    {{~\titlerule*[0.6pc]{$.$}~\contentspage}}%
\titlecontents{subsubsection}
    [6.35mm]
    {\xiaosi \song \vspace{7.5pt}}%
    {\contentslabel{12.7mm}}%
    {}%
    {{~\titlerule*[0.6pc]{$.$}~\contentspage}}%
\titlecontents{paragraph}
    [9.525mm]
    {\xiaosi \song \vspace{7.5pt}}%
    {\contentslabel{15.875mm}}%
    {}%
{{~\titlerule*[0.6pc]{$.$}~\contentspage}}%
\newcommand\specialsectioning{\setcounter{secnumdepth}{-2}}
\title{标题标题标题}
\begin{document}

 \section{一级标题} 
    
    文本文本

    \newpage
    \specialsectioning
    \centering{  \section{总结与展望} }
    
    文本文本
\end{document}

查看更多

关注者
0
被浏览
1.3k
1 个回答
乙醇
乙醇 2021-05-16
这家伙很懒,什么也没写!

首先要说你的写法比较复古, 建议用命令行运行 texdoc lshort-zh-cn 来系统的学习一下, 如果你想让 \section 居中的话, 使用 ctexart 文档类的默认设置就是 \section 居中
image.png

而不是用 \center{\section{}} 这样.

如果你想调整各章节的格式, 建议使用 ctex 宏集或 titlesec 宏包去设置, 用命令行运行 texdoc 宏包名 来打开帮助文档.


顺便, 您的 MWE 在我这里 (Win10 20H2, TeXLive 2021) 编译失败, 如果将文档类改为 ctexart 可以编译, 并且没有您描述的问题
image.png

撰写答案

请登录后再发布答案,点击登录

发布
问题

分享
好友

手机
浏览

扫码手机浏览