Articles I've written for customers on IT issues.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

495 lines
15 KiB

4 years ago
  1. %%
  2. %% This is file `jmlrutils.sty',
  3. %% generated with the docstrip utility.
  4. %%
  5. %% The original source files were:
  6. %%
  7. %% jmlr.dtx (with options: `jmlrutils.sty,package')
  8. %%
  9. %% jmlr.dtx
  10. %% Copyright 2017 Nicola Talbot
  11. %%
  12. %% This work may be distributed and/or modified under the
  13. %% conditions of the LaTeX Project Public License, either version 1.3
  14. %% of this license or (at your option) any later version.
  15. %% The latest version of this license is in
  16. %% http://www.latex-project.org/lppl.txt
  17. %% and version 1.3 or later is part of all distributions of LaTeX
  18. %% version 2005/12/01 or later.
  19. %%
  20. %% This work has the LPPL maintenance status `maintained'.
  21. %%
  22. %% The Current Maintainer of this work is Nicola Talbot.
  23. %%
  24. %% This work consists of the files jmlr.dtx and jmlr.ins and the derived files jmlrutils.sty, jmlr.cls, jmlrbook.cls.
  25. %%
  26. %% \CharacterTable
  27. %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
  28. %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
  29. %% Digits \0\1\2\3\4\5\6\7\8\9
  30. %% Exclamation \! Double quote \" Hash (number) \#
  31. %% Dollar \$ Percent \% Ampersand \&
  32. %% Acute accent \' Left paren \( Right paren \)
  33. %% Asterisk \* Plus \+ Comma \,
  34. %% Minus \- Point \. Solidus \/
  35. %% Colon \: Semicolon \; Less than \<
  36. %% Equals \= Greater than \> Question mark \?
  37. %% Commercial at \@ Left bracket \[ Backslash \\
  38. %% Right bracket \] Circumflex \^ Underscore \_
  39. %% Grave accent \` Left brace \{ Vertical bar \|
  40. %% Right brace \} Tilde \~}
  41. %% First editor:
  42. %% Second editor:
  43. \ProvidesPackage{jmlrutils}[2017/08/01]
  44. \newif\ifjmlrutilsmaths
  45. \jmlrutilsmathstrue
  46. \DeclareOption{maths}{\jmlrutilsmathstrue}
  47. \DeclareOption{nomaths}{\jmlrutilsmathsfalse}
  48. \newif\ifjmlrutilstheorems
  49. \jmlrutilstheoremstrue
  50. \DeclareOption{theorems}{\jmlrutilstheoremstrue}
  51. \DeclareOption{notheorems}{\jmlrutilstheoremsfalse}
  52. \newif\ifjmlrutilssubfloats
  53. \jmlrutilssubfloatstrue
  54. \DeclareOption{subfloats}{\jmlrutilssubfloatstrue}
  55. \DeclareOption{nosubfloats}{\jmlrutilssubfloatsfalse}
  56. \ProcessOptions
  57. \RequirePackage{etoolbox}
  58. \ifjmlrutilsmaths
  59. \RequirePackage{amsmath}
  60. \fi
  61. \@ifundefined{iftablecaptiontop}
  62. {\newif\iftablecaptiontop
  63. \tablecaptiontoptrue}
  64. {}
  65. \newcommand*{\@jmlr@reflistsep}{, }
  66. \newcommand*{\@jmlr@reflistlastsep}{ and }
  67. \newcommand*{\sectionrefname}{Section}
  68. \newcommand*{\sectionsrefname}{Sections}
  69. \newcommand*{\equationrefname}{Equation}
  70. \newcommand*{\equationsrefname}{Equations}
  71. \newcommand*{\tablerefname}{Table}
  72. \newcommand*{\tablesrefname}{Tables}
  73. \newcommand*{\figurerefname}{Figure}
  74. \newcommand*{\figuresrefname}{Figures}
  75. \newcommand*{\algorithmrefname}{Algorithm}
  76. \newcommand*{\algorithmsrefname}{Algorithms}
  77. \newcommand*{\theoremrefname}{Theorem}
  78. \newcommand*{\theoremsrefname}{Theorems}
  79. \newcommand*{\lemmarefname}{Lemma}
  80. \newcommand*{\lemmasrefname}{Lemmas}
  81. \newcommand*{\remarkrefname}{Remark}
  82. \newcommand*{\remarksrefname}{Remarks}
  83. \newcommand*{\corollaryrefname}{Corollary}
  84. \newcommand*{\corollarysrefname}{Corollaries}
  85. \newcommand*{\definitionrefname}{Definition}
  86. \newcommand*{\definitionsrefname}{Definitions}
  87. \newcommand*{\conjecturerefname}{Conjecture}
  88. \newcommand*{\conjecturesrefname}{Conjectures}
  89. \newcommand*{\axiomrefname}{Axiom}
  90. \newcommand*{\axiomsrefname}{Axioms}
  91. \newcommand*{\examplerefname}{Example}
  92. \newcommand*{\examplesrefname}{Examples}
  93. \newcommand*{\appendixrefname}{Appendix}
  94. \newcommand*{\appendixsrefname}{Appendices}
  95. \newcommand*{\partrefname}{Part}
  96. \newcommand*{\partsrefname}{Parts}
  97. \newrobustcmd*{\objectref}[5]{%
  98. \let\@objectname\@empty
  99. \def\@objectref{}%
  100. \let\@prevsep\@empty
  101. \@for\@thislabel:=#1\do{%
  102. \toks@{\@prevsep}%
  103. \protected@edef\@objectref{\@objectref\the\toks@
  104. #4\ref{\@thislabel}#5}%
  105. \ifx\@objectname\@empty
  106. \let\@objectname#2% singular tag
  107. \else
  108. \let\@objectname#3% plural tag
  109. \let\@prevsep\@jmlr@reflistsep
  110. \fi
  111. }%
  112. \ifx\@objectname#3% plural tag
  113. \let\@prevsep\@jmlr@reflistlastsep
  114. \fi
  115. \@objectname~\@objectref
  116. }
  117. \newcommand*{\sectionref}[1]{%
  118. \objectref{#1}{\sectionrefname}{\sectionsrefname}{}{}}
  119. \newcommand*{\equationref}[1]{%
  120. \objectref{#1}{\equationrefname}{\equationsrefname}()}
  121. \newcommand*{\tableref}[1]{%
  122. \objectref{#1}{\tablerefname}{\tablesrefname}{}{}}
  123. \newcommand*{\figureref}[1]{%
  124. \objectref{#1}{\figurerefname}{\figuresrefname}{}{}}
  125. \newcommand*{\algorithmref}[1]{%
  126. \objectref{#1}{\algorithmrefname}{\algorithmsrefname}{}{}}
  127. \newcommand*{\theoremref}[1]{%
  128. \objectref{#1}{\theoremrefname}{\theoremsrefname}{}{}}
  129. \newcommand*{\lemmaref}[1]{%
  130. \objectref{#1}{\lemmarefname}{\lemmasrefname}{}{}}
  131. \newcommand*{\remarkref}[1]{%
  132. \objectref{#1}{\remarkrefname}{\remarksrefname}{}{}}
  133. \newcommand*{\corollaryref}[1]{%
  134. \objectref{#1}{\corollaryrefname}{\corollarysrefname}{}{}}
  135. \newcommand*{\definitionref}[1]{%
  136. \objectref{#1}{\definitionrefname}{\definitionsrefname}{}{}}
  137. \newcommand*{\conjectureref}[1]{%
  138. \objectref{#1}{\conjecturerefname}{\conjecturesrefname}{}{}}
  139. \newcommand*{\axiomref}[1]{%
  140. \objectref{#1}{\axiomrefname}{\axiomsrefname}{}{}}
  141. \newcommand*{\exampleref}[1]{%
  142. \objectref{#1}{\examplerefname}{\examplesrefname}{}{}}
  143. \newcommand*{\appendixref}[1]{%
  144. \objectref{#1}{\appendixrefname}{\appendixsrefname}{}{}}
  145. \newcommand*{\partref}[1]{%
  146. \objectref{#1}{\partrefname}{\partsrefname}{}{}}
  147. \newcommand{\floatconts}[3]{%
  148. \@ifundefined{\@captype conts}{\tableconts{#1}{#2}{#3}}%
  149. {\csname\@captype conts\endcsname{#1}{#2}{#3}}%
  150. }
  151. \providecommand{\tableconts}[3]{%
  152. #2\label{#1}\vskip\baselineskip
  153. {\centering #3\par}%
  154. }
  155. \newcommand{\figureconts}[3]{%
  156. {\centering #3\par}%
  157. \vskip\baselineskip
  158. #2\label{#1}%
  159. }
  160. \newcommand{\algocfconts}[3]{%
  161. \@algocf@pre@ruled
  162. #2\label{#1}\kern2pt\hrule height.8pt depth0pt\kern2pt%
  163. #3\@algocf@pre@ruled
  164. }
  165. \newenvironment{algorithm}[1][htbp]%
  166. {%
  167. \ifundef{\algocf}%
  168. {`algorithm2e' package is required if you want to
  169. use the algorithm environment}%
  170. {}%
  171. \begin{algocf}[#1]%
  172. \renewcommand\@makecaption[2]{%
  173. \hskip\AlCapHSkip
  174. \parbox[t]{\hsize}{\algocf@captiontext{##1}{##2}}%
  175. }%
  176. }%
  177. {%
  178. \end{algocf}%
  179. }
  180. \AtBeginDocument{%
  181. \@ifpackageloaded{graphicx}%
  182. {\let\@jmlr@ifgraphicxloaded\@firstoftwo}%
  183. {\let\@jmlr@ifgraphicxloaded\@secondoftwo}%
  184. }
  185. \newcommand*{\includeteximage}[2][]{%
  186. \@jmlr@ifgraphicxloaded
  187. {%
  188. \def\Gin@req@sizes{%
  189. \Gin@req@height\Gin@nat@height
  190. \Gin@req@width\Gin@nat@width}%
  191. \begingroup
  192. \let\input@path\Ginput@path
  193. \IfFileExists{#2}%
  194. {%
  195. \toks@{\input{#2}}%
  196. \ifstrempty{#1}
  197. {}%
  198. {%
  199. \@tempswatrue
  200. \setkeys{Gin}{#1}%
  201. \Gin@esetsize
  202. }%
  203. \the\toks@
  204. }%
  205. {\@warning{File `#2' not found}}%
  206. \endgroup
  207. }%
  208. {\PackageError{jmlrutils}{`graphicx' package is required
  209. if you want to use \string\includeteximage}{}}%
  210. }
  211. \ifjmlrutilssubfloats
  212. \newcounter{subfigure}
  213. \@addtoreset{subfigure}{figure}
  214. \renewcommand*{\thesubfigure}{\alph{subfigure}}
  215. \renewcommand*{\p@subfigure}{\expandafter\@p@subfigure}
  216. \newcommand*{\@p@subfigure}[1]{%
  217. \protect\@subfigurelabel{\thefigure}{\thesubfigure}%
  218. }
  219. \newcommand*\@subfigurelabel[2]{#1\subfigurelabel{#2}}
  220. \newcommand*\@subfigref[1]{%
  221. {%
  222. \def\@subfigurelabel##1##2{\subfigurelabel{##2}}%
  223. \ref{#1}%
  224. }%
  225. }
  226. \newcommand*{\subfigref}[1]{%
  227. \let\@objectname\@empty
  228. \def\@objectref{}%
  229. \let\@prevsep\@empty
  230. \@for\@thislabel:=#1\do{%
  231. \toks@{\@prevsep}%
  232. \protected@edef\@objectref{\@objectref\the\toks@
  233. \protect\@subfigref{\@thislabel}}%
  234. \ifx\@objectname\@empty
  235. \let\@objectname\@nil
  236. \else
  237. \let\@objectname\relax
  238. \let\@prevsep\@jmlr@reflistsep
  239. \fi
  240. }%
  241. \ifx\@objectname\relax
  242. \let\@prevsep\@jmlr@reflistlastsep
  243. \fi
  244. \@objectref
  245. }
  246. \newcommand*{\subfigurelabel}[1]{(\emph{#1})}
  247. \newsavebox\@subfloatcapbox
  248. \newsavebox\@subfloatcontsbox
  249. \newcommand*{\subfigure}[1][]{%
  250. \bgroup
  251. \def\@subfigcap{#1}%
  252. \@subfigure
  253. }
  254. \newcommand*{\@subfigure}[2][b]{%
  255. \advance\c@figure by 1\relax
  256. \refstepcounter{subfigure}%
  257. \sbox\@subfloatcapbox{\subfigurelabel{\thesubfigure}%
  258. \ifx\@subfigcap\@empty
  259. \else
  260. \space\@subfigcap
  261. \fi}%
  262. \sbox\@subfloatcontsbox{#2}%
  263. \settowidth{\@tempdima}{\usebox\@subfloatcontsbox}%
  264. \settowidth{\@tempdimb}{\usebox\@subfloatcapbox}%
  265. \ifdim\@tempdimb>\@tempdima
  266. \settowidth\@tempdimb{\subfigurelabel{\thesubfigure}\space}%
  267. \addtolength{\@tempdima}{-\@tempdimb}%
  268. \sbox\@subfloatcapbox{\subfigurelabel{\thesubfigure}\space
  269. \parbox[t]{\@tempdima}{\@subfigcap}}%
  270. \fi
  271. \begin{tabular}[#1]{@{}c@{}}%
  272. \usebox\@subfloatcontsbox\\\usebox\@subfloatcapbox
  273. \end{tabular}%
  274. \egroup
  275. }
  276. \newcounter{subtable}
  277. \@addtoreset{subtable}{table}
  278. \renewcommand*{\thesubtable}{\alph{subtable}}
  279. \renewcommand*{\p@subtable}{\expandafter\@p@subtable}
  280. \newcommand*{\@p@subtable}[1]{%
  281. \protect\@subtablelabel{\thetable}{\thesubtable}%
  282. }
  283. \newcommand*\@subtablelabel[2]{#1\subtablelabel{#2}}
  284. \newcommand*\@subtabref[1]{%
  285. {%
  286. \def\@subtablelabel##1##2{\subtablelabel{##2}}%
  287. \ref{#1}%
  288. }%
  289. }
  290. \newcommand*{\subtabref}[1]{%
  291. \let\@objectname\@empty
  292. \def\@objectref{}%
  293. \let\@prevsep\@empty
  294. \@for\@thislabel:=#1\do{%
  295. \toks@{\@prevsep}%
  296. \protected@edef\@objectref{\@objectref\the\toks@
  297. \protect\@subtabref{\@thislabel}}%
  298. \ifx\@objectname\@empty
  299. \let\@objectname\@nil
  300. \else
  301. \let\@objectname\relax
  302. \let\@prevsep\@jmlr@reflistsep
  303. \fi
  304. }%
  305. \ifx\@objectname\relax
  306. \let\@prevsep\@jmlr@reflistlastsep
  307. \fi
  308. \@objectref
  309. }
  310. \newcommand*{\subtablelabel}[1]{(\emph{#1})}
  311. \newcommand*{\subtable}[1][]{%
  312. \def\@subtabcap{#1}%
  313. \@subtable
  314. }
  315. \newcommand*{\@subtable}[2][t]{%
  316. \refstepcounter{subtable}%
  317. \sbox\@subfloatcapbox{\subtablelabel{\thesubtable}%
  318. \ifx\@subtabcap\@empty
  319. \else
  320. \space\@subtabcap
  321. \fi}%
  322. \sbox\@subfloatcontsbox{#2}%
  323. \settowidth{\@tempdima}{\usebox\@subfloatcontsbox}%
  324. \settowidth{\@tempdimb}{\usebox\@subfloatcapbox}%
  325. \ifdim\@tempdimb>\@tempdima
  326. \settowidth\@tempdimb{\subtablelabel{\thesubtable}\space}%
  327. \addtolength{\@tempdima}{-\@tempdimb}%
  328. \sbox\@subfloatcapbox{\subtablelabel{\thesubtable}\space
  329. \parbox[t]{\@tempdima}{\@subtabcap}}%
  330. \fi
  331. \begin{tabular}[#1]{@{}c@{}}%
  332. \usebox\@subfloatcapbox\\\usebox\@subfloatcontsbox
  333. \end{tabular}
  334. }
  335. \fi
  336. \ifjmlrutilsmaths
  337. \newcommand*{\set}[1]{\ensuremath{\mathcal{#1}}}
  338. \let\orgvec\vec
  339. \renewcommand*{\vec}[1]{\boldsymbol{#1}}
  340. \fi
  341. \newenvironment{enumerate*}%
  342. {%
  343. \ifnum\@enumdepth=0\relax
  344. \setcounter{enumi}{0}%
  345. \fi
  346. \ifnum\@enumdepth>\thr@@
  347. \@toodeep
  348. \else
  349. \advance\@enumdepth\@ne
  350. \def\@enumctr{enumi}%
  351. \list
  352. {\labelenumi}%
  353. {\@nmbrlisttrue\def\@listctr{enumi}%
  354. \def\makelabel##1{\hss\llap{##1}}}%
  355. \fi
  356. }%
  357. {\endlist}
  358. \newenvironment{altdescription}[1]%
  359. {\list{}%
  360. {%
  361. \settowidth{\labelwidth}{\altdescriptionlabel{#1}}%
  362. \setlength{\labelsep}{15pt}%
  363. \setlength{\leftmargin}{2\labelsep}%
  364. \addtolength{\leftmargin}{\labelwidth}%
  365. \setlength{\rightmargin}{\labelsep}%
  366. \let\makelabel\altdescriptionlabel
  367. }%
  368. }%
  369. {\endlist}
  370. \newcommand*{\altdescriptionlabel}[1]{\normalfont\bfseries #1\hfill}
  371. \newcommand*{\mailto}[1]{\texttt{#1}}
  372. \ifjmlrutilstheorems
  373. \newcommand{\jmlrBlackBox}{\rule{1.5ex}{1.5ex}}
  374. \providecommand{\BlackBox}{\jmlrBlackBox}
  375. \newcommand{\jmlrQED}{\hfill\jmlrBlackBox\par\bigskip}
  376. \newenvironment{proof}%
  377. {%
  378. \par\noindent{\bfseries\upshape Proof\ }%
  379. }%
  380. {\jmlrQED}
  381. \newcommand*{\theorembodyfont}[1]{%
  382. \renewcommand*{\@theorembodyfont}{#1}%
  383. }
  384. \newcommand*{\@theorembodyfont}{\normalfont\itshape}%
  385. \newcommand*{\theoremheaderfont}[1]{%
  386. \renewcommand*{\@theoremheaderfont}{#1}%
  387. }
  388. \newcommand*{\@theoremheaderfont}{\normalfont\bfseries }%
  389. \newcommand*{\theoremsep}[1]{%
  390. \renewcommand*{\@theoremsep}{#1}%
  391. }
  392. \newcommand*{\@theoremsep}{}%
  393. \newcommand*{\theorempostheader}[1]{%
  394. \renewcommand*{\@theorempostheader}{#1}%
  395. }
  396. \newcommand*{\@theorempostheader}{}%
  397. \let\jmlr@org@newtheorem\newtheorem
  398. \renewcommand*{\newtheorem}{\@ifstar\jmlr@snewtheorem\jmlr@newtheorem}
  399. \newcommand*{\jmlr@snewtheorem}[2]{%
  400. \cslet{jmlr@thm@#1@body@font}{\@theorembodyfont}%
  401. \cslet{jmlr@thm@#1@header@font}{\@theoremheaderfont}%
  402. \cslet{jmlr@thm@#1@sep}{\@theoremsep}%
  403. \cslet{jmlr@thm@#1@postheader}{\@theorempostheader}%
  404. \newenvironment{#1}%
  405. {%
  406. \trivlist
  407. \item
  408. [%
  409. \hskip\labelsep{\csuse{jmlr@thm@#1@header@font}#2%
  410. \csuse{jmlr@thm@#1@postheader}%
  411. }%
  412. ]%
  413. \mbox{}\csuse{jmlr@thm@#1@sep}%
  414. \csuse{jmlr@thm@#1@body@font}%
  415. }%
  416. {%
  417. \endtrivlist
  418. }%
  419. }
  420. \newcommand{\jmlr@newtheorem}[1]{%
  421. \cslet{jmlr@thm@#1@body@font}{\@theorembodyfont}%
  422. \cslet{jmlr@thm@#1@header@font}{\@theoremheaderfont}%
  423. \cslet{jmlr@thm@#1@sep}{\@theoremsep}%
  424. \cslet{jmlr@thm@#1@postheader}{\@theorempostheader}%
  425. \jmlr@org@newtheorem{#1}%
  426. }
  427. \renewcommand*{\@xthm}[2]{%
  428. \def\@jmlr@currentthm{#1}%
  429. \@begintheorem{#2}{\csname the#1\endcsname}%
  430. \ignorespaces
  431. }
  432. \def\@ythm#1#2[#3]{%
  433. \def\@jmlr@currentthm{#1}%
  434. \@opargbegintheorem{#2}{\csname the#1\endcsname}{#3}%
  435. \ignorespaces
  436. }
  437. \renewcommand*{\@begintheorem}[2]{%
  438. \ifdef{\@jmlr@currentthm}%
  439. {%
  440. \letcs{\jmlr@this@theoremheader}{jmlr@thm@\@jmlr@currentthm @header@font}%
  441. \letcs{\jmlr@this@theorembody}{jmlr@thm@\@jmlr@currentthm @body@font}%
  442. \letcs{\jmlr@this@theoremsep}{jmlr@thm@\@jmlr@currentthm @sep}%
  443. \letcs{\jmlr@this@theorempostheader}%
  444. {jmlr@thm@\@jmlr@currentthm @postheader}%
  445. }%
  446. {%
  447. \let\jmlr@this@theorembody\@theorembodyfont
  448. \let\jmlr@this@theoremheader\@theoremheaderfont
  449. \let\jmlr@this@theoremsep\@theoremsep
  450. \let\jmlr@this@theorempostheader\@theorempostheader
  451. }%
  452. \trivlist
  453. \item
  454. [%
  455. \hskip\labelsep{\jmlr@this@theoremheader #1\ #2%
  456. \jmlr@this@theorempostheader}%
  457. ]%
  458. \mbox{}\jmlr@this@theoremsep
  459. \jmlr@this@theorembody
  460. }
  461. \renewcommand*{\@opargbegintheorem}[3]{%
  462. \ifdef{\@jmlr@currentthm}%
  463. {%
  464. \letcs{\jmlr@this@theoremheader}{jmlr@thm@\@jmlr@currentthm @header@font}%
  465. \letcs{\jmlr@this@theorembody}{jmlr@thm@\@jmlr@currentthm @body@font}%
  466. \letcs{\jmlr@this@theoremsep}{jmlr@thm@\@jmlr@currentthm @sep}%
  467. \letcs{\jmlr@this@theorempostheader}%
  468. {jmlr@thm@\@jmlr@currentthm @postheader}%
  469. }%
  470. {%
  471. \let\jmlr@this@theorembody\@theorembodyfont
  472. \let\jmlr@this@theoremheader\@theoremheaderfont
  473. \let\jmlr@this@theoremsep\@theoremsep
  474. \let\jmlr@this@theorempostheader\@theorempostheader
  475. }%
  476. \trivlist
  477. \item[\hskip\labelsep{\jmlr@this@theoremheader #1\ #2\ (#3)%
  478. \jmlr@this@theorempostheader}]%
  479. \mbox{}\jmlr@this@theoremsep
  480. \jmlr@this@theorembody
  481. }
  482. \newtheorem{example}{Example}
  483. \newtheorem{theorem}{Theorem}
  484. \newtheorem{lemma}[theorem]{Lemma}
  485. \newtheorem{proposition}[theorem]{Proposition}
  486. \newtheorem{remark}[theorem]{Remark}
  487. \newtheorem{corollary}[theorem]{Corollary}
  488. \newtheorem{definition}[theorem]{Definition}
  489. \newtheorem{conjecture}[theorem]{Conjecture}
  490. \newtheorem{axiom}[theorem]{Axiom}
  491. \fi
  492. \endinput
  493. %%
  494. %% End of file `jmlrutils.sty'.