| 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 | %\renewcommand{\section}[2]{\ifthenelse{\equal{#1}{*}}% |
|---|
| 60 | % {\mysectionstar{#2}}% |
|---|
| 61 | % {\mysection{#1}}% |
|---|
| 62 | %} |
|---|
| 63 | |
|---|
| 64 | \renewenvironment{figure}{% |
|---|
| 65 | \nonumberparagraphs% |
|---|
| 66 | \@float{figure}}{% |
|---|
| 67 | \numberparagraphs% |
|---|
| 68 | \end@float} |
|---|
| 69 | |
|---|
| 70 | |
|---|
| 71 | %%% section |
|---|
| 72 | |
|---|
| 73 | \let\mypkg@@section\section |
|---|
| 74 | |
|---|
| 75 | \renewcommand{\section}{\@ifstar |
|---|
| 76 | \mysectionstar% |
|---|
| 77 | \mysection% |
|---|
| 78 | } |
|---|
| 79 | |
|---|
| 80 | \newcommand{\mysectionstar}[1]{% |
|---|
| 81 | \ifdonumberparagraphs% |
|---|
| 82 | \nonumberparagraphs% |
|---|
| 83 | \mypkg@@section*{#1}% |
|---|
| 84 | \numberparagraphs% |
|---|
| 85 | \else% |
|---|
| 86 | \mypkg@@section*{#1}% |
|---|
| 87 | \fi} |
|---|
| 88 | |
|---|
| 89 | \newcommand{\mysection}[1]{% |
|---|
| 90 | \ifdonumberparagraphs% |
|---|
| 91 | \nonumberparagraphs% |
|---|
| 92 | \mypkg@@section{#1}% |
|---|
| 93 | \numberparagraphs% |
|---|
| 94 | \else% |
|---|
| 95 | \mypkg@@section{#1}% |
|---|
| 96 | \fi} |
|---|
| 97 | |
|---|
| 98 | %%% subsection |
|---|
| 99 | |
|---|
| 100 | \let\mypkg@@subsection\subsection |
|---|
| 101 | |
|---|
| 102 | \renewcommand{\subsection}{\@ifstar |
|---|
| 103 | \mysubsectionstar% |
|---|
| 104 | \mysubsection% |
|---|
| 105 | } |
|---|
| 106 | |
|---|
| 107 | \newcommand{\mysubsectionstar}[1]{% |
|---|
| 108 | \ifdonumberparagraphs% |
|---|
| 109 | \nonumberparagraphs% |
|---|
| 110 | \mypkg@@subsection*{#1}% |
|---|
| 111 | \numberparagraphs% |
|---|
| 112 | \else% |
|---|
| 113 | \mypkg@@subsection*{#1}% |
|---|
| 114 | \fi} |
|---|
| 115 | |
|---|
| 116 | \newcommand{\mysubsection}[1]{% |
|---|
| 117 | \ifdonumberparagraphs% |
|---|
| 118 | \nonumberparagraphs% |
|---|
| 119 | \mypkg@@subsection{#1}% |
|---|
| 120 | \numberparagraphs% |
|---|
| 121 | \else% |
|---|
| 122 | \mypkg@@subsection{#1}% |
|---|
| 123 | \fi} |
|---|
| 124 | |
|---|
| 125 | |
|---|
| 126 | |
|---|
| 127 | %%% chapter, chapter* |
|---|
| 128 | |
|---|
| 129 | \let\mypkg@@chapter\chapter |
|---|
| 130 | |
|---|
| 131 | %\renewcommand{\chapter}[2]{\ifthenelse{\equal{#1}{*}}% |
|---|
| 132 | % {\mychapterstar{#2}}% |
|---|
| 133 | % {\mychapter{#1}}% |
|---|
| 134 | %} |
|---|
| 135 | |
|---|
| 136 | %\renewcommand\chapter{\@dblarg\@mychapter} |
|---|
| 137 | %\newcommand\@mychapter{% |
|---|
| 138 | % \@ifstar% |
|---|
| 139 | % \mychapterstar% |
|---|
| 140 | % \mychapter% |
|---|
| 141 | %} |
|---|
| 142 | |
|---|
| 143 | \renewcommand{\chapter}{\@ifstar |
|---|
| 144 | \@dblarg\@mychapterstar% |
|---|
| 145 | \@dblarg\@mychapternostar% |
|---|
| 146 | } |
|---|
| 147 | |
|---|
| 148 | %\def\@ifstar#1{\@ifnextchar *{\@firstoftwo{#1}}} |
|---|
| 149 | |
|---|
| 150 | %\long\def\@dblarg#1{\kernel@ifnextchar[{#1}{\@xdblarg{#1}}} |
|---|
| 151 | %\long\def\@xdblarg#1#2{#1[{#2}]{#2}} |
|---|
| 152 | |
|---|
| 153 | |
|---|
| 154 | %\renewcommand{\chapter}{\@dblarg\@mychapterx} |
|---|
| 155 | %\newcommand{\@mychapterx}{\@ifstar |
|---|
| 156 | % \mychapterstar% |
|---|
| 157 | % \@mychapter% |
|---|
| 158 | %} |
|---|
| 159 | |
|---|
| 160 | |
|---|
| 161 | \comment{ |
|---|
| 162 | \newcommand{\mychapterstar}[1]{% |
|---|
| 163 | \ifdonumberparagraphs% |
|---|
| 164 | \nonumberparagraphs% |
|---|
| 165 | \mypkg@@chapter*{#1}% |
|---|
| 166 | \numberparagraphs% |
|---|
| 167 | \else% |
|---|
| 168 | \mypkg@@chapter*{#1}% |
|---|
| 169 | \fi} |
|---|
| 170 | |
|---|
| 171 | \newcommand{\mychapter}[1]{% |
|---|
| 172 | \ifdonumberparagraphs% |
|---|
| 173 | \nonumberparagraphs% |
|---|
| 174 | \mypkg@@chapter{#1}% |
|---|
| 175 | \numberparagraphs% |
|---|
| 176 | \else% |
|---|
| 177 | \mypkg@@chapter{#1}% |
|---|
| 178 | \fi} |
|---|
| 179 | } |
|---|
| 180 | |
|---|
| 181 | \def\@mychapterstar[#1]#2{% |
|---|
| 182 | \ifdonumberparagraphs% |
|---|
| 183 | \nonumberparagraphs% |
|---|
| 184 | \mypkg@@chapter*[#1]{#2}% |
|---|
| 185 | \numberparagraphs% |
|---|
| 186 | \else% |
|---|
| 187 | \mypkg@@chapter*[#1]{#2}% |
|---|
| 188 | \fi} |
|---|
| 189 | |
|---|
| 190 | \def\@mychapternostar[#1]#2{% |
|---|
| 191 | \ifdonumberparagraphs% |
|---|
| 192 | \nonumberparagraphs% |
|---|
| 193 | \mypkg@@chapter[#1]{#2}% |
|---|
| 194 | \numberparagraphs% |
|---|
| 195 | \else% |
|---|
| 196 | \mypkg@@chapter[#1]{#2}% |
|---|
| 197 | \fi} |
|---|