Sunday 24 June 2012

LaTeX- still counting

とりあえずカウンタの勉強も兼ねて.
前言ってた,「命題13」「定義14」みたいな感じで連番を振りたいときようの .sty .

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%24th June 2012. Mutsuteru @exumbra_insolem on twitter,
%all rights reserved.
%distributed under LGPL license.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%definition of \mtheo. the counter is theoremMutsu, and
%this counter is independent.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcounter{theoremMutsu}
\renewcommand{\thetheoremMutsu}{\arabic{theoremMutsu}.}
\newcommand{\mtheo}[1]{\paragraph{{#1} \thetheoremMutsu}\stepcounter{theoremMutsu}}
%\newcommand{\mtheo}[1]{\stepcounter{theoremMutsu}\paragraph{{#1} \thetheoremMutsu.}
% DOES NOT work. it yealds, when the counter theoremMutsu is first set to 0,'' 2,3,4,..., n,n''.
\setcounter{theoremMutsu}{0}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%next definition of \dtheo, this counter is dependent on section.
%thus the numbering is reset in each new section.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcounter{dtheoremMutsu}[section]
\renewcommand{\thedtheoremMutsu}{\arabic{section}.\arabic{dtheoremMutsu}.}
\newcommand{\dtheo}[1]{\paragraph{{#1} \thedtheoremMutsu}\stepcounter{dtheoremMutsu}}
\setcounter{dtheoremMutsu}{0}
 \newcounter{a}[b] で b のこどものカウンタ a を作れる.


\mtheo{definition} で 「definition 1. 」
次例えば \mtheo{proposition} で「proposition 2.」
以降 3., 4. ... とカウントしていきます.
\dtheo{} の方は section 番号と倶に 「proposition 1.1.」 みたいな.
これは section が変わるとまた1からのカウントになります.
\mtheo, \dtheo ともに paragraph を作る設定にしてあります.つまり
\paragraph{definition 13.} とかやってたのの,カウントを自動でしてくれるのがこちら.

LGPL で配布しますがご利用の際は ひとこえかけていただけると喜びます.
数式のカウントとも連動するようにできたりしたら良いかもしれない.
\theequation を書き換えるとかして.


vim ほんま捗るわぁ.まだ文字化け治ってないから日本語打てへんけど.

No comments:

Post a Comment