我如何计算每个章节中的小节总数。实际上,每个章节中的章节和每个章节中的小节都是如此article
。基于此邮政我已尽力,但没有成功。(我是新手)。
这可能吗?有人能帮助我吗?
编辑
非常感谢您的及时回复。以下是我希望实现的一个非常简短的示例:
答案1
更新(2017/01/14)
我已将新版本上传cntperchap
到 CTAN,现在称为xcntperchap
,它允许通过标签和多个轨道级别进行跟踪。
编辑(2016/05/09):更新:我发现了 中的一个奇怪的小错误xassoccnt
,它导致了一些令人讨厌的值。请参阅本文底部的off-by-one
新相似版本的临时版本。cntperchap
可以用于此(通常),但和cntperchap
不匹配(我是这两个包的作者,所以我知道这一点并且必须(很快)纠正它)。cntperchap
assoccnt
如果没有其他办法,请使用此by-pass
解决方案:cntchap
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{cntchap}[2015/06/01 v0.3 -- store counter values per chapter]%
%%
%% License: LaTeX Project Public License version 1.3
%% Copyright (2015) Dr. Christian Hupfer
%% Author: Christian Hupfer [email protected]
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%% http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%%
%% This work has the LPPL maintenance status `maintained'.
%%
%% This work consists of all files listed in README
%%
%%%%
\RequirePackage{ifthen}
\RequirePackage{xassoccnt}
\RequirePackage{morewrites}
\RequirePackage{xkeyval}
\RequirePackage{xpatch}
\RequirePackage{xparse}
%%%% Data macros
\def\cps@@data@@tracklevel{chapter}
\edef\cps@@data@@packagename{\@currname} % Store the actual packagename
\newcommand{\cpspackagename}{%
\cps@@data@@packagename%
}
\newcommand{\@cps@@writefilehandleprefix}{tf@cps}
%%%%%
%%%% Preconfiguration depending on the class in the background
\edef\cps@@config@@tracklevel{\cps@@data@@tracklevel}%
\@ifclassloaded{article}{%
\edef\cps@@config@@tracklevel{section}
}{%
\@ifclassloaded{scrartcl}{%
\edef\cps@@config@@tracklevel{section}%
}{%
}%
}
\newif\ifcpsstorage
\newcommand{\EnableCPSStorage}{%
\cpsstoragetrue%
}
\newcommand{\DisableCPSStorage}{%
\cpsstoragefalse%
}
\EnableCPSStorage
%%%% Command options
\define@boolkey{cpskeys}{autodefine}[false]{}
\define@key{cpskeys}{tracklevel}[\cps@@config@@tracklevel]{%
\gdef\@cps@@keymacro@@tracklevel{#1}%
}
\presetkeys{cpskeys}{autodefine=false,tracklevel=\cps@@config@@tracklevel}{}%
\NewDocumentCommand{\DeclareCPSCounter}{s+O{cps}m}{%
\ifltxcounter{#3}{%
}{%
\newcounter{#2@@cps@@#3}%
}
% Not really useful so far
% \expandafter\newcommand\csname #3countername\endcsname{#2@@cps@@#3}%
}
\@onlypreamble{\DeclareCPSCounter}
%%%% Package options
\newif\ifcpsnoendclose
\cpsnoendclosefalse
\newif\ifcpsverbose
\cpsverbosefalse
\newif\ifcpsautodefine
\cpsautodefinefalse
\newif\ifcpsdraftmode
\cpsdraftmodetrue
\DeclareOptionX{autodefine}{\cpsautodefinetrue\presetkeys{cpskeys}{autodefine=true}{}}
\DeclareOptionX{draft}{\cpsdraftmodetrue}
\DeclareOptionX{final}{\cpsdraftmodefalse}
\DeclareOptionX{noendclose}{\cpsnoendclosetrue}
\DeclareOptionX{tracklevel}{\presetkeys{cpskeys}{tracklevel=#1}{}}
\DeclareOptionX{verbose}{\cpsverbosetrue}
\ProcessOptionsX*
\newcommand{\@cps@@counterlistname}{cps@@counterstostore}
\listcsadd{\@cps@@counterlistname}{}
%%%% Internal commands
% Instead of using totcount package
\newcounter{cps@@totaltracklevelcount}
% Intermediate package counters
\newcounter{cps@@currentlevelcount}
\newcounter{cps@@togglecounter}
\newcounter{cps@@tempcounter}
\newcounter{cps@@tempcounterstorage}
\newcounter{cps@@cpscounters}
\newcommand{\@cps@@cpscountersname}{%
cps@@cpscounters%
}
\newcommand{\@cps@@typeout}[1]{%
\ifcpsverbose%
\typeout{\cps@@data@@packagename: #1}%
\fi%
}
\NewDocumentCommand{\@cps@@tracklevelstarthook}{}{%
\stepcounter{cps@@currentlevelcount}%
\ifnumgreater{\value{cps@@currentlevelcount}}{0}{%
\StoreCounters%
}{}%
\ResetStoredCounters%
}
% This disables the usage of the automatic counter storage for ToC - like macros, since those use `\chapter*` and confuse the tracking counter
\NewDocumentCommand{\PrepareTocCommand}{m}{%
\xpretocmd{#1}{\DisableCPSStorage}{}{}% Lazy so far
\xapptocmd{#1}{\EnableCPSStorage}{}{}% Lazy so far
}
\AtBeginDocument{%
% Do a check first whether the given tracklevel does exist at all
\expandafter\ifx\csname \@cps@@keymacro@@tracklevel\endcsname\relax
\GenericError{Error}{Error in \jobname.tex: At line \the\inputlineno: The section level \@cps@@keymacro@@tracklevel\ is unknown}{%
Please check your document class and the tracklevel option}{%
}%
\else
% Generate a read file handle
\@cps@@generatereadfilehandle%
% Prepending the \csname \@cps@keymacro@tracklevel\endcsname command with some starter hook
\expandafter\xpretocmd\expandafter{\csname \@cps@@keymacro@@tracklevel\endcsname}{\@cps@@tracklevelstarthook}{\typeout{\@cps@@keymacro@@tracklevel{} command redefined}}{}%
\PrepareTocCommand{\tableofcontents}%
\PrepareTocCommand{\listoffigures}%
\PrepareTocCommand{\listoftables}%
\PrepareTocCommand{\printindex}%
\fi%
}
\AtEndDocument{%
% Store the total value of the considered sectioning level to the `.aux` file
\immediate\write\@auxout{%
\string\setcounter{cps@@totaltracklevelcount}{\number\value{cps@@currentlevelcount}}^^J
}% End of \immediate\write
}
\newcommand{\@cps@@readfilehandlename}{%
tfr@cpsreadfile%
}
\newcommand{\@cps@@readfilehandle}{%
\csname\@cps@@readfilehandlename\endcsname%
}
\newcommand{\@cps@@generatereadfilehandle}{%
\@cps@@typeout{Generating read filehandle}%
\expandafter\newread\csname \@cps@@readfilehandlename\endcsname%
}
\newcommand{\@cps@@generatewritefilehandle}[1]{%
\@cps@@typeout{Generating write filehandle #1}%
\expandafter\newwrite\csname\@cps@@writefilehandlename{#1}\endcsname% Generate the file handles
}
\newcommand{\@cps@@writefilehandle}[1]{%
\csname\@cps@@writefilehandlename{#1}\endcsname% Generate the file handles
}
\newcommand{\@cps@@writefilehandlename}[1]{%
\@cps@@writefilehandleprefix#1%
}
\newcommand{\@cps@@closeinfile}[1]{%
\immediate\closein#1%
}
\newcommand{\@cps@@openincpsfile}[2][\@cps@@readfilehandle]{%
\expandafter\immediate\openin#1=\jobname.cps#2\relax%
}
\newcommand{\@cps@@openoutcpsfile}[1]{%
\expandafter\immediate\openout\@cps@@writefilehandle{#1}=\jobname.cps#1\relax%
}
\newcommand{\@cps@@closeoutfile}[1]{%
\immediate\closeout#1%
}
\newcommand{\@cps@@closeoutcpsfile}[1]{%
\@cps@@typeout{Closing cps#1 file}%
\@cps@@closeoutfile{\csname\@cps@@writefilehandlename{#1}\endcsname}%
}
\newcommand{\@startcountertoc}[1]{%
\begingroup%
% The file handles are generated either by `\@registercounterspertracklevel` or in \AtBeginDocument
\makeatletter
% Read first before deleting it
\IfFileExists{\jobname.cps#1}{%
\@cps@@openincpsfile{#1}%
\@cps@@readcounternumbers{\@cps@@readfilehandle}{#1}%
\@cps@@closeinfile{\@cps@@readfilehandle}%
}{%
\typeout{No #1{} counter values so far}%
}
\if@filesw
% Write only if not `\nofiles` is specified
\@cps@@openoutcpsfile{#1}%
\fi%
\@nobreakfalse%
\endgroup%
}
\newcommand{\@cps@@readcounternumbers}[2]{%
\setcounter{cps@@togglecounter}{0}%
\whiledo {\value{cps@@togglecounter} < 1}{%
\read#1 to \@cps@@numberfromfile%
\ifeof #1%
\stepcounter{cps@@togglecounter}%
\else%
\listcsxadd{#2countlist}{\@cps@@numberfromfile}%
\fi%
}%
}
\newcommand{\@cps@@storecounter}[1]{%
\addtocontents{cps#1}{%
\number\value{cps@@cps@@total#1}%
}%
}
\newcommand{\@cps@@csloop}[1]{%
\ifnumgreater{\value{\@cps@@cpscountersname}}{0}{%
\expandafter\forlistcsloop{\csname #1\endcsname}{\@cps@@counterlistname}
}{%
}%
}
\newcommand{\@cps@@loopstorecounters}{%
\ifnumgreater{\value{\@cps@@cpscountersname}}{0}{%
\forlistcsloop{\@cps@@storecounter}{\@cps@@counterlistname}%
}{%
}%
}
\newcommand{\@cps@@registercounter}[1]{%
\listcsxadd{\@cps@@counterlistname}{#1}%
\stepcounter{cps@@cpscounters}%
\listcsxadd{#1countlist}{}%
\DeclareCPSCounter{total#1}%
\DeclareCPSCounter{grandtotaltemp#1}%
\DeclareCPSCounter{grandtotal#1}%
\@cps@@generatewritefilehandle{#1}%
% This needs some work to do
\DeclareAssociatedCounters{#1}{cps@@cps@@total#1,cps@@cps@@grandtotaltemp#1}%
}
%% Searches the list of counter values for the tracklevel (#2)
\newcommand{\@cps@@searchcountervalue}[3]{%
\setcounter{cps@@tempcounterstorage}{-1}%
\ifnumequal{#1}{\value{#2}}{%
% Value found, store it temporarily
\setcounter{cps@@tempcounterstorage}{#3}%
\listbreak%
}{%
\stepcounter{#2}%
}%
}
\newcommand{\@cps@@auxsetcounter}[2]{%
\immediate\write\@auxout{%
\string\setcounter{#1}{\number\value{#2}}
}
}%
\newcommand{\@cps@@storegrandtotal}[1]{%
\@cps@@auxsetcounter{cps@@cps@@grandtotal#1}{cps@@cps@@grandtotaltemp#1}%
}
%%%%%%%%%%%%%% User commands %%%%%%%%%%%%%%%%%%%%
\newcommand{\RegisterCounter}[2][]{%
\begingroup
\setkeys{cpskeys}{#1}%
\ifltxcounter{#2}{%
\@cps@@registercounter{#2}%
}{%
\ifKV@cpskeys@autodefine
\newcounter{#2}%
\@cps@@registercounter{#2}%
\else%
% Ignore non existing counters
\GenericWarning{Counter #1 is not defined}{}%
\fi
}%
\endgroup
}
\newcommand{\RegisterCounters}[1]{%
\forcsvlist{\RegisterCounter}{#1}%
}
% Prevent usage later in document body
\@onlypreamble{\@registercounters}
\@onlypreamble{\RegisterCounter}
\@onlypreamble{\RegisterCounters}
\@onlypreamble{\PrepareToCCommands}
\newcommand{\ResetStoredCounter}[1]{%
\setcounter{cps@@cps@@total#1}{0}%
}
% Reset all total counters
\newcommand{\ResetStoredCounters}{%
\ifnumgreater{\value{\@cps@@cpscountersname}}{0}{%
\forlistcsloop{\ResetStoredCounter}{\@cps@@counterlistname}%
}{}%
}
%% Only for statistical purposes. Do not use it in a production run
\newcommand{\IndividualCounterStatistics}[2][\number\value{cps@@currentlevelcount}]{%
\ifcpsdraftmode
\GetStoredCounterValue[#1]{#2}%
\ifnumgreater{\value{cps@@tempcounterstorage}}{-1}{%
\noindent \@cps@@keymacro@@tracklevel\ #1~has \number\value{cps@@tempcounterstorage} #2(s)\par
}{}
\fi
}%
%% Only for statistical purposes. Do not use it in a production run
\newcommand{\ShowStatistics}[1][\number\value{cps@@currentlevelcount}]{%
\ifcpsdraftmode%
\ifnumgreater{\value{\@cps@@cpscountersname}}{0}{%
\forlistcsloop{\IndividualCounterStatistics[\number#1]}{\@cps@@counterlistname}%
}{%
\typeout{No counters registered}%
}%
\fi%
}
\newcommand{\fullstatistics}[1]{%
\hspace{1cm} \number\value{cps@@cps@@grandtotal#1}{} #1(s)%
}
\newcommand{\Fullstatistics}{%
This document has
\ifnumgreater{\value{\@cps@@cpscountersname}}{0}{%
\forlistcsloop{\fullstatistics}{\@cps@@counterlistname}%
}{%
\typeout{No counters registered}%
}%
}
\newcommand{\GetStoredCounterValue}[2][\number\value{cps@@currentlevelcount}]{%
\setcounter{cps@@tempcounter}{0}%
\ifnumgreater{#1}{\value{cps@@totaltracklevelcount}}{%
\def\cps@@trackleveltoshow{\value{cps@@totaltracklevelcount}}%
}{%
\def\cps@@trackleveltoshow{#1}%
}%
\ifcsdef{#2countlist}{%
\forlistcsloop{\@cps@@searchcountervalue{\cps@@trackleveltoshow}{cps@@tempcounter}}{#2countlist}%
}{%
\typeout{Warning: List for counter #2 not defined}%
}% Failure branch should be improved
}
\newcommand{\FetchStoredCounterValue}[2][\number\value{cps@@currentlevelcount}]{%
\GetStoredCounterValue[#1]{#2}%
\number\value{cps@@tempcounterstorage}%
}
\newcommand{\StartCounterToc}{%
\ifnumgreater{\value{\@cps@@cpscountersname}}{0}{%
\forlistcsloop{\@startcountertoc}{\@cps@@counterlistname}%
}{%
}%
}
\newcommand{\CloseCPSFiles}{%
\ifnumgreater{\value{\@cps@@cpscountersname}}{0}{%
\forlistcsloop{\@cps@@closeoutcpsfile}{\@cps@@counterlistname}%
}{%
}%
}
\newcommand{\StoreCounters}{%
\ifcpsstorage% Only store counters if \cpsstoragetrue
\@cps@@loopstorecounters%
\fi%
}
\newcommand{\StoreGrandTotalCounters}{%
\forlistcsloop{\@cps@@storegrandtotal}{\@cps@@counterlistname}%
}
\newcommand{\StopCounting}{%
\StoreCounters%
}
%% Informational macros -- very hackish so far
\newcommand{\CPSGetCounterList}{%
\csname\@cps@@counterlistname\endcsname%
}
\newcommand{\numberofstoredcounters}{%
\number\value{\@cps@@cpscountersname}%
}
\AtBeginDocument{%
\StartCounterToc%
}
\AtEndDocument{%
% Write the last counter values to the file
\StopCounting%
% Full counter values
\StoreGrandTotalCounters%
}
%% etoolbox - addition
\AfterEndDocument{%
\ifcpsnoendclose
% Prevent the explicit closing
\else
\CloseCPSFiles%
\fi
}
\endinput
这是用于获取特定章节中子章节数量的工作文档:
section
使用 first注册 first 中要跟踪的计数器,然后编译两次。可以使用 检索\RegisterCounters{subsection}
section 中子节的具体数量。n
\FetchStoredCounterValue[n]{subsection}
该\Fullstatistics
宏是为了方便概览。
\documentclass{article}
\usepackage{cntchap}
\RegisterCounters{subsection}
\begin{document}
There are \FetchStoredCounterValue[1]{subsection} in Section 1 and \FetchStoredCounterValue[2]{subsection} in Section 2
\Fullstatistics
\section{First section}
\subsection{My first subsection}
\subsection{other subsection}
\section{Second section}
\subsection{My first subsection}
\subsection{other subsection}
\subsection{My first subsection}
\subsection{other subsection}
\subsection{My first subsection}
\subsection{other subsection}
\subsection{My first subsection}
\subsection{other subsection}
\subsection{My first subsection}
\subsection{other subsection}
\subsection{My first subsection}
\subsection{other subsection}
\subsection{My first subsection}
\subsection{other subsection}
\subsection{My first subsection}
\subsection{other subsection}
\end{document}
cntperchap
我将在接下来的几周内提供新版本。
更新-- 使用新的临时版本cntchap
并制作补丁xassoccnt
\documentclass{book}
\usepackage{xassoccnt}
% Patch -- is in the development version
\makeatletter
\ExplSyntaxOn
\RenewDocumentCommand{\stepcounter}{m}{%
\__xassoccnt_translate_countername:cn {l_tmpa_tl} {#1}%
\xassoccnt_is_suspendedcounter:nF{#1}{%
\xassoccnt_is_coupledcounter:nTF {#1}
{ \xassoccnt_stepcounter_coupledcounters:n{#1} }
{% No, not a coupled counter!
\cs_gset_nopar:Nn \__xassoccnt_laststeppedcounter: {\l_tmpa_tl}%
\xassoccnt_countersinresetlist:n{\l_tmpa_tl}%
\__xassoccnt_getresetlist:n {\l_tmpa_tl}%
\seq_if_empty:NTF \l__xassoccnt_counterreset_seq
{%
\xassoccnt_standardaddtocounter{\l_tmpa_tl}{\c_one}% Use the original one!
\int_gset:Nn \g__xassoccnt_lastcountervalue_int {\number\value{\l_tmpa_tl}}%
\__xassoccnt_step_associatedcounters:n {\l_tmpa_tl}
}{ % reset list is not empty!
% This is the replacement of \csname cl@#1\endcsname
\xassoccnt_standardaddtocounter{\l_tmpa_tl}{\c_one}
\seq_map_inline:Nn \l__xassoccnt_counterreset_seq {%
\xassoccnt_is_drivercounter:nTF{##1}{%
\use:c{c@##1}\c_zero% Reset but do not increase
}{%
\use:c{c@##1}\c_minus_one
\xassoccnt_standardstepcounter{##1}%
}
}
\__xassoccnt_step_associatedcounters:n {\l_tmpa_tl} % step the remaining associated counters
}% End of not empty reset list
}% End of coupled counters
} % end of not suspended counter
}
\let\latex@@stepcounter\stepcounter
\seq_new:N \g_cntchap_registeredcounters_seq
\seq_new:N \g_cntchap_storedcounters_seq
\seq_new:N \g_cntchap_trackcounters_seq
\seq_gput_right:Nn \g_cntchap_trackcounters_seq {chapter}
\NewDocumentCommand{\RegisterCounters}{m}{%
\seq_set_from_clist:Nn \g_cntchap_registeredcounters_seq {#1}
\seq_map_inline:Nn \g_cntchap_registeredcounters_seq {
}
\seq_map_inline:Nn \g_cntchap_registeredcounters_seq {
\IfIsDocumentCounterF{cps@@total##1}{%
\NewDocumentCounter{cps@@total##1}%
\DeclareAssociatedCounters{##1}{cps@@total##1}% Define associated counters
}
}
}
\ior_new:N \g_trackfile_storage_read
\iow_new:N \g_trackfile_storage_write
\NewDocumentCommand{\StoreCounterValues}{m}{%
\tl_clear:N \l_tmpa_tl
\int_zero:N \l_tmpa_int
\tl_if_eq:nnT {#1} {chapter} {%
\ifnum\value{#1} > 0\relax % Replace later one with expl3 - version
\seq_map_inline:Nn \g_cntchap_registeredcounters_seq {%
\int_incr:N \l_tmpa_int
\int_compare:nNnTF {\l_tmpa_int } < {\seq_count:N \g_cntchap_registeredcounters_seq }
{ \tl_put_right:Nx \l_tmpa_tl { \number\value{cps@@total##1},} }{ \tl_put_right:Nx \l_tmpa_tl { \number\value{cps@@total##1} } }
\setcounter{cps@@total##1}{0}% Reset the total counter values
}
\iow_now:Nx \g_trackfile_storage_write {\l_tmpa_tl}%
\fi
}
}
% Redefine again, to provide the storage feature
\RenewDocumentCommand{\stepcounter}{m}{%
\StoreCounterValues{#1}%
\latex@@stepcounter{#1}%
}
\cs_new:Nn \l_cntchap_read_countervalues:n {%
\clist_set:Nx \l_tmpa_clist {#1}%
\clist_map_inline:Nn \l_tmpa_clist {%
\seq_gput_right:Nn \g_cntchap_storedcounters_seq {##1}
}
}
\AtBeginDocument{%
\IfFileExists{ \jobname.cpc }{%
\seq_gclear:N \g_cntchap_storedcounters_seq
\ior_open:Nn \g_trackfile_storage_read {\jobname.cpc}
\ior_map_inline:Nn \g_trackfile_storage_read { \l_cntchap_read_countervalues:n{##1} }
\ior_close:N \g_trackfile_storage_read
}{}
\iow_open:Nn \g_trackfile_storage_write {\jobname.cpc}
}
\newcommand{\closestoragefile}{%
\iow_close:N \g_trackfile_storage_write%
}
\cs_generate_variant:Nn \int_set:Nn {NV, Nx}
\int_new:N \l_currentchapter_int
\NewDocumentCommand{\FetchStoredCounterValue}{om}{%
\IfValueTF{#1}{%
\int_set:Nx \l_currentchapter_int {#1}
}{%
\int_set:Nx \l_currentchapter_int {\number\value{chapter}}
}
\seq_if_in:NnTF \g_cntchap_registeredcounters_seq {#2}
{
\int_zero:N \l_tmpa_int
\seq_map_inline:Nn \g_cntchap_registeredcounters_seq {%
\int_incr:N \l_tmpa_int
\tl_if_eq:nnT { ##1 } {#2 } {
\seq_map_break:
}
}
\int_set:NV \l_tmpb_int { \l_tmpa_int }
\int_set:Nx \l_tmpa_int { \seq_count:N \g_cntchap_registeredcounters_seq * (\l_currentchapter_int -1) + \l_tmpb_int }
\seq_item:Nn \g_cntchap_storedcounters_seq {\int_use:N \l_tmpa_int}
}{%
% Perhaps some error message here
}
}
\ExplSyntaxOff
\@onlypreamble\RegisterCounters
\makeatother
\AtEndDocument{%
\StoreCounterValues{chapter}%
\closestoragefile%
}
\RegisterCounters{section,subsection}
\begin{document}
\tableofcontents
\cleardoublepage
\markboth{}{}
\begingroup
\parindent=0em
Chapter 1 has \FetchStoredCounterValue[1]{section} sections and \FetchStoredCounterValue[1]{subsection} subsections
Chapter 2 has \FetchStoredCounterValue[2]{section} sections and \FetchStoredCounterValue[2]{subsection} subsections
\endgroup
\chapter{Foo}
This chapter has \FetchStoredCounterValue{section} sections and \FetchStoredCounterValue{subsection} subsections
\section{First section}
\subsection{My first subsection}
\subsection{other subsection}
\section{Second section}
\subsection{My first subsection}
\subsection{other subsection}
\section{Third section}
\subsection{other subsection}
\subsection{other subsection}
\subsection{other subsection}
\section{Fourth section}
\subsection{other subsection}
\subsection{other subsection}
\subsection{other subsection}
\chapter{Foo bar chapter}
This chapter has \FetchStoredCounterValue{section} sections and \FetchStoredCounterValue{subsection} subsections
\section{Foo}
\section{Second section}
\subsection{My first subsection}
\subsection{other subsection}
\subsection{My first subsection}
\subsection{other subsection}
\subsection{My first subsection}
\subsection{other subsection}
\subsection{My first subsection}
\subsection{other subsection}
\section{Third section}
\subsection{My first subsection}
\subsection{other subsection}
\subsection{My first subsection}
\subsection{other subsection}
\subsection{My first subsection}
\subsection{other subsection}
\subsection{My first subsection}
\subsection{other subsection}
\end{document}