关于本节的问题

关于本节的问题

您好,目前我在部分方面遇到了麻烦。这是代码,当我在第二页运行它时,它显示 1 个测试,但由于它是部分,我期望得到 1.1 个测试,但事实并非如此。

\documentclass{report}
\usepackage{xcolor}
\usepackage{listings}
\usepackage{float}
\usepackage{amsmath}  
\usepackage[a4paper,margin=1in,footskip=0.25in]{geometry}
\usepackage{graphicx}
\usepackage{tcolorbox}
\usepackage[parfill]{parskip}
\usepackage{mdframed}
\usepackage{eso-pic,xcolor}
\tcbuselibrary{breakable} 
\usepackage{tocloft}
\usepackage{fancyhdr}
\usepackage{scrextend}

\colorlet{mygray}{black!30}
\colorlet{mygreen}{green!60!blue}
\colorlet{mymauve}{red!60!blue}




\newcommand*\tocsection[2]{%
  \stepcounter{section}%
  \contentsline{section}{\numberline{\thesection}#1}{#2}%
}
\newcommand*\tocsubsection[2]{%
  \stepcounter{subsection}%
  \contentsline{subsection}{\numberline{\thesubsection}#1}{#2}%
}

\parindent 0pt



\begin{document}


\newpage
\huge
\cleardoublepage
\pagenumbering{roman} 
\setlength\parindent{0pt}
Table of Contents\\
\normalsize

\renewcommand{\thesection}{\arabic{section}}
\renewcommand{\thesubsection}{\thesection.\arabic{subsection}}
\large
\renewcommand{\thesection}{\Roman{section}}
\renewcommand{\thesection}{\arabic{section}}
\setcounter{section}{0}
\tocsection{test2}{1}
\tocsubsection{First subsection}{1}
\tocsubsection{Second subsection}{3}
\tocsubsection{Third subsection}{3}



\setlength\parindent{24pt}

\newpage
\pagenumbering{arabic}



\chapter{Test}

\large

\section{Test}
\hspace{20pt} TEST



\end{document}

我怎样才能解决这个问题?

答案1

使用\renewcommand{\thesection}{\thechapter.\arabic{section}}(序言中)

A

....
\renewcommand{\thesection}{\thechapter.\arabic{section}} % changed <<<<<<<<<<<<<<
\renewcommand{\thesubsection}{\thesection.\arabic{subsection}}

\begin{document}
    
%   \newpage
    \huge
%   \cleardoublepage
    \pagenumbering{roman} 
    \setlength\parindent{0pt}
    Table of Contents\\
    \normalsize 
    ....

相关内容