更改目录编号

更改目录编号

如何更改目录中某一部分的编号?

例子:

(实际情况)

动力学简介.................. #

(期望情况)

附录 A 动力学简介......... #

平均能量损失

\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{standalone}

\usepackage{wallpaper}
\usepackage{color}
\definecolor{darkblue}{RGB}{6,0,111}
\definecolor{red}{RGB}{255,0,0}
\definecolor{green}{RGB}{0,125,0}

\usepackage{indentfirst}
\setlength\parindent{1.25cm}

\usepackage{graphicx}
%\DeclareGraphicsExtensions{.jpg,.png}

\renewcommand*\contentsname{\centering SUMÁRIO}
\usepackage{titletoc}
\usepackage[titletoc,title]{appendix}

\setcounter{secnumdepth}{6}
\setcounter{tocdepth}{6}

\titlecontents{section}[0em]{\medskip\bfseries}
{\thecontentslabel\enspace} %numbered
{} %numberless
{\titlerule*[1.5mm]{.}\contentspage}

\titlecontents{subsection}[0em]{\smallskip}
{\thecontentslabel\enspace} %numbered
{} %numberless
{\normalfont\titlerule*[1.5mm]{.}\contentspage}

\titlecontents{subsubsection}[0em]{\smallskip\bfseries}
{\thecontentslabel\enspace} %numbered
{} %numberless
{\normalfont\titlerule*[1.5mm]{.}\contentspage}

\titlecontents{paragraph}[0em]{\smallskip}
{\thecontentslabel\enspace} %numbered
{} %numberless
{\normalfont\titlerule*[1.5mm]{.}\contentspage}

\titlecontents{subparagraph}[0em]{\smallskip\itshape}
{\thecontentslabel\enspace} %numbered
{} %numberless
{\normalfont\titlerule*[1.5mm]{.}\contentspage}

\usepackage{enumitem}
\usepackage{multirow}
\usepackage{booktabs}

\usepackage{setspace}
\singlespacing

\usepackage{units}

\usepackage{hyphenat}

\usepackage{nicefrac}
\usepackage{pdflscape}

\usepackage[fleqn]{amsmath}
\makeatletter
\g@addto@macro\normalsize{%
    \setlength\abovedisplayskip{0mm}
    \setlength\belowdisplayskip{5mm}
    \setlength\abovedisplayshortskip{0mm}
    \setlength\belowdisplayshortskip{0mm}
    \setlength{\mathindent}{12.5mm}
}
\makeatother

\usepackage{txfonts}

\pagestyle{myheadings}
\makeatletter
\def\@oddhead{{\slshape\rightmark}\hfil\footnotesize\thepage}%
\makeatother

\usepackage[bottom=2cm,top=3cm,left=3cm,right=2cm]{geometry}
\usepackage{titling}
\usepackage{titlesec}
\titlelabel{\thetitle\quad}
\titleformat*{\section}{\normalsize\bfseries\uppercase}
\titleformat*{\subsection}{\normalsize\uppercase}
\titleformat*{\subsubsection}{\normalsize\bfseries}
\titleformat{\paragraph}[hang]{\normalsize}{\theparagraph}{1em}{}
\titleformat{\subparagraph}[hang]{\normalsize\itshape}{\thesubparagraph}{1em}{}

\titlespacing*{\section}{0pt}{1\baselineskip}{2\baselineskip}
\titlespacing*{\subsection}{0pt}{1\baselineskip}{2\baselineskip}
\titlespacing*{\subsubsection}{0pt}{1\baselineskip}{2\baselineskip}
\titlespacing*{\paragraph}{0pt}{1\baselineskip}{2\baselineskip}
\titlespacing*{\subparagraph}{0pt}{1\baselineskip}{2\baselineskip}

\begin{document}

    \tableofcontents

    \newpage
    \appendix
    \titlelabel{APPENDIX \thetitle\ -- }

    \section{Sec 1}

    \newpage
    \titlelabel{APPENDIX \thetitle\ -- }

    \section{Sec 2}

    \newpage
    \titlelabel{APPENDIX \thetitle\ -- }

    \section{Sec 3}     

\end{document}

答案1

例如,您可以在命令后添加以下代码\appendix

\renewcommand*{\thesection}{Appendix~\Alph{section}}
\renewcommand*{\thesubsection}{\thesection~\arabic{subsection}}
    \titlelabel{APPENDIX \thetitle\ -- }

使用\Alph{section}大写字母代替数字,第一个\renewcommand只会添加Appendix~到节标题(如果您需要大写字母,请写APPENDIX而不是我的Appendix)。您需要注释您的命令。请参阅以下 MWE 中\titlelabel标记为的更改。% <=====

完整代码(我注释掉\newpage目录和附录放在同一页):

\documentclass[a4paper,12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{standalone}

\usepackage{wallpaper}
\usepackage{color}
\definecolor{darkblue}{RGB}{6,0,111}
\definecolor{red}{RGB}{255,0,0}
\definecolor{green}{RGB}{0,125,0}

\usepackage{indentfirst}
\setlength\parindent{1.25cm}

\usepackage{graphicx}
%\DeclareGraphicsExtensions{.jpg,.png}

\renewcommand*\contentsname{\centering SUMÁRIO}
\usepackage{titletoc}
\usepackage[titletoc,title]{appendix}

\setcounter{secnumdepth}{6}
\setcounter{tocdepth}{6}

\titlecontents{section}[0em]{\medskip\bfseries}
{\thecontentslabel\enspace} %numbered
{} %numberless
{\titlerule*[1.5mm]{.}\contentspage}

\titlecontents{subsection}[0em]{\smallskip}
{\thecontentslabel\enspace} %numbered
{} %numberless
{\normalfont\titlerule*[1.5mm]{.}\contentspage}

\titlecontents{subsubsection}[0em]{\smallskip\bfseries}
{\thecontentslabel\enspace} %numbered
{} %numberless
{\normalfont\titlerule*[1.5mm]{.}\contentspage}

\titlecontents{paragraph}[0em]{\smallskip}
{\thecontentslabel\enspace} %numbered
{} %numberless
{\normalfont\titlerule*[1.5mm]{.}\contentspage}

\titlecontents{subparagraph}[0em]{\smallskip\itshape}
{\thecontentslabel\enspace} %numbered
{} %numberless
{\normalfont\titlerule*[1.5mm]{.}\contentspage}

\usepackage{enumitem}
\usepackage{multirow}
\usepackage{booktabs}

\usepackage{setspace}
\singlespacing

\usepackage{units}

\usepackage{hyphenat}

\usepackage{nicefrac}
\usepackage{pdflscape}

\usepackage[fleqn]{amsmath}
\makeatletter
\g@addto@macro\normalsize{%
    \setlength\abovedisplayskip{0mm}
    \setlength\belowdisplayskip{5mm}
    \setlength\abovedisplayshortskip{0mm}
    \setlength\belowdisplayshortskip{0mm}
    \setlength{\mathindent}{12.5mm}
}
\makeatother

\usepackage{txfonts}

\pagestyle{myheadings}
\makeatletter
\def\@oddhead{{\slshape\rightmark}\hfil\footnotesize\thepage}%
\makeatother

\usepackage[bottom=2cm,top=3cm,left=3cm,right=2cm]{geometry}
\usepackage{titling}
\usepackage{titlesec}
\titlelabel{\thetitle\quad}
\titleformat*{\section}{\normalsize\bfseries\uppercase}
\titleformat*{\subsection}{\normalsize\uppercase}
\titleformat*{\subsubsection}{\normalsize\bfseries}
\titleformat{\paragraph}[hang]{\normalsize}{\theparagraph}{1em}{}
\titleformat{\subparagraph}[hang]{\normalsize\itshape}{\thesubparagraph}{1em}{}

\titlespacing*{\section}{0pt}{1\baselineskip}{2\baselineskip}
\titlespacing*{\subsection}{0pt}{1\baselineskip}{2\baselineskip}
\titlespacing*{\subsubsection}{0pt}{1\baselineskip}{2\baselineskip}
\titlespacing*{\paragraph}{0pt}{1\baselineskip}{2\baselineskip}
\titlespacing*{\subparagraph}{0pt}{1\baselineskip}{2\baselineskip}

\begin{document}

\tableofcontents

%\newpage
\appendix
\renewcommand*{\thesection}{Appendix~\Alph{section}}% <==========================
\renewcommand*{\thesubsection}{\thesection~\arabic{subsection}}
    %\titlelabel{APPENDIX \thetitle\ -- }% <==========================

    \section{Sec 1}

    %\newpage
    %\titlelabel{APPENDIX \thetitle\ -- }% <==========================

    \section{Sec 2}

    %\newpage
    %\titlelabel{APPENDIX \thetitle\ -- }% <==========================

    \section{Sec 3}     

\end{document}

结果:

mwe 的结果

相关内容