美文网首页
latex定制标题样式

latex定制标题样式

作者: 真人找个 | 来源:发表于2019-02-02 19:54 被阅读0次
    主要说明下标题格式的设置方式,包括字体、字号、段前后间距、标题标签等

    用\CTEXsetup命令

    如下:

    
    \CTEXsetup[name={第,章 },format={\centering\heitiB\zihao{3}},aftername={\enspace},beforeskip={24bp},afterskip={18bp}]{section}  %name选项中不要使用中文逗号
    
    \CTEXsetup[format={\raggedright\heiti\zihao{-3}},aftername={\enspace},beforeskip={24bp},afterskip={6bp}]{subsection}
    
    \CTEXsetup[format={\raggedright\heiti\zihao{4}},aftername={\enspace},beforeskip={12bp},afterskip={6bp}]{subsubsection}
    
    

    存在的还未解决的问题有三点:

    • 字体命令对标签中的数字编号不起作用

    • 生成的目录格式没有按上面设置的标题格式展示

    • 低一级标题紧接高一级标题时,两级标题之间的间距以高级标题的段后间距为准,而不是以段前间距和段后间距的最大值为准

    修改底层命令(姑且这么说)

    如下:

    
    \makeatletter  %可行
    
    \renewcommand\section{\@startsection{section}{1}{\z@}%
    
    {24bp\@plus 1ex \@minus .2ex}%
    
    {18bp \@plus .2ex}%
    
    {\heitiB\centering\zihao{3}}}
    
    \renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
    
    {24bp\@plus 1ex \@minus .2ex}%
    
    {6bp \@plus .2ex}%
    
    {\heiti\zihao{-3}}}
    
    \renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}
    
    {12bp\@plus 1ex \@minus .2ex}%
    
    {6bp \@plus .2ex}%
    
    {\heiti\zihao{4}}}
    
    \makeatother
    
    \renewcommand{\thesection}{第\arabic{section}章}
    
    \renewcommand{\thesubsection}{\arabic{section}.\arabic{subsection}}
    
    \renewcommand{\thesubsubsection}{\arabic{section}.\arabic{subsection}.\arabic{subsubsection}}
    
    

    第二中方式的三个\renewcommand可以使目录中的标题展示为我们想要的样式。

    但仍存在两个问题:

    • 字体命令仍不能对数字编号起作用

    • \makeatletter...\makeatother这种用法不熟悉,而且其中符号\z@的含义还不清楚

    最后给出代码供大家调试

    
    \documentclass{ctexart}
    
    %可行
    
    %\CTEXsetup[name={第,章 },format={\centering\heiti\zihao{3}},aftername={\enspace},beforeskip={24bp},afterskip={18bp}]{section}  %name选项中不要使用中文逗号
    
    %\CTEXsetup[format={\raggedright\heiti\zihao{-3}},aftername={\enspace},beforeskip={24bp},afterskip={6bp}]{subsection}
    
    %\CTEXsetup[format={\raggedright\heiti\zihao{4}},aftername={\enspace},beforeskip={12bp},afterskip={6bp}]{subsubsection}
    
    
    
    \makeatletter  %可行
    
    \renewcommand\section{\@startsection{section}{1}{\z@}%
    
    {24bp\@plus 1ex \@minus .2ex}%
    
    {18bp \@plus .2ex}%
    
    {\heiti\centering\zihao{3}}}
    
    \renewcommand\subsection{\@startsection{subsection}{2}{\z@}%
    
    {24bp\@plus 1ex \@minus .2ex}%
    
    {6bp \@plus .2ex}%
    
    {\heiti\zihao{-3}}}
    
    \renewcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}
    
    {12bp\@plus 1ex \@minus .2ex}%
    
    {6bp \@plus .2ex}%
    
    {\heiti\zihao{4}}}
    
    \makeatother
    
    \renewcommand{\thesection}{第\arabic{section}章}
    
    \renewcommand{\thesubsection}{\arabic{section}.\arabic{subsection}}
    
    \renewcommand{\thesubsubsection}{\arabic{section}.\arabic{subsection}.\arabic{subsubsection}}
    
    
    
    \begin{document}
    
        \tableofcontents
    
        \section{咚咚咚}
    
        \subsection{咚咚咚咚咚}
    
        咚咚咚咚咚咚咚咚咚咚咚咚咚咚咚咚咚咚咚咚\\咚咚咚咚咚咚咚咚咚咚咚咚咚咚咚咚咚咚咚咚
    
        \subsubsection{咚咚咚咚咚咚咚}
    
        咚咚咚咚咚咚咚咚咚咚咚咚咚咚咚咚咚咚咚咚\\咚咚咚咚咚咚咚咚咚咚咚咚咚咚咚咚咚咚咚咚
    
        \section{锵锵锵}
    
        \subsection{锵锵锵锵锵}
    
        \subsubsection{锵锵锵锵锵锵锵}
    
    \end{document}
    
    

    相关文章

      网友评论

          本文标题:latex定制标题样式

          本文链接:https://www.haomeiwen.com/subject/onqesqtx.html