macros.tex (7114B)
1 \pdfcompresslevel=0 2 3 \catcode`\@=11 4 \def\@listi{\leftmargin\leftmargini 5 \parsep=0pt 6 \topsep=0pt 7 \itemsep=0pt 8 \partopsep=0pt} 9 \let\@listI\@listi 10 %\@listi 11 \def\@listii {\leftmargin\leftmarginii 12 \labelwidth\leftmarginii 13 \advance\labelwidth-\labelsep} 14 \def\@listiii{\leftmargin\leftmarginiii 15 \labelwidth\leftmarginiii 16 \advance\labelwidth-\labelsep} 17 \def\@listiv {\leftmargin\leftmarginiv 18 \labelwidth\leftmarginiv 19 \advance\labelwidth-\labelsep} 20 \def\@listv {\leftmargin\leftmarginv 21 \labelwidth\leftmarginv 22 \advance\labelwidth-\labelsep} 23 \def\@listvi {\leftmargin\leftmarginvi 24 \labelwidth\leftmarginvi 25 \advance\labelwidth-\labelsep} 26 \catcode`\@=12 27 28 \baselineskip=0pt 29 \lineskiplimit=0pt 30 \lineskip=0pt 31 \parindent=0pt 32 \parskip=0pt 33 \topskip=0pt 34 \maxdepth=0pt 35 \pdfminorversion=7 36 \jot=4pt 37 38 % \pretolerance=-1 39 % \tolerance=9999 40 % \emergencystretch=8pt 41 \overfullrule=5mm 42 \showboxdepth=100 43 \showboxbreadth=1000 44 45 \def\capitalize#1#2{\uppercase{#1}#2} 46 \newbox\innerbox 47 \newbox\innerboxfirstline 48 \newbox\innerboxi 49 \newbox\partialpage 50 \newdimen\heightremaining 51 \newdimen\heightfirstline 52 \newdimen\innerwidth 53 54 \def\breakbox#1{% 55 \global\def\breakboxcolor{#1} 56 % TODO: Why do I need this? There is a problem when the page start with a breakbox. The whole line is not printed. 57 % \hbox{} 58 % First, save in \partialpage the content of the current page so far. 59 % \vbox{\unvbox255} is used instead of \box255 because the height of the 60 % \box255 is \textheight = \vsize (\pagegoal?) 61 \output{\global\setbox\partialpage=\vbox{\unvbox255}}\eject 62 \output{\myoutput}% 63 % compute the width of the innerbox 64 \innerwidth=\linewidth 65 \advance\innerwidth by-2\fboxsep 66 \advance\innerwidth by-2\fboxrule 67 % The innerbox is a vbox that will contain the content of the theorem 68 % It start a bgroup that will end at \endtheorem 69 \setbox\innerbox=\vbox\bgroup% 70 \hsize=\innerwidth 71 \linewidth=\innerwidth 72 % TODO: error when page breaking and the color was changed 73 } 74 75 \def\endbreakbox{% 76 % It close the innerbox that was started at \theoremii 77 \egroup 78 % Config for the vsplit's 79 \splitmaxdepth=0pt 80 \splittopskip=0pt 81 % Get the first line of the innerbox by splitting a copy 82 \setbox\innerboxfirstline=\copy\innerbox 83 \vfuzz=\maxdimen 84 \setbox\innerboxfirstline=\vsplit\innerboxfirstline to0pt 85 \vfuzz=1pt 86 \setbox\innerboxfirstline=\vbox{\hsize=\innerwidth\unvbox\innerboxfirstline}% 87 \heightfirstline=\ht\innerboxfirstline 88 \advance\heightfirstline by\dp\innerboxfirstline 89 % Compute the height remaining in the page 90 \heightremaining=\textheight 91 \advance\heightremaining by-\ht\partialpage 92 \advance\heightremaining by-\dp\partialpage 93 \advance\heightremaining by-2\fboxsep 94 \advance\heightremaining by-2\fboxrule 95 % Put the partial page back 96 \box\partialpage 97 % Check if the first line fits 98 \ifdim\heightremaining>\heightfirstline 99 % \message{First line fits} 100 % If the firstline fits, then check if the whole box fits 101 \ifdim\heightremaining<\ht\innerbox 102 % \message{The whole box does not fit} 103 % If The whole box does not fit, then split it 104 \vbadness=10000 105 \setbox\innerboxi=\vsplit\innerbox to\heightremaining 106 \vbadness=1000 107 % \vbox\unvbox\innerboxi instead of \box\innerboxi 108 \setbox\innerboxi=\vbox{\unvbox\innerboxi} 109 % Set the width of the innerbox so that the fcolorbox don't overfull 110 \wd\innerboxi=\innerwidth 111 \par\noindent\fcolorbox{\breakboxcolor}{\breakboxcolor!5}{\box\innerboxi}% 112 \eject 113 \else 114 % \message{The whole box fits} 115 \fi 116 \else 117 % If the firstline does not fit then eject to finish the current column 118 % \message{First line does not fit} 119 \eject 120 \fi 121 % If the innerbox is void after the splitting, then print it 122 \ifvoid\innerbox\else 123 % \message{The innerbox is not void} 124 % Set the width of the innerbox so that the fcolorbox don't overflow 125 \wd\innerbox=\innerwidth 126 \smallskip 127 \par\noindent\fcolorbox{\breakboxcolor}{\breakboxcolor!5}{\box\innerbox}\par 128 \smallskip 129 \fi 130 \par 131 \let\breakboxcolor=\relax 132 } 133 134 \newcount\thmnum 135 \thmnum=0 136 \def\newthm#1#2#3{ 137 % \theorem 138 \expandafter\def\csname #3\endcsname{% 139 \global\advance\thmnum by1 140 % \message{\number\thmnum}% 141 \def\tmp{\futurelet\next}% 142 \expandafter\tmp\csname #3i\endcsname 143 } 144 145 % \theoremi 146 \expandafter\def\csname #3i\endcsname{% 147 \let\thmname=\relax 148 \def\tmpi[####1]{\def\thmname{####1}\csname #3ii\endcsname}% 149 \ifx\next[ 150 \expandafter\tmpi 151 \else 152 \csname #3ii\endcsname 153 \fi 154 } 155 156 % \theoremii 157 \expandafter\def\csname #3ii\endcsname{% 158 \breakbox{#1} 159 {\bf \capitalize#3 \number\thmnum.}~\ifx\thmname\relax\else(\thmname)\fi% 160 } 161 162 % \endtheorem 163 \expandafter\def\csname end#3\endcsname{% 164 \endbreakbox 165 } 166 } 167 168 169 \edef\twocolumn{\detokenize{twocolumn}} 170 \edef\fourcolumn{\detokenize{fourcolumn}} 171 \edef\xjobname{\jobname} 172 173 \newcount\numcol 174 \ifx\xjobname\twocolumn 175 \AtBeginDocument{ 176 \pdfpageheight=297mm 177 \pdfpagewidth=210mm 178 } 179 \numcol=2 180 \else\ifx\xjobname\fourcolumn 181 \numcol=4 182 \AtBeginDocument{ 183 \pdfpageheight=297mm 184 \pdfpagewidth=420mm 185 \mag=707 186 } 187 \else 188 \numcol=1 189 \ifx\documentclass\undefined 190 \pdfpageheight=288mm 191 \pdfpagewidth=100mm 192 \else 193 \AtBeginDocument{ 194 \pdfpageheight=290mm 195 \pdfpagewidth=100mm 196 } 197 \fi 198 \fi\fi 199 200 \hoffset=-1in 201 \voffset=-1in 202 203 204 \countdef\pageno=0 \pageno=1 205 \newcount\curcol 206 \newcount\colbox 207 \newcount\firstbox 208 \firstbox=100 209 \curcol=0 210 \def\myoutput{% 211 \global\advance\curcol by1 212 {% 213 \advance\curcol by\firstbox 214 \global\setbox\curcol=\box255 215 \global\wd\curcol=\textwidth 216 }% 217 \ifnum\curcol=\numcol 218 \global\curcol=4 219 \shipout\vbox to \pdfpageheight {% 220 \vfil 221 \hbox to \pdfpagewidth {% 222 \colbox=0 223 \hfil 224 \loop 225 \ifnum\colbox<\numcol 226 \advance\colbox by1 227 {% 228 \hfil 229 \advance\colbox by\firstbox 230 \box\colbox 231 }% 232 \repeat 233 \hfil\hfil 234 }% 235 \vfil 236 }% 237 \global\advance\pageno by1 238 \global\curcol=0 239 \fi 240 } 241 242 \def\xthm#1#2#3,{ 243 \if\relax\detokenize{#3}\relax\else 244 \newthm{#1}{#2}{#3} 245 \def\tmpxthm{\xthm{#1}{#2}} 246 \expandafter\tmpxthm 247 \fi 248 } 249 250 \ifx\documentclass\undefined\else 251 \fboxsep=2mm 252 \fboxrule=1.5pt 253 \usepackage{xcolor} 254 \definecolor{red}{RGB}{247,87,130} 255 \definecolor{green}{RGB}{86,162,43} 256 \definecolor{blue}{RGB}{126,134,244} 257 \definecolor{bts}{RGB}{244,58,232} 258 \definecolor{orange}{RGB}{235,106,44} 259 \definecolor{gray}{RGB}{145,145,145} 260 \xthm{green}{green}theorem,lemma,corollary,proposition,, 261 \xthm{orange}{orange}definition,, 262 \xthm{blue}{blue}question,remark,note,notation,claim,summary,acknowledgment,case,conclusion,observation,recall,affirmation,, 263 \xthm{bts}{bts}example,application,problem,, 264 \xthm{red}{red}exercise,, 265 \xthm{gray}{gray}proof,solution,, 266 267 \textheight=287mm 268 \textwidth=97.5mm 269 270 \AtBeginDocument{ 271 \baselineskip=12pt 272 \abovedisplayskip=1pt 273 \belowdisplayskip=1pt 274 \abovedisplayshortskip=2pt 275 \belowdisplayshortskip=2pt 276 \output{\myoutput}% 277 \overfullrule=5mm 278 } 279 \fi 280 281 \def\coloneqq{\mathrel{\mathop:}=} 282 \def\mathclap#1{\hbox to 0pt{\hss$#1$\hss}} 283 \def\mathllap{}