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