如何为小节设置编号功能?

如何为小节设置编号功能?

我有一个报告类型的文件(我的论文)。我对章节和子章节的编号没有任何问题(它们会自行枚举并正确显示在目录中),但对于子子章节,编号从 0 开始而不是从 1 开始,而且这些编号不会显示在目录中。在下图中,我们可以看到子子章节的编号从 0(7.1.0)开始,而不是从 7.1.1 开始,而且这也不会显示在目录中。

图片编号错误

图片内容不全

我已经多次重新编译了我的代码,所以问题不在于代码的刷新或更新。有什么想法吗?提前谢谢大家,智利向你们问好。

\documentclass[letterpaper,openright,12pt]{report}
%\usepackage[spanish]{babel} %Defino idioma como español
\usepackage{graphicx} % Para Añadir imagenes
\usepackage{subfigure} %Para las subfiguras
\usepackage{caption}
\usepackage{enumitem}
\usepackage{multicol}
\usepackage{float}
\usepackage{xcolor}
\usepackage{setspace}
\usepackage{tikz}
%\usepackage[spanish]{babel}
\usepackage[english]{babel}
%\selectlanguage{spanish}
\usepackage[utf8]{inputenc}
%\usepackage[usenames, dvipsnames]{color}
\usepackage{hyperref} % Para que el pdf referencie directamente las referencias
\usepackage{amssymb,amsmath,amsfonts} %para \textbf y otras cosas
\usepackage{setspace} %sirve para espaciado del documento entre otras cosas
%\usepackage{dsfont}% para conjunto entero, reales.
\usepackage{stackrel}%paquete matematico para algunos simbolos
\usepackage{comment}
\renewcommand{\thesection}{\thechapter.\number\numexpr\value{section}-1\relax}
\renewcommand{\thesubsection}{\thesection.\number\numexpr\value{subsection}-1\relax}
\renewcommand{\thesubsubsection}{\thesubsection.\number\numexpr\value{subsubsection}-1\relax}
\setcounter{secnumdepth}{3}
% nombre y ano
%\usepackage[latin1]{inputenc} 
%\usepackage[sort&compress]{natbib}
 % citations
%%%%%%%%% TABLAS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{longtable}
\usepackage{multirow} % para las tablas
\usepackage{multicol}% Para separar columnas
\usepackage{booktabs}
%\usepackage{babelbib} %para que las referencias esten en español

\renewcommand{\thesection}{\arabic{section}}
\renewcommand{\thesubsection}{\arabic{section}.\arabic{subsection}}


%FORMATOS ESPECIFICOS MEMORIA
\setlength{\parindent}{0cm} %0 sangria
\spacing{1.5} %Espaciado
\usepackage{times} %Letra times new Roman
\usepackage{anysize}% Para definir margenes
\marginsize{3.5cm}{2cm}{2cm}{2cm}% Controla los márgenes {izquierda}{derecha}{arriba}{abajo}

%%%%%%%%%%%%%%%%%%%%%%INICIO: IMAGEN DE FONDO DE TODO EL DOCUMENTO%%%%%%%%%%%%%%%%%%%%%%%%%%%
%La opción pages puede ser all (para todo el documento) o some, para algunas partes del documento
%\usepackage[pages=all]{background}
% configuración
%\backgroundsetup{
%   scale=.2, %escala de la imagen, es recomendable que sea del mismo tamaño que el pdf
%   color=black, %fondo a usar para transparencia
%   opacity=0.2, %nivel de transparencia
%   angle=0, %en caso de querer una rotación
%   contents={
%       \includegraphics[width=\paperwidth,height=\paperheight]{escudo.png} %nombre de la imagen a utilizar como fonbfseries dasdasd \thecontentslabeldo
%   }
%}

\usepackage{titletoc}% http://ctan.org/pkg/titletoc
%\titlecontents{chapter}% <section-type>
%[0pt]% <left>
%%{\vspace{.08cm}}% <above-code>
%{}%{ \bfseries Cap\'itulo \thecontentslabel . \quad}% <numbered-entry-format>
%{\bfseries}% <numbered-entry-format>
%{\hfill \vfill}% <numberless-entry-format>
%{\bfseries \hfill \contentspage \vfill}% <filler-page-format>

\titlecontents{section}
    [0em] % Indentation
    {\addvspace{0em}\bfseries}
    {\normalsize CAP\'ITULO \thecontentslabel. \hspace*{0em} }
    {}
    {\titlerule*[0.3pc]{.}\contentspage}

\titlecontents{subsection}
    [1em] % Indentation
    {}
    {\hspace*{1em}\thecontentslabel \hspace*{1em}}
    {}
    {\titlerule*[0.3pc]{.}\contentspage}

\titlecontents{figure}
    [0em] % Indentation
    {}
    {\thecontentslabel \hspace*{1em}}
    {}
    {\titlerule*[0.3pc]{.}\contentspage}

\titlecontents{table}
    [0em] % Indentation
    {}
    {\thecontentslabel \hspace*{1em}}
    {}
    {\titlerule*[0.3pc]{.}\contentspage}


\setlength\abovedisplayskip{0pt}


%%%%%%%%%%%%%%%%%%%%%%FIN: IMAGEN DE FONDO DE TODO EL DOCUMENTO%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\begin{comment}
%Formato del titulo de los capitulos
\usepackage{titlesec} %paquete para cambiar el formato de los titulos
%Formato secciones
\titleformat{\section}
{
%\vspace{.8ex}%
\bfseries
\Large}
{\thesection.}{.5em}{}
%formato capitulos
\newcommand{\bigrule}{\titlerule[0.5mm]}
{\vspace{-2cm}
\titleformat{\chapter}[block] % cambiamos el formato de los capítulos
{\vspace{-2.6cm}\bfseries\Huge} % por defecto se usarán caracteres de tamaño \Huge en negrita
{% contenido de la etiqueta
%\titlerule % línea horizontal
%\filright % texto alineado a la derecha
%\vspace{-2cm}
%\chaptertitlename % "Capítulo" o "Apéndice" en tamaño \Large en lugar de \Huge
%\chaptername 
%\hspace{.07cm} 
%\thechapter 
%\text{. }
} % número de capítulo en tamaño \Large
{2mm} % espacio mínimo entre etiqueta y cuerpo
{\filright} % texto del cuerpo alineado a la derecha
[\vspace{-9mm} ] % después del cuerpo, dejar espacio vertical y trazar línea horizontal gruesa

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%Numeracion de paginas en esquina superior derecha
\usepackage{fancyhdr}
% primera pagina de un capitulo
\fancypagestyle{plain}{
    \fancyhead[L]{}
    \fancyhead[C]{}
    \fancyhead[R]{}
    \fancyfoot[L]{}
    \fancyfoot[C]{Mag\'ister en Ingenier\'ia Industrial, Direcci\'on de Postgrado - Universidad de Concepci\'on}
    \fancyfoot[R]{\thepage}
    \renewcommand{\headrulewidth}{0pt}
    \renewcommand{\footrulewidth}{0pt}
}
\fancyhead[R]{}
\fancyhead[L]{}
\fancyhead[C]{}
\fancyfoot[L]{}
\fancyfoot[C]{Mag\'ister en Ingenier\'ia Industrial, Direcci\'on de Postgrado - Universidad de Concepci\'on}
\fancyfoot[R]{\thepage}
\renewcommand{\headrulewidth}{0 pt}
\pagestyle{fancy}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\makeatletter
\newcommand{\figsourcefont}{\footnotesize}
\newcommand{\figsource}[1]{%
  \addtocontents{lof}{%
    {\leftskip=\cftfigurenumwidth
    \advance \leftskip \cftfigureindent
    \rightskip=\@tocrmarg
     \figsourcefont\noindent#1\protect\par}%
  }%
 }
\makeatother
\begin{comment}

%%%%%%%%%%%%%%%%%%%%%% PARA MODIFICAR EL INDICE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5
\newcommand{\mychapter}[1]{
    \setcounter{chapter}{#1}
    \setcounter{section}{0}
    \setcounter{secnumdepth}{1}
    \chapter*{#1}
    \addcontentsline{toc}{chapter}{#1}
    \setcounter{tocdepth}{3}

}
\end{comment}
\usetikzlibrary{shadows,matrix}
\usepackage{tikz}
\usepackage{hyperref}
\setcounter{secnumdepth}{3}
\setcounter{section}{0}
\setcounter{tocdepth}{3}

答案1

这是一个示例MWE(小且可编译)

\documentclass[12pt]{report}
\usepackage{lipsum}
\setcounter{secnumdepth}{3}
\begin{document}
\chapter{Ch1}
\lipsum[1]
\section{Se1}
\lipsum[1]
\subsection{SUb1}
\lipsum[1]
\subsubsection{SUb2}
\lipsum[1]
\end{document}

如果您编译它,子小节将根据需要进行编号。

在您的代码中,节号的外观被重新定义了几次,而默认设置似乎提供了您所寻找的内容。

相关内容