
標準のブック クラスを使用して短いレポートを作成しています。レポートでは、約 10 の実験について説明します。 というセクション コマンドを定義したいと思いますexperiment
。このセクション コマンドは、標準のセクション コマンドと非常によく似ている必要があります。可能であれば、新しいページを発行し、コンテンツで実験を章の最後に表示する必要があることだけを希望します。
Chapter 1 Introduction 12
section 2 .....
section 3 .....
experiment 1.2 ....
experiment 1.3 ....
experiment 1.4 ....
答え1
環境を使用した1つの解決策は次のとおりですexperiment
。環境はフォームのタイトルを配置します。実験 #標準セクションと同様のスタイルで、新しい章ごとにリセットされるカウンターを使用します。環境は ToC のエントリも生成します。ただし、エントリは環境が使用された場所に表示されます (そうでない場合、Unapiedra がコメントで述べたように、ToC の順序がおかしくなります)。エントリを章のエントリの最後に表示したい場合は、まさにその場所で環境を使用する必要があります。
\documentclass{book}
\usepackage{lipsum}% just to generate text for the example
\newcounter{exp}
\renewcommand\theexp{\thechapter.\arabic{exp}}
\newcommand\experimentname{Experiment}
\makeatletter
\@addtoreset{exp}{chapter}
\makeatother
\newenvironment{experiment}
{\clearpage
%\phantomsection % un-comment if hyperref is to be used
\stepcounter{exp}
\addcontentsline{toc}{section}{\experimentname~\theexp}
\noindent{\Large\bfseries\experimentname~\theexp}%
\par\vspace*{2.3ex plus .2ex}\noindent\ignorespaces}
{\clearpage}
\begin{document}
\tableofcontents
\chapter{Test Chapter}
\section{Test Section One One}
\lipsum[1]
\begin{experiment}
\lipsum*[1]
\end{experiment}
\section{Test Section One Two}
\lipsum[1]
\begin{experiment}
\lipsum*[1]
\end{experiment}
\end{document}
もう一つの選択肢は、新しい実験リスト標準の「...のリスト」に似ています。これを行う方法は次のとおりです。
\documentclass{book}
\usepackage{lipsum}
\newcounter{exp}
\renewcommand\theexp{\thechapter.\arabic{exp}}
\newcommand\experimentname{Experiment}
\newcommand\listexperimentname{List of Experiments}
\makeatletter
\@addtoreset{exp}{chapter}
\newcommand\listofexperiments{\chapter*{\listexperimentname}\@starttoc{exp}}
\makeatother
\newenvironment{experiment}
{\clearpage
%\phantomsection % un-comment if hyperref is to be used
\stepcounter{exp}
\addcontentsline{exp}{section}{\experimentname~\theexp}
\noindent{\Large\bfseries\experimentname~\theexp}%
\par\vspace*{2.3ex plus .2ex}\noindent\ignorespaces}
{\clearpage}
\begin{document}
\tableofcontents
\listofexperiments
\chapter{Test Chapter}
\section{Test Section One One}
\lipsum[1]
\begin{experiment}
\lipsum*[1]
\end{experiment}
\section{Test Section One Two}
\lipsum[1]
\begin{experiment}
\lipsum*[1]
\end{experiment}
\end{document}