| 1 | % http://www.tex.ac.uk/cgi-bin/texfaq2html?label=subverttoks |
|---|
| 2 | \let\mypkg@@everypar\everypar |
|---|
| 3 | \newtoks\mypkg@everypar |
|---|
| 4 | \mypkg@everypar\expandafter{\the\everypar} |
|---|
| 5 | %\mypkg@@everypar{\mypkgs@ownstuff\the\mypkg@everypar} |
|---|
| 6 | \mypkg@@everypar{\ifdonumberparagraphs\mypkgs@ownstuff\fi\the\mypkg@everypar} |
|---|
| 7 | |
|---|
| 8 | \newif\ifdonumberparagraphs |
|---|
| 9 | %\newif\ifsavenumberparagraphs |
|---|
| 10 | \donumberparagraphsfalse |
|---|
| 11 | \newcommand{\numberparagraphs}{\global\donumberparagraphstrue} |
|---|
| 12 | \newcommand{\nonumberparagraphs}{\global\donumberparagraphsfalse} |
|---|
| 13 | |
|---|
| 14 | \newcounter{parcounter}[chapter] |
|---|
| 15 | \newcommand\thepara{\thechapter.\@arabic\c@parcounter} |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | |
|---|
| 19 | \def\mypkgs@ownstuff{% |
|---|
| 20 | %\ifdonumberparagraphs\marginpar{hello}\fi% |
|---|
| 21 | \donumberparagraphsfalse% |
|---|
| 22 | \refstepcounter{parcounter}% |
|---|
| 23 | \marginpar{hello \thepara}% |
|---|
| 24 | \donumberparagraphstrue% |
|---|
| 25 | } |
|---|
| 26 | |
|---|
| 27 | \let\everypar\mypkg@everypar |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | % don't do it for \section... |
|---|
| 31 | %\let\mypkg@@section\section |
|---|
| 32 | %\newtoks\mypkg@section |
|---|
| 33 | %\mypkg@section\expandafter{\the\section} |
|---|
| 34 | %\mypkg@@section{\ifdonumberparagraphs\donumberparagraphsfalse\the\mypkg@section\donumberparagraphstrue\else\the\mypkg@section\fi} |
|---|
| 35 | %\let\section\mypkg@section |
|---|
| 36 | |
|---|
| 37 | %\newcommand{\oldsection}[1]{\section{#1}} |
|---|
| 38 | %\renewcommand{\section}{\nonumberparagraphs\oldsection\numberparagraphs} |
|---|
| 39 | |
|---|
| 40 | %\let\mypkg@@section\section |
|---|
| 41 | %\renewcommand{\section}[1]{\ifdonumberparagraphs% |
|---|
| 42 | % \nonumberparagraphs% |
|---|
| 43 | % \mypkg@@section{#1}% |
|---|
| 44 | % \numberparagraphs% |
|---|
| 45 | % \else% |
|---|
| 46 | % \mypkg@@section{#1}% |
|---|
| 47 | % \fi} |
|---|
| 48 | |
|---|
| 49 | %\renewcommand{\section}[1]{\ifdonumberparagraphs% |
|---|
| 50 | % \nonumberparagraphs% |
|---|
| 51 | % \@ifstar\mypkg@@section*{#1}\mypkg@@section{#1}% |
|---|
| 52 | % \numberparagraphs% |
|---|
| 53 | % \else% |
|---|
| 54 | % \@ifstar\mypkg@@section*{#1}\mypkg@@section{#1}% |
|---|
| 55 | % \fi} |
|---|
| 56 | |
|---|
| 57 | \usepackage{ifthen} |
|---|
| 58 | |
|---|
| 59 | \let\mypkg@@section\section |
|---|
| 60 | |
|---|
| 61 | \renewcommand{\section}[2]{\ifthenelse{\equal{#1}{*}}% |
|---|
| 62 | {\mysectionstar{*}{#2}}% |
|---|
| 63 | {\mysection{#1}}% |
|---|
| 64 | } |
|---|
| 65 | |
|---|
| 66 | \newcommand{\mysectionstar}[2]{% |
|---|
| 67 | \ifdonumberparagraphs% |
|---|
| 68 | \nonumberparagraphs% |
|---|
| 69 | \mypkg@@section*{#2}% |
|---|
| 70 | \numberparagraphs% |
|---|
| 71 | \else% |
|---|
| 72 | \mypkg@@section*{#2}% |
|---|
| 73 | \fi} |
|---|
| 74 | |
|---|
| 75 | \newcommand{\mysection}[1]{% |
|---|
| 76 | \ifdonumberparagraphs% |
|---|
| 77 | \nonumberparagraphs% |
|---|
| 78 | \mypkg@@section{#1}% |
|---|
| 79 | \numberparagraphs% |
|---|
| 80 | \else% |
|---|
| 81 | \mypkg@@section{#1}% |
|---|
| 82 | \fi} |
|---|
| 83 | |
|---|
| 84 | |
|---|
| 85 | |
|---|
| 86 | |
|---|
| 87 | \let\mypkg@@chapter\chapter |
|---|
| 88 | \renewcommand{\chapter}[1]{\ifdonumberparagraphs% |
|---|
| 89 | \nonumberparagraphs% |
|---|
| 90 | \mypkg@@chapter{#1}% |
|---|
| 91 | \numberparagraphs% |
|---|
| 92 | \else% |
|---|
| 93 | \mypkg@@chapter{#1}% |
|---|
| 94 | \fi} |
|---|