
パッケージはどのように機能しますか?コード内で明示的にtitlesec
呼び出したことはありません。しかし、中間で呼び出されているようです。\sectionbreak
\sectionbreak
\section
\documentclass[fleqn]{report}
\usepackage{titlesec}
\newcommand{\sectionbreak}{\clearpage \setcounter{equation}{0}}
\begin{document}
\section{One}
\begin{equation} 2+2=3.99 \end{equation}
\begin{equation} \pi^2=9.86 \end{equation}
\section{Two}
\begin{equation} E=mc^2 \end{equation}
\begin{equation} v=\frac{e}{t} \end{equation}
\subsection{Two \& One}
\begin{equation} 2+2=22 \end{equation}
\end{document}
答え1
8ページによると、タイトル手動では、\sectionbreak
各セクション コマンドの後に適用されます。 のパッケージ コードを調べるとtitlesec.sty
、次の 2 つのインスタンスが見つかります。
\@ifundefined{#6break}%
{\addpenalty{\@secpenalty}}%
{\csname#6break\endcsname}%
ここで、 は#6
セクション コマンドの名前なので、 、 、 のいずれかになりますsection
。subsection
がsubsubsection
である特殊なケースでは、上記のコードは次のように解釈されますparagraph
。subparagraph
#6
section
sectionbreak
定義されていない場合は\@secpenalty
ペナルティを追加し、定義されている場合は追加します\sectionbreak
ファイルをコンパイルするときにこれが起こっていることを確認したい場合は、たとえば、コマンド\typeout{Adding a section break!!!}
の定義に追加し\sectionbreak
(以下を参照)、ログ ファイルを確認します。ターミナルでファイルをコンパイルし、出力を確認します。
\documentclass[fleqn]{report}
\usepackage{titlesec}
\newcommand{\sectionbreak}{\clearpage \setcounter{equation}{0}\typeout{Adding a section break!!!}}
\begin{document}
\section{One}
\begin{equation} 2+2=3.99 \end{equation}
\begin{equation} \pi^2=9.86 \end{equation}
\section{Two}
\begin{equation} E=mc^2 \end{equation}
\begin{equation} v=\frac{e}{t} \end{equation}
\subsection{Two \& One}
\begin{equation} 2+2=22 \end{equation}
\end{document}