自定义、连续编号的组

自定义、连续编号的组

我确信我不是第一个问这个问题的人。遗憾的是,我无法仅使用搜索功能找到答案(可能是我用错了词汇)。

故事:我想写一份报告。这份报告将分为三部分。该报告将包含 11 份项目描述。

由于我使用了\section组命令,因此该报告的结构示例如下:

\section{Intro}
project 1
project 2


\section{Main}
project 3
...
project 10

\section{Conclusion}
project 11

我的挑战: 我想使用一个名为的命令,\project它看起来和工作起来都像该\subsection命令,但对每个项目进行连续编号,即不考虑它所在的部分。

我想象的情况是这样的:

\section{Intro}
\project{How to put an egg into hot water}
\project{How to set a timer}


\section{Main}
\project{How to take an egg out of boiling water}
...
\project{How to open a boiled egg}

\section{Conclusion}
\project{How to eat a boiled egg}

答案1

这也可以通过加载chngcntr包并简单地发出

\counterwithout{subsection}{section}

平均能量损失

\documentclass{article}

\usepackage{chngcntr}

\counterwithout{subsection}{section}
\let\project\subsection

\begin{document}
\tableofcontents

\section{Intro}
\project{How to put an egg into hot water}
\project{How to set a timer}


\section{Main}
\project{How to take an egg out of boiling water}
...
\project{How to open a boiled egg}

\section{Conclusion}
\project{How to eat a boiled egg}
\end{document} 

输出

在此处输入图片描述

我还建议对“项目”进行格式化,以便在其后面出现“项目”一词。

这可以借助titlesectitletoc包并通过以下定义来完成:

\titlecontents{subsection}[3.8em]
{\hspace*{-2.3em}Project\ }
{\hspace*{2.3em}\contentslabel{2.3em}}
{}
{\titlerule*[.75pc]{.}\contentspage}

\titleformat{\subsection}{\normalfont\large\bfseries}{Project\ \thesubsection}{1em}{}
\titlespacing*{\subsection}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}

平均能量损失

\documentclass{article}

\usepackage{chngcntr}

\usepackage{titlesec,titletoc}

\titlecontents{subsection}[3.8em]
{\hspace*{-2.3em}Project\ }
{\hspace*{2.3em}\contentslabel{2.3em}}
{}
{\titlerule*[.75pc]{.}\contentspage}

\titleformat{\subsection}{\normalfont\large\bfseries}{Project\ \thesubsection}{1em}{}
\titlespacing*{\subsection}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}

\counterwithout{subsection}{section}
\let\project\subsection

\begin{document}
\tableofcontents

\section{Intro}
\project{How to put an egg into hot water}
\project{How to set a timer}


\section{Main}
\project{How to take an egg out of boiling water}
...
\project{How to open a boiled egg}

\section{Conclusion}
\project{How to eat a boiled egg}
\end{document} 

输出

在此处输入图片描述

答案2

remreset允许从父计数器的重置列表中删除计数器。\thesubsection然后可以重新定义为排除部分编号。然后\project就是\subsection

该示例还重新定义了\thesection各部分的不同编号方案。

\documentclass{article}

\usepackage{remreset}
\makeatletter
\@removefromreset{subsection}{section}
\makeatother
\renewcommand*{\thesubsection}{\arabic{subsection}}
\let\project\subsection
\renewcommand*{\thesection}{\Alph{section}}

\begin{document}
\tableofcontents

\section{Intro}
\project{How to put an egg into hot water}
\project{How to set a timer}


\section{Main}
\project{How to take an egg out of boiling water}
...
\project{How to open a boiled egg}

\section{Conclusion}
\project{How to eat a boiled egg}
\end{document}

结果

相关内容