| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% |
| 4 |
% bookshelf.dtx is copyright © 2020-2024 by Peter Flynn |
| 5 |
% <[email protected]> and Boris Veytsman <[email protected]> |
| 6 |
% |
| 7 |
% This work may be distributed and/or modified under the |
| 8 |
% conditions of the LaTeX Project Public License, either |
| 9 |
% version 1.3c of this license or (at your option) any later |
| 10 |
% version. The latest version of this license is in: |
| 11 |
% |
| 12 |
% http://www.latex-project.org/lppl.txt |
| 13 |
% |
| 14 |
% and version 1.3c or later is part of all distributions of |
| 15 |
% LaTeX version 2008-06-01 or later. |
| 16 |
% |
| 17 |
% This work has the LPPL maintenance status ‘maintained’. |
| 18 |
% |
| 19 |
% The current maintainer of this work is Peter Flynn <[email protected]> |
| 20 |
% |
| 21 |
% This work consists of the files bookshelf.dtx and bookshelf.ins, |
| 22 |
% the derived file , |
| 23 |
% and any other ancillary files listed in the MANIFEST. |
| 24 |
% |
| 25 |
% \fi |
| 26 |
% \iffalse |
| 27 |
%<*driver> |
| 28 |
\ProvidesFile{bookshelf.dtx} |
| 29 |
%</driver> |
| 30 |
%<class>\NeedsTeXFormat{LaTeX2e}[2017/04/15] |
| 31 |
%<class>\ProvidesClass{bookshelf} |
| 32 |
%<*class> |
| 33 |
[2024/10/09 v1.2 Turn your bibliography into a bookshelf image] |
| 34 |
%</class> |
| 35 |
%<*driver> |
| 36 |
\RequirePackage{fix-cm}% included by default. |
| 37 |
\PassOptionsToPackage{svgnames}{xcolor}% xcolor/dox/hyperref implied |
| 38 |
\documentclass[12pt]{ltxdoc} |
| 39 |
%% |
| 40 |
%% Packages added for documentation |
| 41 |
%% |
| 42 |
\usepackage[noindex]{dox}% used by default. (0)% |
| 43 |
|
| 44 |
\makeatletter |
| 45 |
\doxitem[idxtype=attribute]{Attribute}{CPK@attribute}{attributes} |
| 46 |
\makeatother |
| 47 |
\makeatletter |
| 48 |
\doxitem[idxtype=attributevalue]{AttributeValue}{CPK@attributevalue}{attribute values} |
| 49 |
\makeatother |
| 50 |
\makeatletter |
| 51 |
\doxitem[idxtype=class]{Class}{CPK@class}{classes} |
| 52 |
\makeatother |
| 53 |
\makeatletter |
| 54 |
\doxitem[idxtype=colour]{Colour}{CPK@colour}{colours} |
| 55 |
\makeatother |
| 56 |
\makeatletter |
| 57 |
\doxitem[idxtype=counter]{Counter}{CPK@counter}{counters} |
| 58 |
\makeatother |
| 59 |
\makeatletter |
| 60 |
\doxitem[idxtype=DTD]{DTD}{CPK@dtd}{DTDs/Schemas} |
| 61 |
\makeatother |
| 62 |
\makeatletter |
| 63 |
\doxitem[idxtype=element]{Element}{CPK@element}{element types} |
| 64 |
\makeatother |
| 65 |
\makeatletter |
| 66 |
\doxitem[idxtype=entity]{Entity}{CPK@entity}{entities} |
| 67 |
\makeatother |
| 68 |
\makeatletter |
| 69 |
\doxitem[idxtype=error]{Error}{CPK@error}{errors} |
| 70 |
\makeatother |
| 71 |
\makeatletter |
| 72 |
\doxitem[idxtype=field]{Field}{CPK@field}{fields} |
| 73 |
\makeatother |
| 74 |
\makeatletter |
| 75 |
\doxitem[idxtype=file]{File}{CPK@file}{files} |
| 76 |
\makeatother |
| 77 |
\makeatletter |
| 78 |
\doxitem[idxtype=font]{Font}{CPK@font}{fonts} |
| 79 |
\makeatother |
| 80 |
\makeatletter |
| 81 |
\doxitem[idxtype=function]{Function}{CPK@function}{functions} |
| 82 |
\makeatother |
| 83 |
\makeatletter |
| 84 |
\doxitem[idxtype=language]{Language}{CPK@language}{languages} |
| 85 |
\makeatother |
| 86 |
\makeatletter |
| 87 |
\doxitem[macrolike,idxtype=length]{Length}{CPK@length}{lengths} |
| 88 |
\makeatother |
| 89 |
\makeatletter |
| 90 |
\doxitem[idxtype=mode]{Mode}{CPK@mode}{modes} |
| 91 |
\makeatother |
| 92 |
\makeatletter |
| 93 |
\doxitem[idxtype=option]{Option}{CPK@option}{options} |
| 94 |
\makeatother |
| 95 |
\makeatletter |
| 96 |
\doxitem[idxtype=package]{Package}{CPK@package}{packages} |
| 97 |
\makeatother |
| 98 |
\makeatletter |
| 99 |
\doxitem[idxtype=variable]{Variable}{CPK@variable}{variables} |
| 100 |
\makeatother |
| 101 |
\makeatletter |
| 102 |
\doxitem[idxtype=parameter]{Parameter}{CPK@parameter}{parameters} |
| 103 |
\makeatother |
| 104 |
\makeatletter |
| 105 |
\doxitem[macrolike,idxtype=switch]{Switch}{CPK@switch}{switches} |
| 106 |
\makeatother |
| 107 |
\makeatletter |
| 108 |
\doxitem[idxtype=template]{Template}{CPK@template}{templates} |
| 109 |
\makeatother |
| 110 |
\makeatletter |
| 111 |
\doxitem[idxtype=typeface]{Typeface}{CPK@typeface}{typefaces} |
| 112 |
\makeatother |
| 113 |
\makeatletter |
| 114 |
\doxitem[macrolike,idxtype=box]{Box}{CPK@box}{boxes} |
| 115 |
\makeatother |
| 116 |
\newcommand{\LabelFont}[2][\relax]{\strut |
| 117 |
{\fontencoding\encodingdefault |
| 118 |
\fontfamily{lmtt}\fontseries{lc}#1\selectfont#2}\space} |
| 119 |
\makeatletter |
| 120 |
\let\CPK@macro\macro\let\CPK@endmacro\endmacro |
| 121 |
\makeatother |
| 122 |
\makeatletter |
| 123 |
\let\CPK@environment\environment\let\CPK@endenvironment\endenvironment |
| 124 |
\makeatother |
| 125 |
\makeatletter |
| 126 |
\def\PrintAttributeName#1{\LabelFont{@#1}} |
| 127 |
\makeatother |
| 128 |
\def\PrintAttributeValueName#1{\LabelFont{"#1"}} |
| 129 |
\def\PrintClassName#1{\LabelFont[\fontfamily{lmss}]{#1}} |
| 130 |
\def\PrintColourName#1{\LabelFont[\color{#1}]{#1}} |
| 131 |
\def\PrintCounterName#1{\LabelFont{#1}} |
| 132 |
\def\PrintDTDName#1{\LabelFont{#1}} |
| 133 |
\def\PrintElementName#1{\LabelFont{<#1>}} |
| 134 |
\def\PrintEntityName#1{\LabelFont{\}} |
| 135 |
\def\PrintEnvironmentName#1{\LabelFont[\fontfamily{lmss}]{#1}} |
| 136 |
\def\PrintErrorName#1{\LabelFont[\color{Red}!]{#1}} |
| 137 |
\def\PrintFunctionName#1{\LabelFont[\bfseries\itshape]{#1}} |
| 138 |
\def\PrintLanguageName#1{\LabelFont{#1}} |
| 139 |
\def\PrintLengthName#1{\LabelFont{#1}} |
| 140 |
\def\PrintMacroName#1{\LabelFont{#1}} |
| 141 |
\def\PrintModeName#1{\LabelFont[\sffamily]{\textlangle#1\textrangle}} |
| 142 |
\def\PrintOptionName#1{\LabelFont[\bfseries]{#1}} |
| 143 |
\def\PrintPackageName#1{\LabelFont[\fontfamily{lmss}]{#1}} |
| 144 |
\def\PrintSwitchName#1{\LabelFont{#1}} |
| 145 |
\def\PrintTemplateName#1{\LabelFont[\bfseries]{#1}} |
| 146 |
\def\PrintVariableName#1{\LabelFont[\ttfamily]{#1}} |
| 147 |
\def\PrintParameterName#1{\LabelFont[\ttfamily]{#1}} |
| 148 |
\def\PrintFieldName#1{\LabelFont[\ttfamily]{#1}} |
| 149 |
%% fontenc omit: conflict: fontspec (3) |
| 150 |
%% inputenc omit: conflict: fontspec (6) |
| 151 |
\usepackage{fontspec}% part/@conformance=xelatex detected. (7)% |
| 152 |
\renewcommand{\textsc}[1]{{\small\MakeTextUppercase{#1}}} |
| 153 |
\usepackage{noto}% requested by author (15)% |
| 154 |
\usepackage{luximono}% requested by author (16)% |
| 155 |
\usepackage{mflogo}% used by default. (36)% |
| 156 |
\usepackage[british]{babel}% used by default. (41)% |
| 157 |
\usepackage{calc}% used by default. (50)% |
| 158 |
\makeatletter |
| 159 |
{\scriptsize |
| 160 |
\global\advance\@totalleftmargin by1em |
| 161 |
\global\advance\MacroIndent by.5em} |
| 162 |
\makeatother |
| 163 |
\usepackage{ccaption}% used by default. (53)% |
| 164 |
\captionnamefont{\bfseries} |
| 165 |
\captionstyle{\raggedright} |
| 166 |
\usepackage[inline]{enumitem}% use of 'variablelist' detected (57)% |
| 167 |
\setlist[description]{style=unboxed} |
| 168 |
\setlist[itemize]{leftmargin=2em} |
| 169 |
\setlist[enumerate]{leftmargin=2em} |
| 170 |
\newlist{inlineenum}{enumerate*}{1} |
| 171 |
\setlist[inlineenum,1]{label=\emph{\alph*}), |
| 172 |
itemjoin={{; }},itemjoin*={{; and }}} |
| 173 |
\usepackage{fancyhdr}% requested by author (59)% |
| 174 |
\makeatletter |
| 175 |
\pagestyle{fancy} |
| 176 |
\cfoot{} |
| 177 |
\lhead{\footnotesize\rightmark} |
| 178 |
\rhead{\small\thepage} |
| 179 |
\rfoot{\footnotesize The \LaTeX\ |
| 180 |
\textsf{\SIL@docname} \SIL@doctype} |
| 181 |
\renewcommand{\headrulewidth}{0pt} |
| 182 |
\renewcommand{\footrulewidth}{0pt} |
| 183 |
\makeatother |
| 184 |
\usepackage{relsize}% use of 'acronym' detected (65)% |
| 185 |
\usepackage{textcase}% used by default. (68)% |
| 186 |
\usepackage{float}% used by default. (70)% |
| 187 |
\renewcommand{\topfraction}{.85} |
| 188 |
\renewcommand{\bottomfraction}{.7} |
| 189 |
\renewcommand{\textfraction}{.15} |
| 190 |
\renewcommand{\floatpagefraction}{.66} |
| 191 |
\renewcommand{\dbltopfraction}{.66} |
| 192 |
\renewcommand{\dblfloatpagefraction}{.66} |
| 193 |
\setcounter{topnumber}{9} |
| 194 |
\setcounter{bottomnumber}{9} |
| 195 |
\setcounter{totalnumber}{20} |
| 196 |
\setcounter{dbltopnumber}{9} |
| 197 |
\usepackage[level]{fmtcount}% xref/@linkend➝listitem/xml:id detected. (71)% |
| 198 |
\usepackage[a4paper,left=30mm,top=25mm, |
| 199 |
textwidth=150mm,textheight=225mm,headheight=15pt]{geometry}% used by |
| 200 |
% default. (72)% |
| 201 |
\usepackage{biblatex} |
| 202 |
\usepackage{hypdoc}% requested by author (78)% |
| 203 |
\hypersetup{linkcolor=DarkBlue,urlcolor=Blue,citecolor=Red} |
| 204 |
\ExecuteBibliographyOptions{maxcitenames=1} |
| 205 |
\DeclareFieldFormat{citehyperref}{% |
| 206 |
\DeclareFieldAlias{bibhyperref}{noformat}% Avoid nested links |
| 207 |
\bibhyperref{#1}} |
| 208 |
\DeclareFieldFormat{textcitehyperref}{% |
| 209 |
\DeclareFieldAlias{bibhyperref}{noformat}% Avoid nested links |
| 210 |
\bibhyperref{% |
| 211 |
#1% |
| 212 |
\ifbool{cbx:parens} |
| 213 |
{\bibcloseparen\global\boolfalse{cbx:parens}} |
| 214 |
{}}} |
| 215 |
\savebibmacro{cite} |
| 216 |
\savebibmacro{textcite} |
| 217 |
\renewbibmacro*{cite}{% |
| 218 |
\printtext[citehyperref]{% |
| 219 |
\restorebibmacro{cite}% |
| 220 |
\usebibmacro{cite}}} |
| 221 |
\renewbibmacro*{textcite}{% |
| 222 |
\ifboolexpr{ |
| 223 |
( not test {\iffieldundef{prenote}} and |
| 224 |
test {\ifnumequal{\value{citecount}}{1}} ) |
| 225 |
or |
| 226 |
( not test {\iffieldundef{postnote}} and |
| 227 |
test {\ifnumequal{\value{citecount}}{\value{citetotal}}} ) |
| 228 |
} |
| 229 |
{\DeclareFieldAlias{textcitehyperref}{noformat}} |
| 230 |
{}% |
| 231 |
\printtext[textcitehyperref]{% |
| 232 |
\restorebibmacro{textcite}% |
| 233 |
\usebibmacro{textcite}}} |
| 234 |
\usepackage{listings}% use of 'programlisting' detected (85)% |
| 235 |
\lstdefinelanguage{dummy} |
| 236 |
{morekeywords={dummy}} |
| 237 |
\lstdefinelanguage{Makefile} |
| 238 |
{otherkeywords={.PHONY,.DEFAULT},% |
| 239 |
morekeywords={PHONY,DEFAULT,shell,ifeq,else,endif},% |
| 240 |
keywordsprefix={.},% |
| 241 |
moredelim=[l][\color{Green}]{:},% |
| 242 |
morecomment=[l]{\#},% |
| 243 |
moredelim=[s][\color{Blue}]{\$(}{)}% |
| 244 |
} |
| 245 |
\lstdefinelanguage{DocBook}[]{XML} |
| 246 |
{morekeywords={abstract,address,affiliation,annotation,arg, |
| 247 |
author,book,chapter,classname,cmdsynopsis,command, |
| 248 |
constraintdef,contrib,copyright,cover,date,email,emphasis, |
| 249 |
envar,filename,firstname,footnote,guibutton,guilabel, |
| 250 |
guimenu,guimenuitem,guisubmenu,holder,info,itemizedlist, |
| 251 |
listitem,literal,member,option,orderedlist,orgdiv,orgname, |
| 252 |
package,para,parameter,part,personname,phrase,procedure, |
| 253 |
productname,programlisting,quote,refsection,remark, |
| 254 |
constructorsynopsis,methodparan,modifier,funcparams,olink, |
| 255 |
bibliography,biblioentry,biblioset,subtitle,artpagenums, |
| 256 |
volumenum,issuenum,DOCTYPE,SYSTEM,xml:id,releaseinfo, |
| 257 |
replaceable,revdescription,revhistory,revision,sect1,sect2, |
| 258 |
sect3,sect4,seg,seglistitem,segmentedlist,segtitle, |
| 259 |
simplelist,step,surname,systemitem,tag,term,title,uri, |
| 260 |
userinput,variablelist,varlistentry,wordasword,xref,year, |
| 261 |
xlink:href}} |
| 262 |
|
| 263 |
\makeatletter |
| 264 |
\lstdefinelanguage{bash} |
| 265 |
{morestring=[s]{[]},morekeywords={exit,logout,yes,no,@, |
| 266 |
password,ssh,URL,cd,dvips,latex,ls,makeindex,man,mkdir, |
| 267 |
pdflatex,sudo,texconfig,texdoc,updmap,xelatex,biber, |
| 268 |
latexmk,bibtex}} |
| 269 |
|
| 270 |
\makeatother |
| 271 |
\lstdefinelanguage{APA}[]{XML} |
| 272 |
{morekeywords={TTL}} |
| 273 |
|
| 274 |
\lstdefinelanguage{OOXML}[]{XML} |
| 275 |
{morekeywords={w:p,w:pPr,w:pStyle,w:rPr,w:rFonts, |
| 276 |
w:r,w:t,w:lang}} |
| 277 |
|
| 278 |
\lstdefinelanguage{SGML}[]{XML} |
| 279 |
{morekeywords={sec,ttl}} |
| 280 |
|
| 281 |
\lstdefinelanguage{DTD}[]{XML} |
| 282 |
{morekeywords={ELEMENT,ENTITY,ATTLIST,CDATA,ID,REQUIRED, |
| 283 |
IMPLIED,PCDATA}} |
| 284 |
|
| 285 |
\lstdefinelanguage{Runoff} |
| 286 |
{morekeywords={h1}} |
| 287 |
|
| 288 |
\lstdefinelanguage{GML} |
| 289 |
{morekeywords={h1}} |
| 290 |
|
| 291 |
\lstdefinelanguage{Scribe} |
| 292 |
{morekeywords={Heading},morestring=[s]{[]}} |
| 293 |
|
| 294 |
\lstdefinelanguage{RTF}[]{TeX} |
| 295 |
{moretexcs={rtf,ansi,deff,adeflang,fonttbl,f,froman,fprq, |
| 296 |
fcharset,f1,fswiss,falt,fnil,colortbl,red,green,blue, |
| 297 |
stylesheet,s,snext,nowidctlpar,hyphen,hyphlead,hyphtrail, |
| 298 |
hyphmax,cf,kerning,dbch,af,langfe,afs,alang,loch,fs, |
| 299 |
pgndec,pard,plain,qc,sb,sa,keepn,b,ab,rtlch,ltrch,par}} |
| 300 |
|
| 301 |
\lstdefinelanguage{TEI}[]{XML} |
| 302 |
{morekeywords={TEI,TEI.2,teiHeader,fileDesc,sourceDesc, |
| 303 |
titleStmt,title,author,editor,respStmt,resp,name, |
| 304 |
editionStmt,edition,text,body,publicationStmt,publisher, |
| 305 |
div,div1,placeName,lg,l,s,cl,phr,w,list,distinct,p,pb, |
| 306 |
mls,div2,head,num,val,app,lem,rdg,q,sup,uncl,note, |
| 307 |
DOCTYPE,SYSTEM,xml:id}}[keywords,comments,strings] |
| 308 |
|
| 309 |
\lstdefinelanguage{XSLT2}[]{XML} |
| 310 |
{morekeywords={xsl:stylesheet,xsl:transform, |
| 311 |
xsl:apply-imports,xsl:attribute-set,xsl:decimal-format, |
| 312 |
xsl:import,xsl:include,xsl:key,xsl:namespace-alias, |
| 313 |
xsl:output,xsl:param, |
| 314 |
xsl:preserve-space,xsl:strip-space,xsl:template, |
| 315 |
xsl:variable,xsl:character-map,xsl:function, |
| 316 |
xsl:import-schema,xsl:param,xsl:variable, |
| 317 |
xsl:apply-imports,xsl:apply-templates,xsl:attribute, |
| 318 |
xsl:call-template,xsl:choose,xsl:comment,xsl:copy, |
| 319 |
xsl:copy-of,xsl:element,xsl:fallback,xsl:for-each, |
| 320 |
xsl:if,xsl:message,xsl:number,xsl:otherwise, |
| 321 |
xsl:processing-instruction,xsl:text,xsl:value-of, |
| 322 |
xsl:variable,xsl:when,xsl:with-param,xsl:sort, |
| 323 |
xsl:for-each-group,xsl:next-match,xsl:analyze-string, |
| 324 |
xsl:namespace,xsl:result-document,xsl:copy, |
| 325 |
xsl:fallback,xsl:document,xsl:sequence, |
| 326 |
xsl:matching-substring,xsl:non-matching-substring, |
| 327 |
xsl:perform-sort,xsl:output-character}, |
| 328 |
alsodigit={-}} |
| 329 |
|
| 330 |
\lstdefinelanguage{LaTeXe}[LaTeX]{TeX} |
| 331 |
{morekeywords = {selectlanguage,foreignlanguage, |
| 332 |
textbrokenbar,textlangle,textrangle,subsection,url, |
| 333 |
chapter,tableofcontents,part,subsubsection,paragraph, |
| 334 |
subparagraph,maketitle,setlength,listoffigures, |
| 335 |
listoftables,color,arraybackslash,includegraphics, |
| 336 |
textcite,parencite,graphicspath,lstinline, |
| 337 |
DeclareLanguageMapping,textcolor,definecolor,colorbox, |
| 338 |
fcolorbox,RequirePackage,PassOptionsToPackage}} |
| 339 |
|
| 340 |
\lstdefinelanguage{BIBTeX}{ |
| 341 |
morekeywords = {title,author,edition,publisher,year, |
| 342 |
address}, |
| 343 |
morestring=[b]", |
| 344 |
} |
| 345 |
|
| 346 |
\lstdefinelanguage{Email}{ |
| 347 |
morekeywords={From,Subject,To,Date}, |
| 348 |
} |
| 349 |
|
| 350 |
\lstset{defaultdialect=LaTeXe,frame=single, |
| 351 |
framesep=.5em,backgroundcolor=\color{AliceBlue}, |
| 352 |
rulecolor=\color{LightSteelBlue},framerule=1pt} |
| 353 |
|
| 354 |
\lstloadlanguages{LaTeXe,DocBook,XML,XSLT2,bash} |
| 355 |
\lstdefinelanguage{XMLFRAG}{tag=**[s]<>}[html] |
| 356 |
\lstnewenvironment{listingsdoc} |
| 357 |
{\lstset{language={[LaTeX]TeX}}} |
| 358 |
{} |
| 359 |
\newcommand\basicdefault[1]{\footnotesize |
| 360 |
\color{Black}\ttfamily#1} |
| 361 |
|
| 362 |
\lstset{basicstyle=\basicdefault{\spaceskip.5em}} |
| 363 |
\lstset{literate= |
| 364 |
{§}{{\S}}1 |
| 365 |
{©}{{\raisebox{.125ex}{\copyright}\enspace}}1 |
| 366 |
{«}{{\guillemotleft}}1 |
| 367 |
{»}{{\guillemotright}}1 |
| 368 |
{Á}{{\'A}}1 |
| 369 |
{Ä}{{\"A}}1 |
| 370 |
{É}{{\'E}}1 |
| 371 |
{Í}{{\'I}}1 |
| 372 |
{Ó}{{\'O}}1 |
| 373 |
{Ö}{{\"O}}1 |
| 374 |
{Ú}{{\'U}}1 |
| 375 |
{Ü}{{\"U}}1 |
| 376 |
{ß}{{\ss}}2 |
| 377 |
{à}{{\`a}}1 |
| 378 |
{á}{{\'a}}1 |
| 379 |
{ä}{{\"a}}1 |
| 380 |
{é}{{\'e}}1 |
| 381 |
{í}{{\'i}}1 |
| 382 |
{ó}{{\'o}}1 |
| 383 |
{ö}{{\"o}}1 |
| 384 |
{ú}{{\'u}}1 |
| 385 |
{ü}{{\"u}}1 |
| 386 |
{¹}{{\textsuperscript1}}1 |
| 387 |
{²}{{\textsuperscript2}}1 |
| 388 |
{³}{{\textsuperscript3}}1 |
| 389 |
{ı}{{\i}}1 |
| 390 |
{—}{{---}}1 |
| 391 |
{’}{{'}}1 |
| 392 |
{…}{{\dots}}1 |
| 393 |
{➝}{{$leftarrow$}}1 |
| 394 |
{⮠}{{$\hookleftarrow$}}1 |
| 395 |
{␣}{{\textvisiblespace}}1, |
| 396 |
keywordstyle=\color{DarkGreen}\bfseries, |
| 397 |
identifierstyle=\color{DarkRed}, |
| 398 |
commentstyle=\color{Gray}\upshape, |
| 399 |
stringstyle=\color{DarkBlue}\upshape, |
| 400 |
emphstyle=\color{Chocolate}\upshape, |
| 401 |
showstringspaces=false, |
| 402 |
columns=fullflexible, |
| 403 |
keepspaces=true} |
| 404 |
\usepackage{makeidx}% used by default. (87)% |
| 405 |
\makeindex |
| 406 |
\usepackage{nicefrac}% used by default. (93)% |
| 407 |
\def\textonehalf{\ensuremath{\nicefrac12}} |
| 408 |
\usepackage{parskip}% requested by author (95)% |
| 409 |
\usepackage{sectsty}% requested by author (99)% |
| 410 |
\allsectionsfont{\sffamily\raggedright} |
| 411 |
\renewcommand*{\descriptionlabel}[1]{\hspace\labelsep |
| 412 |
\sffamily\bfseries #1} |
| 413 |
\usepackage[normalem]{ulem}% use of 'link' detected (105)% |
| 414 |
\usepackage{url}% use of 'uri' detected (106)% |
| 415 |
\AtBeginDocument{\urlstyle{tt}} |
| 416 |
\usepackage{varioref}% use of 'xref' detected (109)% |
| 417 |
\vrefwarning |
| 418 |
\labelformat{appendix}{Appendix~#1} |
| 419 |
\makeatletter |
| 420 |
\labelformat{chapter}{\@chapapp~#1} |
| 421 |
\makeatother |
| 422 |
\labelformat{section}{section~#1} |
| 423 |
\labelformat{subsection}{section~#1} |
| 424 |
\labelformat{subsubsection}{section~#1} |
| 425 |
\labelformat{paragraph}{section~#1} |
| 426 |
\labelformat{figure}{Figure~#1} |
| 427 |
\labelformat{table}{Table~#1} |
| 428 |
\labelformat{item}{item~#1} |
| 429 |
\renewcommand{\reftextcurrent}{elsewhere on this |
| 430 |
page} |
| 431 |
\def\reftextafter{on the |
| 432 |
\reftextvario{next}{following} page} |
| 433 |
\usepackage{xcolor}% used by default. (117)% |
| 434 |
\makeatletter |
| 435 |
\@ifundefined{T}{% |
| 436 |
\newcommand{\T}[2]{{\fontencoding{T1}% |
| 437 |
\selectfont#2}}}{} |
| 438 |
\makeatother |
| 439 |
\usepackage{classpack}[2020/05/19]% used by default. (122)% |
| 440 |
\makeatletter |
| 441 |
\newcommand{\SIL@doctype}{class} |
| 442 |
\newcommand{\SIL@docname}{bookshelf} |
| 443 |
\newcommand{\SIL@docowner}{Silmaril} |
| 444 |
\makeatother |
| 445 |
\addbibresource{bookshelf.bib} |
| 446 |
\allsectionsfont{\sffamily} |
| 447 |
% |
| 448 |
%% |
| 449 |
%% Settings for docstrip and ltxdoc |
| 450 |
%% |
| 451 |
\EnableCrossrefs |
| 452 |
\CodelineIndex |
| 453 |
\RecordChanges |
| 454 |
\begin{document}\raggedright |
| 455 |
\DocInput{bookshelf.dtx} |
| 456 |
\end{document} |
| 457 |
%</driver> |
| 458 |
% \fi |
| 459 |
% |
| 460 |
% \CheckSum{0} |
| 461 |
% |
| 462 |
% \CharacterTable |
| 463 |
% {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 |
| 464 |
% 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 |
| 465 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 466 |
% Exclamation \! Double quote \" Hash (number) \# |
| 467 |
% Dollar \$ Percent \% Ampersand \& |
| 468 |
% Acute accent \' Left paren \( Right paren \) |
| 469 |
% Asterisk \* Plus \+ Comma \, |
| 470 |
% Minus \- Point \. Solidus \/ |
| 471 |
% Colon \: Semicolon \; Less than \< |
| 472 |
% Equals \= Greater than \> Question mark \? |
| 473 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 474 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 475 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 476 |
% Right brace \} Tilde \~} |
| 477 |
% |
| 478 |
% \changes{v1.0}{2024/10/02}{New maintainer. Starting rewriting} |
| 479 |
% \changes{v0.5}{2020/05/24}{Finished initial testing: Replaced hyperref with hypdoc to avoid makeindex bug.} |
| 480 |
% \changes{v0.4}{2020/05/19}{Completed documentation: 1) Updated note on bug in biber when processing sgml.bib; 2) Removed sgml.bib as example until problems are resolved; 3) Backtracked on attempt to use the monographic title for articles, chapters, etc; 4) Revised notes on production.} |
| 481 |
% \changes{v0.3}{2020/05/14}{Finished first pass on documentation: 1) Done preliminary testing; 2) Script adapted for Mac OS X.} |
| 482 |
% \changes{v0.2}{2020/05/12}{Started documentation: Code doc done, user doc still missing.} |
| 483 |
% \changes{v0.1}{2020/05/7}{First packaged draft: Done manually from .tex file.} |
| 484 |
% |
| 485 |
% \GetFileInfo{bookshelf.dtx} |
| 486 |
% |
| 487 |
% \DoNotIndex{\@,\@@par,\@beginparpenalty,\@empty} |
| 488 |
% \DoNotIndex{\@flushglue,\@gobble,\@input,\@makefnmark} |
| 489 |
% \DoNotIndex{\@makeother,\@maketitle,\@namedef,\@ne} |
| 490 |
% \DoNotIndex{\@spaces,\@tempa,\@tempb,\@tempswafalse} |
| 491 |
% \DoNotIndex{\@tempswatrue,\@thanks,\@thefnmark,\@topnum} |
| 492 |
% \DoNotIndex{\@@,\@elt,\@forloop,\@fortmp,\@gtempa} |
| 493 |
% \DoNotIndex{\@totalleftmargin,\",\/,\@ifundefined,\@nil} |
| 494 |
% \DoNotIndex{\@verbatim,\@vobeyspaces,\|,\~,\ ,\active} |
| 495 |
% \DoNotIndex{\advance,\aftergroup,\begingroup,\bgroup} |
| 496 |
% \DoNotIndex{\mathcal,\csname,\def,\documentstyle} |
| 497 |
% \DoNotIndex{\dospecials,\edef,\egroup,\else,\endcsname} |
| 498 |
% \DoNotIndex{\endgroup,\endinput,\endtrivlist} |
| 499 |
% \DoNotIndex{\expandafter,\fi,\fnsymbol,\futurelet,\gdef} |
| 500 |
% \DoNotIndex{\global,\hbox,\hss,\if,\if@inlabel} |
| 501 |
% \DoNotIndex{\if@tempswa,\if@twocolumn,\ifcase,\ifcat} |
| 502 |
% \DoNotIndex{\iffalse,\ifx,\ignorespaces,\index,\input} |
| 503 |
% \DoNotIndex{\item,\jobname,\kern,\leavevmode,\leftskip} |
| 504 |
% \DoNotIndex{\let,\llap,\lower,\m@ne,\next,\newpage} |
| 505 |
% \DoNotIndex{\nobreak,\noexpand,\nonfrenchspacing} |
| 506 |
% \DoNotIndex{\obeylines,\or,\protect,\raggedleft} |
| 507 |
% \DoNotIndex{\rightskip,\rm,\sc,\setbox,\setcounter} |
| 508 |
% \DoNotIndex{\small,\space,\string,\strut,\strutbox} |
| 509 |
% \DoNotIndex{\thefootnote,\thispagestyle,\topmargin} |
| 510 |
% \DoNotIndex{\trivlist,\tt,\twocolumn,\typeout,\vss,\vtop} |
| 511 |
% \DoNotIndex{\xdef,\z@,\,,\@bsphack,\@esphack,\@noligs} |
| 512 |
% \DoNotIndex{\@vobeyspaces,\@xverbatim,\`,\catcode,\end} |
| 513 |
% \DoNotIndex{\escapechar,\frenchspacing,\glossary} |
| 514 |
% \DoNotIndex{\hangindent,\hfil,\hfill,\hskip,\hspace,\ht} |
| 515 |
% \DoNotIndex{\it,\langle,\leaders,\long,\makelabel} |
| 516 |
% \DoNotIndex{\marginpar,\markboth,\mathcode,\mathsurround} |
| 517 |
% \DoNotIndex{\mbox,\newcount,\newdimen,\newskip} |
| 518 |
% \DoNotIndex{\nopagebreak,\parfillskip,\parindent} |
| 519 |
% \DoNotIndex{\parskip,\penalty,\raise,\rangle,\section} |
| 520 |
% \DoNotIndex{\setlength,\TeX,\topsep,\underline,\unskip} |
| 521 |
% \DoNotIndex{\verb,\vskip,\vspace,\widetilde,\\,\%,\@date} |
| 522 |
% \DoNotIndex{\@defpar,\[,\{,\},\],\count@,\ifnum,\loop} |
| 523 |
% \DoNotIndex{\today,\uppercase,\uccode,\baselineskip} |
| 524 |
% \DoNotIndex{\begin,\tw@,\a,\b,\c,\d,\e,\f,\g,\h,\i,\j,\k} |
| 525 |
% \DoNotIndex{\l,\m,\n,\o,\p,\q,\r,\s,\t,\u,\v,\w,\x,\y,\z} |
| 526 |
% \DoNotIndex{\A,\B,\C,\D,\E,\F,\G,\H,\I,\J,\K,\L,\M,\N,\O} |
| 527 |
% \DoNotIndex{\P,\Q,\R,\S,\T,\U,\V,\W,\X,\Y,\Z,\1,\2,\3,\4} |
| 528 |
% \DoNotIndex{\5,\6,\7,\8,\9,\0,\!,\#,\$,\&,\',\(,\)} |
| 529 |
% \DoNotIndex{\+,\.,\:,\;,\<,\=,\>,\?,\_,\discretionary} |
| 530 |
% \DoNotIndex{\immediate,\makeatletter,\makeatother} |
| 531 |
% \DoNotIndex{\meaning,\newenvironment,\par,\relax} |
| 532 |
% \DoNotIndex{\renewenvironment,\repeat,\scriptsize} |
| 533 |
% \DoNotIndex{\selectfont,\the,\undefined,\arabic,\do} |
| 534 |
% \DoNotIndex{\makeindex,\null,\number,\show,\write,\@ehc} |
| 535 |
% \DoNotIndex{\@author,\@ehc,\@ifstar,\@sanitize,\@title} |
| 536 |
% \DoNotIndex{\everypar,\if@minipage,\if@restonecol,\ifeof} |
| 537 |
% \DoNotIndex{\ifmmode,\lccode,\newtoks,\onecolumn,\openin} |
| 538 |
% \DoNotIndex{\p@,\SelfDocumenting,\settowidth} |
| 539 |
% \DoNotIndex{\@resetonecoltrue,\@resetonecolfalse,\bf} |
| 540 |
% \DoNotIndex{\clearpage,\closein,\lowercase,\@tempdima} |
| 541 |
% \DoNotIndex{\@inlabelfalse,\selectfont,\mathcode} |
| 542 |
% \DoNotIndex{\newmathalphabet,\rmdefault,\bfdefault} |
| 543 |
% \DoNotIndex{\DeclareRobustCommand,\@ifpackagewith} |
| 544 |
% \DoNotIndex{\SIL@doctype} |
| 545 |
% \DoNotIndex{\SIL@docname} |
| 546 |
% \DoNotIndex{\SIL@docowner} |
| 547 |
% \DoNotIndex{\SIL@svgcolname} |
| 548 |
% \DoNotIndex{\ifcase} |
| 549 |
% \DoNotIndex{\SIL@svgcolval} |
| 550 |
% \DoNotIndex{\addbibresource} |
| 551 |
% \DoNotIndex{\immediate} |
| 552 |
% \DoNotIndex{\input} |
| 553 |
% \DoNotIndex{\documentclass} |
| 554 |
% \DoNotIndex{\pagewidth} |
| 555 |
% \DoNotIndex{\raggedright} |
| 556 |
% \DoNotIndex{\name} |
| 557 |
% \DoNotIndex{\SIL@topauthor} |
| 558 |
% \DoNotIndex{\SIL@titleoneline} |
| 559 |
% \DoNotIndex{\makebook} |
| 560 |
% \DoNotIndex{\SILmfont} |
| 561 |
% \DoNotIndex{\SILmfontname} |
| 562 |
% \DoNotIndex{\vbox} |
| 563 |
% \DoNotIndex{\fcolorbox} |
| 564 |
% \DoNotIndex{\scalebox} |
| 565 |
% \setcounter{tocdepth}{5} |
| 566 |
% \setcounter{secnumdepth}{5} |
| 567 |
% \makeatletter |
| 568 |
% \makeatother |
| 569 |
% |
| 570 |
% \GetFileInfo{bookshelf.dtx} |
| 571 |
% \title{The \textsf{bookshelf} document class\thanks{% |
| 572 |
% This document corresponds to \textsf{bookshelf} |
| 573 |
% \fileversion, dated \filedate.} |
| 574 |
% \\[1em]\Large |
| 575 |
% Turn your bibliography into a bookshelf image} |
| 576 |
% \author{Peter Flynn\\\normalsize Silmaril |
| 577 |
% Consultants\\[-.25ex]\normalsize Instant Textual Gratification |
| 578 |
% Division\\\normalsize(\url{[email protected]})\\ |
| 579 |
% Boris Veytsman\\\normalsize(\url{[email protected]})} |
| 580 |
% \maketitle |
| 581 |
% \renewcommand{\abstractname}{Summary}\thispagestyle{empty} |
| 582 |
% \begin{abstract} |
| 583 |
% \parskip=0.5\baselineskip |
| 584 |
% \advance\parskip by 0pt plus 2pt |
| 585 |
% \parindent=0pt% \noindent |
| 586 |
% The \textsf{bookshelf} package uses |
| 587 |
% your \BibTeX{} |
| 588 |
% bibliography file into a randomly-coloured, randomly-sized |
| 589 |
% shelf of books, with the title and author in a randomly-chosen |
| 590 |
% typeface. The image (converted to {\smaller JPEG} from |
| 591 |
% {\smaller PDF}) can then be used as a background in |
| 592 |
% \emph{Zoom}, |
| 593 |
% \emph{Teams}, |
| 594 |
% \emph{WhatsApp} etc video calls. It |
| 595 |
% requires a little preliminary work with the supplied scripts to |
| 596 |
% set up a list of your fonts and their stylistic variants, |
| 597 |
% but otherwise should work on any modern \TeX{} |
| 598 |
% distribution.\par |
| 599 |
% \par\centering\includegraphics[width=.55\columnwidth, page=4]{spines.pdf} |
| 600 |
% \end{abstract} |
| 601 |
% \clearpage |
| 602 |
% \tableofcontents |
| 603 |
% \subsection*{Note on required and optional features} |
| 604 |
% In this document, the keywords |
| 605 |
% {\sffamily {\smaller MUST}}, {\sffamily {\smaller MUST NOT}}, {\sffamily {\smaller REQUIRED}}, |
| 606 |
% {\sffamily {\smaller SHALL}}, {\sffamily {\smaller SHALL NOT}}, {\sffamily {\smaller SHOULD}}, |
| 607 |
% {\sffamily {\smaller SHOULD NOT}}, |
| 608 |
% {\sffamily {\smaller RECOMMENDED}}, |
| 609 |
% {\sffamily {\smaller MAY}}, and |
| 610 |
% {\sffamily {\smaller OPTIONAL}} have a specific |
| 611 |
% meaning when shown in {\sffamily {\smaller THIS TYPESTYLE}}, and |
| 612 |
% {\sffamily {\smaller MUST}} be interpreted as described in |
| 613 |
% RFC 2119 \parencite{rfc2119}.\par |
| 614 |
% When shown in normal type, these words keep their conventional |
| 615 |
% contextual degree of meaning.\par |
| 616 |
% \clearpage |
| 617 |
% \section*{Foreword by BV} |
| 618 |
% \addcontentsline{toc}{section}{Foreword by BV} |
| 619 |
% I have spent many hours admiring colorful bookcases produced by |
| 620 |
% Peter Flynn's \emph{bookshelf} package. They helped me to survive |
| 621 |
% many boring remote meetings during the {\smaller COVID} pandemic and its |
| 622 |
% aftermath. However, since my library had books in different |
| 623 |
% languages, I wanted to showcase them as well. I started to write |
| 624 |
% patches for the package, and at some point Peter kindly decided to |
| 625 |
% transfer the maintenance to me. |
| 626 |
% |
| 627 |
% I described the project at {\smaller |
| 628 |
% TUG}~2024~\parencite{Bookshelf2024}. At present the following |
| 629 |
% changes has been implemented: |
| 630 |
% \begin{enumerate} |
| 631 |
% \item The package now can typeset book spines in any language. It |
| 632 |
% automatically selects a random font capable to typeset a given |
| 633 |
% spine. |
| 634 |
% \item The new |bookshelf-listallfonts| script lists all system and \TeX\ |
| 635 |
% fonts with ``interesting'' variants, while the new |bookshelf-mkfontsel| |
| 636 |
% script populates the |fontsel| directory. |
| 637 |
% \item The package now understands fonts in OTF, TTF |
| 638 |
% \item The switch from Biber to Bib\TeX\ made the processing much |
| 639 |
% faster, and eliminated the need for the separate |entries.tex| file: |
| 640 |
% now the |.bbl| file has the right format. |
| 641 |
% \item The switch from \emph{fontspec} to primitive font loading also |
| 642 |
% made the processing faster---and increased the number of fonts we |
| 643 |
% can display. |
| 644 |
% \end{enumerate} |
| 645 |
% |
| 646 |
% There is, however, a price for these improvements: now the package |
| 647 |
% is Lua\LaTeX-only. |
| 648 |
% |
| 649 |
% \bigskip |
| 650 |
% \emph{Boris Veytsman, October 2024} |
| 651 |
% \clearpage |
| 652 |
% \addcontentsline{toc}{section}{Latest changes} |
| 653 |
% \section*{Latest changes} |
| 654 |
% \subsection*{v.1.0(2025/10/02)} |
| 655 |
% New maintainer. Several rewrites. |
| 656 |
% \subsection*{v.0.5 (2020-05-24)} |
| 657 |
% \paragraph*{Finished initial testing} |
| 658 |
% \begin{itemize} |
| 659 |
% \item Replaced \textsf{hyperref} |
| 660 |
% with \textsf{hypdoc} to avoid |
| 661 |
% \emph{makeindex} bug\par |
| 662 |
% \end{itemize} |
| 663 |
% \subsection*{v.0.1 (2020-05-7)} |
| 664 |
% \paragraph*{First packaged draft} |
| 665 |
% \begin{itemize} |
| 666 |
% \item Done manually from .tex file\par |
| 667 |
% \end{itemize} |
| 668 |
% \subsection*{v.0.4 (2020-05-19)} |
| 669 |
% \paragraph*{Completed documentation} |
| 670 |
% \begin{itemize} |
| 671 |
% \item Updated note on bug in |
| 672 |
% \emph{biber} when processing |
| 673 |
% {\ttfamily{}sgml.bib}\par |
| 674 |
% \item Removed {\ttfamily{}sgml.bib} as example |
| 675 |
% until problems are resolved\par |
| 676 |
% \item Backtracked on attempt to use the monographic |
| 677 |
% title for articles, chapters, etc\par |
| 678 |
% \item Revised notes on production\par |
| 679 |
% \end{itemize} |
| 680 |
% \subsection*{v.0.3 (2020-05-14)} |
| 681 |
% \paragraph*{Finished first pass on documentation} |
| 682 |
% \begin{itemize} |
| 683 |
% \item Done preliminary testing\par |
| 684 |
% \item Script adapted for Mac OS X\par |
| 685 |
% \end{itemize} |
| 686 |
% \subsection*{Acknowledgments} |
| 687 |
% Thanks to many people for the original |
| 688 |
% suggestion; and to Isabel Yorke, Bethan Tovey-Walsh, |
| 689 |
% Nelson Beebe, The \LaTeX{} Ninja, Stephan Lukasczyk, |
| 690 |
% and others for their thesis bibliographies and |
| 691 |
% testing comments.\par |
| 692 |
% \clearpage |
| 693 |
% \section{Documentation} |
| 694 |
% During the era of the {\smaller COVID-19} lockdown, the popularity |
| 695 |
% of group video messaging grew rapidly, both for business and |
| 696 |
% domestic use. As people sought for what they believed to be more |
| 697 |
% representative backgrounds than a messy kitchen, an untidy workroom, |
| 698 |
% or a sterile blank wall, a well-populated bookshelf was a frequent |
| 699 |
% choice.\par |
| 700 |
% This package is for those who cannot use (or don't have, or don't |
| 701 |
% want to use) such a bookshelf, but can still lay their hands on a |
| 702 |
% bibliography or reference list in \BibTeX{} format — perhaps from a |
| 703 |
% recent or long-forgotten thesis, book, article, or other |
| 704 |
% document.\par |
| 705 |
% You also may want to showcase your electronic library. Many |
| 706 |
% programs like \emph{Calibre}~\parencite{Calibre} can export the list |
| 707 |
% of your electronic books in Bib\TeX\ format. This is how the sample |
| 708 |
% library |spines.pdf| was created.\par |
| 709 |
% Another important use of this package is to provide a diversion |
| 710 |
% during long boring remote meetings. Try to guess the font the given |
| 711 |
% spine was typeset with---and use these tiny numbers under the books |
| 712 |
% to check your knowledge! |
| 713 |
% \par\begingroup |
| 714 |
% \fboxsep1em\centering |
| 715 |
% \fbox{\begin{minipage}{0.8\columnwidth}\sffamily |
| 716 |
% \raggedright\parindent0pt |
| 717 |
% \parskip=.5\baselineskip |
| 718 |
% \subsubsection*{\sffamily Lua\LaTeX{}} |
| 719 |
% To avoid problems with accented |
| 720 |
% characters, and to make it easier to maintain, |
| 721 |
% this document class uses only Lua\LaTeX.\par |
| 722 |
% It will not work with the |
| 723 |
% \emph{pdflatex} or \XeTeX.\par |
| 724 |
% \end{minipage}}\par\endgroup |
| 725 |
% This is a work-in-progress: there are bugs (see \vref{bugs}).\par |
| 726 |
% \subsection{What the package does} |
| 727 |
% The \textsf{bookshelf} package |
| 728 |
% generates what looks like shelves of book spines |
| 729 |
% from your list of references, using random |
| 730 |
% dimensions (within specified limits) in random but |
| 731 |
% contrasting colors, with a randomly-selected |
| 732 |
% typeface.\par |
| 733 |
% It does this by creating a box (rectangle) for each |
| 734 |
% entry in your list, assigning colors to the background and |
| 735 |
% foreground, deciding on the layout and font, and then |
| 736 |
% stacking the boxes side-by-side as if they were letters on a |
| 737 |
% line.\par |
| 738 |
% \subsection{Preparation} |
| 739 |
% To get things ready for this, you need to install this |
| 740 |
% document class, and provide the following data: |
| 741 |
% \begin{enumerate} |
| 742 |
% \item The list of book as a \BibTeX{} file. |
| 743 |
% \item A list of all your usable text fonts and the total number of |
| 744 |
% them. |
| 745 |
% \item A list of all the colors to choose from. |
| 746 |
% \end{enumerate} |
| 747 |
% These are explained in more detail in the subsections |
| 748 |
% below.\par |
| 749 |
% \subsubsection{Your \BibTeX{} file} |
| 750 |
% Your \BibTeX{} ({\ttfamily{}.bib}) file, |
| 751 |
% suitable for use with \emph{biber} |
| 752 |
% rather than \emph{bibtex}.\par |
| 753 |
% You may need to replace all the |
| 754 |
% old-style symbolic notation accented characters like |
| 755 |
% \verb|{\"a}| for |
| 756 |
% `ä' and |
| 757 |
% \verb|{\l}| for |
| 758 |
% `ł'. \par |
| 759 |
% If you have a bibliography in |
| 760 |
% \emph{EndNote}, |
| 761 |
% \emph{Mendeley}, |
| 762 |
% \emph{Zotero}, |
| 763 |
% \emph{ProCite}, |
| 764 |
% \emph{Reference Manager}, |
| 765 |
% etc, you should be able to export it in either |
| 766 |
% \BibTeX{} or {\smaller RIS} format. A |
| 767 |
% {\smaller RIS} file can easily be |
| 768 |
% converted to \BibTeX{} by opening it in |
| 769 |
% \emph{JabRef} and saving it |
| 770 |
% as \BibTeX{}.\par |
| 771 |
% \subsubsection{Font file list}\label{fontfiles} |
| 772 |
% A set of 2–line files in a subdirectory called |
| 773 |
% |fontsel| representing of all the |
| 774 |
% usable text fonts on your system.\par |
| 775 |
% Each file {\sffamily {\smaller MUST}} be |
| 776 |
% numbered sequentially in its name (eg |
| 777 |
% {\ttfamily{}1.tex}, {\ttfamily{}2.tex}, |
| 778 |
% {\ttfamily{}3.tex}, etc) and |
| 779 |
% {\sffamily {\smaller MUST}} contain a |\font| command and define |
| 780 |
% the name of the font, for example |
| 781 |
% \begin{verbatim} |
| 782 |
% \font\SILmfont={[/usr/local/texlive/2024/texmf-dist/fonts/opentype/public/junicode/Junicode-SmCondMediumItalic.otf]:+clig;+liga;+tlig;+swsh}\SILmfont |
| 783 |
% \def\SILmfontname{Junicode SmCond Medium Italic; Swash}% |
| 784 |
% \end{verbatim} |
| 785 |
% This list can be created using the scripts |bookshelf-listallfonts| and |
| 786 |
% |bookshelf-mkfontsel|, see~\vref{sec:scripts}. |
| 787 |
% \subsubsection{Maximum number of fonts} |
| 788 |
% A file called {\ttfamily{}pickfont.tex} |
| 789 |
% containing a |
| 790 |
% \verb|\setcounter{SIL@maxfont}{...}| command to |
| 791 |
% set the total number of the fonts which are represented in |
| 792 |
% the {\ttfamily{}fontsel} subdirectory above\par |
| 793 |
% This file can be created using the scripts |bookshelf-listallfonts| and |
| 794 |
% |bookshelf-mkfontsel|, see~\vref{sec:scripts}. |
| 795 |
% \subsubsection{List of colors} |
| 796 |
% A list of all the colors represented by the |
| 797 |
% {\smaller SVG} palette used by the |
| 798 |
% \textsf{xcolor} package: the file is called |
| 799 |
% called {\ttfamily{}bookshelf-svgnam.tex}. |
| 800 |
% This contains three definitions:\par |
| 801 |
% \begin{enumerate} |
| 802 |
% \item the command {\ttfamily{}\textbackslash{}SIL@svgcolname} |
| 803 |
% which uses an {\ttfamily{}\textbackslash{}ifcase} command to |
| 804 |
% return the name of the \emph{n}th color |
| 805 |
% in alphabetical order;\par |
| 806 |
% \item the command {\ttfamily{}\textbackslash{}SIL@svgcolval} which |
| 807 |
% does the same to return the brightness value of that |
| 808 |
% color, computed by the formula on \vpageref{bright} (see script for |
| 809 |
% details);\par |
| 810 |
% \item the counter {\ttfamily{}SIL@maxcolno} which holds |
| 811 |
% the number of colors available.\par |
| 812 |
% \end{enumerate} |
| 813 |
% This file is included in the distribution. |
| 814 |
% |
| 815 |
% In the previous versions of the ditribution it was created with the |
| 816 |
% from |svgnam.def| database. The script |svgnam.sh| is retained in |
| 817 |
% the distribution and can be used to recreate the file. |
| 818 |
% |
| 819 |
% \subsection{Producing your bookshelf} |
| 820 |
% |
| 821 |
% \subsubsection{Producing the list of fonts} |
| 822 |
% \label{sec:scripts} |
| 823 |
% |
| 824 |
% Each system has its own fonts installed, so you need to create the |
| 825 |
% list of fonts installed on \emph{your} system. It is done in three |
| 826 |
% steps. |
| 827 |
% \begin{enumerate} |
| 828 |
% \item Update the database of fonts known to Lua\TeX: |
| 829 |
% \begin{verbatim} |
| 830 |
% luaotfload-tool --update --force |
| 831 |
% \end{verbatim} |
| 832 |
% The key |--force| forces the update even if Lua\TeX\ thinks it is |
| 833 |
% not necessary: sometimes it is mistaken. |
| 834 |
% \item Create the list of the usable fonts and font variants: |
| 835 |
% \begin{verbatim} |
| 836 |
% bookshelf-listallfonts [options] > allfonts |
| 837 |
% \end{verbatim} |
| 838 |
% The script lists all fonts in {\smaller OTF, TTF} or {\smaller TTC} |
| 839 |
% format, known to Lua\LaTeX. For scripts in {\smaller OTF} and |
| 840 |
% {\smaller TTF} format it looks at the ``interesting'' Open Type |
| 841 |
% features like swash and stylistic variant and lists them too. This |
| 842 |
% means that the bookshelf might have spines typeset in the different |
| 843 |
% variants of the same font---they are considered different fonts! |
| 844 |
% You can change the list of feaures using the key |-f FEATURES_FILE|; |
| 845 |
% see the |doc| directory for an example. The script tries to exclude |
| 846 |
% broken font files; you can change the list with the key |
| 847 |
% |-x EXCLUDED_PATTERNS|. Again, there is an example in the |doc| |
| 848 |
% directory. |
| 849 |
% \item Create the |fontsel| directory and the file |pickfont.tex| |
| 850 |
% using the command |
| 851 |
% \begin{verbatim} |
| 852 |
% bookshelf-mkfontsel allfonts |
| 853 |
% \end{verbatim} |
| 854 |
% \end{enumerate} |
| 855 |
% |
| 856 |
% \subsubsection{Driver file} |
| 857 |
% |
| 858 |
% The distribution contains the file |spines.tex| |
| 859 |
% \begin{verbatim} |
| 860 |
% % !TEX TS-program = lualatex |
| 861 |
% % !TEX encoding = UTF-8 Unicode |
| 862 |
% % !BIB TS-program = bibtex |
| 863 |
% \documentclass[landscape]{bookshelf} |
| 864 |
% \begin{document} |
| 865 |
% \nocite{*} |
| 866 |
% \bibliography{sample} |
| 867 |
% \bibliographystyle{bookshelf} |
| 868 |
% \end{document} |
| 869 |
% \end{verbatim} |
| 870 |
% |
| 871 |
% Change |sample| to the name of your bibliography, and typeset the |
| 872 |
% file using |lualatex| and | bibtex|. |
| 873 |
% |
| 874 |
% You should see your books nicely placed on the shelves. The small |
| 875 |
% numbers under each book are meaningful: they are the line numbers in |
| 876 |
% the |allfonts| file. You may use them if you play ``Guess the |
| 877 |
% font'' game. |
| 878 |
% |
| 879 |
% \subsubsection{Options} |
| 880 |
% The class comes set for making an |
| 881 |
% \textbf{\texttt{a0paper}} page (1189 mm × 841 mm |
| 882 |
% or 4′ 11″ × 2′ 10″) in |
| 883 |
% \textbf{\texttt{landscape}} mode, suitable for |
| 884 |
% large bibliographies. If you have a smaller |
| 885 |
% {\ttfamily{}.bib} file, or if you want |
| 886 |
% fewer volumes per page, you can change the paper |
| 887 |
% size option in the |
| 888 |
% {\ttfamily{}\textbackslash{}documentclass} command to a |
| 889 |
% smaller one: all the `A' |
| 890 |
% sizes from 5 to 0 are supported, plus the common |
| 891 |
% US office sizes including Ledger (Tabloid).\par |
| 892 |
% There is also a \textbf{\texttt{portrait}} option to |
| 893 |
% produce the page in that format instead of |
| 894 |
% landscape.\par |
| 895 |
% |
| 896 |
% \subsection{Bugs}\label{bugs} |
| 897 |
% Some things don't yet work as they should, and |
| 898 |
% there are some features that may or may not make |
| 899 |
% the final cut. Please report bugs at |
| 900 |
% \url{https://github.com/borisveytsman/bookshelf}\par |
| 901 |
% |
| 902 |
% |
| 903 |
% \StopEventually{\label{endcode}% |
| 904 |
% \clearpage |
| 905 |
% \newgeometry{left=3cm}% |
| 906 |
% \addcontentsline{toc}{section}{Change History}% |
| 907 |
% \label{changehistory}% |
| 908 |
% \PrintChanges |
| 909 |
% \clearpage |
| 910 |
% \label{codeindex}% |
| 911 |
% \addcontentsline{toc}{section}{Index}% |
| 912 |
% \PrintIndex} |
| 913 |
% \addtolength{\CPKrevmarg}{\widthof{\LabelFont{AddToShipoutPictureBG}}} |
| 914 |
% \newgeometry{left=\CPKrevmarg} |
| 915 |
% \message{Margin reset to \the\CPKrevmarg, to fit <AddToShipoutPictureBG>} |
| 916 |
% \iffalse |
| 917 |
%<*class> |
| 918 |
% \fi |
| 919 |
% \clearpage |
| 920 |
% \section{Implementation}\label{setup} |
| 921 |
% \par |
| 922 |
% \subsection{Auto-initialisation}\label{setup:autoinit} |
| 923 |
% This section is added automatically by \textit{ClassPack} |
| 924 |
% as a preamble to all classes and style packages. |
| 925 |
% The \textsf{fixltx2e} package, which used to be included |
| 926 |
% automatically, is no longer preloaded, as its |
| 927 |
% features are now a part of the latest \LaTeXe\ kernel.\par |
| 928 |
% The code starts with identity and requirements which are |
| 929 |
% generated automatically as needed by the Doc\TeX\ system. |
| 930 |
% For details see the \textsf{ltxdoc} package documentation. |
| 931 |
% \par\smallskip |
| 932 |
% \begingroup\color{DarkRed}\footnotesize |
| 933 |
% \leavevmode\enspace{\scriptsize1}\quad{\ttfamily\textbackslash NeedsTeXFormat\{LaTeX2e\}[2017/04/15]}\\ |
| 934 |
% \leavevmode\enspace{\scriptsize2}\quad{\ttfamily\textbackslash ProvidesClass\{bookshelf\}[2020/05/24 v0.5}\\ |
| 935 |
% \leavevmode\enspace{\scriptsize3}\qquad{\ttfamily Turn your bibliography into a bookshelf image]}\\\endgroup |
| 936 |
% \setcounter{CodelineNo}{3} |
| 937 |
% \begin{CPK@package}{fix-cm} |
| 938 |
% Preloaded functions to override the default \LaTeX\ |
| 939 |
% step-size font sizes (which can still be used, |
| 940 |
% but are no longer restrictions).\par |
| 941 |
% \begin{macrocode} |
| 942 |
\RequirePackage{fix-cm} |
| 943 |
% \end{macrocode} |
| 944 |
% \end{CPK@package} |
| 945 |
% \begin{CPK@option}{svgnames} |
| 946 |
% Pass the \textbf{\texttt{svgnames}} option to the |
| 947 |
% \textsf{xcolor} package if that gets loaded later. |
| 948 |
% This avoids a conflict with any other packages |
| 949 |
% (eg \textsf{hyperref}) which use their own default |
| 950 |
% is when they load \textsf{xcolor}.\par |
| 951 |
% \begin{macrocode} |
| 952 |
\PassOptionsToPackage{svgnames}{xcolor} |
| 953 |
% \end{macrocode} |
| 954 |
% \end{CPK@option} |
| 955 |
% \subsection{Options}\label{options} |
| 956 |
% \iffalse |
| 957 |
%% |
| 958 |
%% ****************************************************************** |
| 959 |
%% |
| 960 |
%% Options |
| 961 |
% \fi |
| 962 |
% The paper size and orientation are the only two valid |
| 963 |
% options, both of which are the same as the standard |
| 964 |
% documentclass options, and will be passed to the underlying |
| 965 |
% class automatically, but they need recording so that they |
| 966 |
% can be used by the \textsf{geometry} |
| 967 |
% package. The default is for A0 paper, landscape.\par |
| 968 |
% \begin{macrocode} |
| 969 |
\def\SIL@paper{a0paper}% |
| 970 |
\DeclareOption{a0paper}{% |
| 971 |
\def\SIL@paper{a0paper}% |
| 972 |
\setlength\paperheight {1189mm}% |
| 973 |
\setlength\paperwidth {841mm}} |
| 974 |
\DeclareOption{a1paper}{% |
| 975 |
\def\SIL@paper{a1paper}% |
| 976 |
\setlength\paperheight {841mm}% |
| 977 |
\setlength\paperwidth {594mm}} |
| 978 |
\DeclareOption{a2paper}{% |
| 979 |
\def\SIL@paper{a2paper}% |
| 980 |
\setlength\paperheight {594mm}% |
| 981 |
\setlength\paperwidth {420mm}} |
| 982 |
\DeclareOption{a3paper}{% |
| 983 |
\def\SIL@paper{a3paper}% |
| 984 |
\setlength\paperheight {420mm}% |
| 985 |
\setlength\paperwidth {297mm}} |
| 986 |
\DeclareOption{a4paper}{% |
| 987 |
\def\SIL@paper{a4paper}% |
| 988 |
\setlength\paperheight {297mm}% |
| 989 |
\setlength\paperwidth {210mm}} |
| 990 |
\DeclareOption{a5paper}{% |
| 991 |
\def\SIL@paper{a5paper}% |
| 992 |
\setlength\paperheight {210mm}% |
| 993 |
\setlength\paperwidth {148mm}} |
| 994 |
\DeclareOption{b5paper}{% |
| 995 |
\def\SIL@paper{b5paper}% |
| 996 |
\setlength\paperheight {250mm}% |
| 997 |
\setlength\paperwidth {176mm}} |
| 998 |
\DeclareOption{letterpaper}{% |
| 999 |
\def\SIL@paper{letterpaper}% |
| 1000 |
\setlength\paperheight {11in}% |
| 1001 |
\setlength\paperwidth {8.5in}} |
| 1002 |
\DeclareOption{legalpaper}{% |
| 1003 |
\def\SIL@paper{legalpaper}% |
| 1004 |
\setlength\paperheight {14in}% |
| 1005 |
\setlength\paperwidth {8.5in}} |
| 1006 |
\DeclareOption{executivepaper}{% |
| 1007 |
\def\SIL@paper{executivepaper}% |
| 1008 |
\setlength\paperheight {10.5in}% |
| 1009 |
\setlength\paperwidth {7.25in}} |
| 1010 |
\DeclareOption{ledgerpaper}{% |
| 1011 |
\def\SIL@paper{ledgerpaper}% |
| 1012 |
\setlength\paperheight {17in}% |
| 1013 |
\setlength\paperwidth {11in}} |
| 1014 |
\DeclareOption{tabloidpaper}{% |
| 1015 |
\def\SIL@paper{tabloidpaper}% |
| 1016 |
\setlength\paperheight {17in}% |
| 1017 |
\setlength\paperwidth {11in}} |
| 1018 |
\def\SIL@orient{landscape}% |
| 1019 |
\DeclareOption{landscape}{% |
| 1020 |
\def\SIL@orient{landscape}% |
| 1021 |
\setlength\@tempdima {\paperheight}% |
| 1022 |
\setlength\paperheight {\paperwidth}% |
| 1023 |
\setlength\paperwidth {\@tempdima}} |
| 1024 |
\DeclareOption{portrait}{% |
| 1025 |
\def\SIL@orient{}} |
| 1026 |
% \end{macrocode} |
| 1027 |
% \subsection{Load the document base class}\label{classload} |
| 1028 |
% \iffalse |
| 1029 |
%% |
| 1030 |
%% ****************************************************************** |
| 1031 |
%% |
| 1032 |
%% Load the document base class |
| 1033 |
% \fi |
| 1034 |
% This class is based on the standard \LaTeX{} |
| 1035 |
% \DescribeClass{report}\textsf{report} class, with no special options |
| 1036 |
% except the extra sizes defined above. The default is A0 |
| 1037 |
% paper, landscape.\par |
| 1038 |
% \begin{macrocode} |
| 1039 |
\DeclareOption*{\ClassWarning{bookshelf}{% |
| 1040 |
Unknown option `\CurrentOption', please RTFM}} |
| 1041 |
\ProcessOptions\relax |
| 1042 |
\LoadClass{report} |
| 1043 |
% \end{macrocode} |
| 1044 |
%\iffalse |
| 1045 |
%% |
| 1046 |
%% Packages required for the class or package |
| 1047 |
%% |
| 1048 |
% \fi |
| 1049 |
% \subsection{Packages required for the class or |
| 1050 |
% package}\label{clspackages} |
| 1051 |
% \begin{CPK@package}{fontspec} |
| 1052 |
% Font specification setup for use with \XeLaTeX{}. |
| 1053 |
% \iffalse |
| 1054 |
%% Font specification setup for use with \XeLaTeX{}. |
| 1055 |
% \fi |
| 1056 |
% \begin{macrocode} |
| 1057 |
\RequirePackage{fontspec}% |
| 1058 |
% \end{macrocode} |
| 1059 |
% \end{CPK@package} |
| 1060 |
% \begin{CPK@package}{calc} |
| 1061 |
% Required for calculations involving lengths or counters, |
| 1062 |
% such as changes to widths for margin adjustment. |
| 1063 |
% \iffalse |
| 1064 |
%% Required for calculations involving lengths or counters, such as changes to widths for margin adjustment. |
| 1065 |
% \fi |
| 1066 |
% \begin{macrocode} |
| 1067 |
\RequirePackage{calc}% |
| 1068 |
% \end{macrocode} |
| 1069 |
% \end{CPK@package} |
| 1070 |
% \begin{CPK@package}{fp} |
| 1071 |
% Used for fixed-point calculations; |
| 1072 |
% \iffalse |
| 1073 |
%% Used for fixed-point calculations |
| 1074 |
% \fi |
| 1075 |
% \begin{macrocode} |
| 1076 |
\RequirePackage{fp}% |
| 1077 |
% \end{macrocode} |
| 1078 |
% \end{CPK@package} |
| 1079 |
% \begin{CPK@package}{graphicx} |
| 1080 |
% Provide for graphics (PNG, JPG, or PDF format (only) for |
| 1081 |
% pdflatex; EPS format (only) for standard \LaTeX{}). |
| 1082 |
% \iffalse |
| 1083 |
%% Provide for graphics (PNG, JPG, or PDF format (only) for pdflatex; EPS format (only) for standard \LaTeX{}). |
| 1084 |
% \fi |
| 1085 |
% \begin{macrocode} |
| 1086 |
\RequirePackage{graphicx}% |
| 1087 |
% \end{macrocode} |
| 1088 |
% \end{CPK@package} |
| 1089 |
% \begin{CPK@package}{xcolor} |
| 1090 |
% Provide color. |
| 1091 |
% \iffalse |
| 1092 |
%% Provide color. |
| 1093 |
% \fi |
| 1094 |
% \begin{macrocode} |
| 1095 |
\RequirePackage{xcolor}% |
| 1096 |
\@ifundefined{T}{% |
| 1097 |
\newcommand{\T}[2]{{\fontencoding{T1}% |
| 1098 |
\selectfont#2}}}{} |
| 1099 |
% \end{macrocode} |
| 1100 |
% There seems to be a bug in the T1 encoding of some package |
| 1101 |
% (unidentified, but possibly \textsf{xcolor}) which |
| 1102 |
% uses the command {\ttfamily{}\textbackslash{}T1}, which is an |
| 1103 |
% impossibility (no digits allowed in command names). So we fake |
| 1104 |
% it here to stop \LaTeX{} complaining, by dropping the first |
| 1105 |
% argument on the floor. |
| 1106 |
% \end{CPK@package} |
| 1107 |
% \begin{CPK@package}{eso-pic} |
| 1108 |
% Add picture commands (or backgrounds) to every page. |
| 1109 |
% \iffalse |
| 1110 |
%% Add picture commands (or backgrounds) to every page. |
| 1111 |
% \fi |
| 1112 |
% \begin{macrocode} |
| 1113 |
\RequirePackage{eso-pic}% |
| 1114 |
% \end{macrocode} |
| 1115 |
% \end{CPK@package} |
| 1116 |
% \begin{CPK@package}{geometry} |
| 1117 |
% Package for establishing margins and text area. |
| 1118 |
% \iffalse |
| 1119 |
%% Package for establishing margins and text area. |
| 1120 |
% \fi |
| 1121 |
% \begin{macrocode} |
| 1122 |
\RequirePackage[\SIL@paper,\SIL@orient,nohead, |
| 1123 |
nofoot,margin=1cm]{geometry}% |
| 1124 |
% \end{macrocode} |
| 1125 |
% \end{CPK@package} |
| 1126 |
% |
| 1127 |
% \subsection{Non-package resources} |
| 1128 |
% \iffalse |
| 1129 |
%% |
| 1130 |
%% ****************************************************************** |
| 1131 |
%% |
| 1132 |
%% Non-package resources |
| 1133 |
% \fi |
| 1134 |
% \begin{CPK@file}{random.tex}\label{file--random.tex} |
| 1135 |
% There is one resource not available in packaged form, |
| 1136 |
% the module that lets \LaTeX{} create random values. This is |
| 1137 |
% in {\ttfamily{}random.tex}, which on the author's |
| 1138 |
% system is hiding in a directory |
| 1139 |
% {\ttfamily{}texmf/tex/generic/genmisc/}, in the |
| 1140 |
% {\ttfamily{}texmf-dist} tree, and indexed by an |
| 1141 |
% {\ttfamily{}ls-R} database, so it should therefore |
| 1142 |
% be findable by any \TeX{} system.\par |
| 1143 |
% \begin{macrocode} |
| 1144 |
\input{random.tex} |
| 1145 |
% \end{macrocode} |
| 1146 |
% \end{CPK@file} |
| 1147 |
% \subsection{The code} |
| 1148 |
% \iffalse |
| 1149 |
%% |
| 1150 |
%% ****************************************************************** |
| 1151 |
%% |
| 1152 |
%% The code |
| 1153 |
% \fi |
| 1154 |
% This is beta software: the code is messy and covered in |
| 1155 |
% tracing output.\par |
| 1156 |
% \subsubsection{Font selection}\label{fonts} |
| 1157 |
% \begin{CPK@counter}{maxfont}\label{counter--maxfont} |
| 1158 |
% This is set in the {\ttfamily{}\textbackslash{}input} file |
| 1159 |
% {\ttfamily{}pickfont.tex}, which is created by |
| 1160 |
% the preparatory data script |
| 1161 |
% {\ttfamily{}prepdata.sh}. It is the number of |
| 1162 |
% working text fonts found on the system.\par |
| 1163 |
% \begin{macrocode} |
| 1164 |
\newcounter{SIL@maxfont} |
| 1165 |
% \end{macrocode} |
| 1166 |
% \end{CPK@counter} |
| 1167 |
% \begin{CPK@counter}{SIL@fontsel}\label{counter--SIL@fontsel} |
| 1168 |
% This is set to a random number between one and |
| 1169 |
% \DescribeCounter{SIL@maxfont}{\ttfamily{}SIL@maxfont}, and used as the |
| 1170 |
% name of the file containing the font name.\par |
| 1171 |
% \begin{macrocode} |
| 1172 |
\newcounter{SIL@fontsel} |
| 1173 |
% \end{macrocode} |
| 1174 |
% \end{CPK@counter} |
| 1175 |
% \begin{CPK@file}{pickfont.tex}\label{file--pickfont.tex} |
| 1176 |
% This file is created by the preparatory data script |
| 1177 |
% {\ttfamily{}prepdata.sh} after it sets up the |
| 1178 |
% subdirectory list of valid text fonts. It sets the value |
| 1179 |
% of \DescribeCounter{SIL@maxfont}{\ttfamily{}SIL@maxfont}.\par |
| 1180 |
% \begin{macrocode} |
| 1181 |
\input{pickfont.tex} |
| 1182 |
% \end{macrocode} |
| 1183 |
% \end{CPK@file} |
| 1184 |
% \subsubsection{Color selection}\label{color} |
| 1185 |
% \begin{CPK@counter}{SIL@maxcolno}\label{counter--SIL@maxcolno} |
| 1186 |
% This value is set at the end of the file |
| 1187 |
% {\ttfamily{}bookshelf-svgnam.tex}. This is the number of |
| 1188 |
% color names found by the routine in |
| 1189 |
% {\ttfamily{}prepdata.sh} which extracts the color |
| 1190 |
% names.\par |
| 1191 |
% \begin{macrocode} |
| 1192 |
\newcounter{SIL@maxcolno} |
| 1193 |
% \end{macrocode} |
| 1194 |
% \end{CPK@counter} |
| 1195 |
% \begin{CPK@file}{bookshelf-svgnam.tex}\label{file--bookshelf-svgnam.tex} |
| 1196 |
% The preparatory data script |
| 1197 |
% {\ttfamily{}prepdata.sh} retrieves the colors named |
| 1198 |
% in the \textbf{\texttt{svgnames}} option to the |
| 1199 |
% \textsf{xcolor} package and instantiates them |
| 1200 |
% as a \LaTeX{} {\ttfamily{}\textbackslash{}ifcase} list in the file |
| 1201 |
% {\ttfamily{}bookshelf-svgnam.tex} as the command |
| 1202 |
% {\ttfamily{}\textbackslash{}SIL@svgcolname}.\par |
| 1203 |
% \begin{macrocode} |
| 1204 |
\input{bookshelf-svgnam.tex} |
| 1205 |
% \end{macrocode} |
| 1206 |
% \end{CPK@file} |
| 1207 |
% \begin{CPK@counter}{SIL@loopcount}\label{counter--SIL@loopcount} |
| 1208 |
% The random font selection is done in a loop because |
| 1209 |
% of the need to test the values. This counter counts the |
| 1210 |
% iterations…\par |
| 1211 |
% \begin{macrocode} |
| 1212 |
\newcounter{SIL@loopcount} |
| 1213 |
% \end{macrocode} |
| 1214 |
% \end{CPK@counter} |
| 1215 |
% \begin{CPK@counter}{SIL@maxloop}\label{counter--SIL@maxloop} |
| 1216 |
% …and this one the limit.\par |
| 1217 |
% \begin{macrocode} |
| 1218 |
\newcounter{SIL@maxloop} |
| 1219 |
% \end{macrocode} |
| 1220 |
% \end{CPK@counter} |
| 1221 |
% \begin{CPK@counter}{SIL@bgcolno}\label{counter--SIL@bgcolno} |
| 1222 |
% The colors are selected numerically. This value is |
| 1223 |
% the background color of the spine of a book.\par |
| 1224 |
% \begin{macrocode} |
| 1225 |
\newcounter{SIL@bgcolno} |
| 1226 |
% \end{macrocode} |
| 1227 |
% \end{CPK@counter} |
| 1228 |
% \begin{CPK@counter}{SIL@fgcolno}\label{counter--SIL@fgcolno} |
| 1229 |
% And this is the foreground color, used to typeset |
| 1230 |
% the title and author on the spine of a book.\par |
| 1231 |
% \begin{macrocode} |
| 1232 |
\newcounter{SIL@fgcolno} |
| 1233 |
% \end{macrocode} |
| 1234 |
% \end{CPK@counter} |
| 1235 |
% \begin{CPK@length}{\splitpoint}\label{length--splitpoint} |
| 1236 |
% To make sure that \DescribeCounter{SIL@bgcolno}{\ttfamily{}SIL@bgcolno} and \DescribeCounter{SIL@fgcolno}{\ttfamily{}SIL@fgcolno} |
| 1237 |
% are distinct, we will need to pick one |
| 1238 |
% `dark' and one |
| 1239 |
% `light', crudely distinguished by |
| 1240 |
% examining their `brightness' |
| 1241 |
% (monochrome intensity value) using the formula |
| 1242 |
% \label{bright}\(b=\sqrt(.241r^2+.691g^2+.068b^2)\) due to \href{https://www.nbdtech.com/Blog/archive/2008/04/27/Calculating-the-Perceived-Brightness-of-a-Color.aspx}{Nir |
| 1243 |
% Dobovizki}. From inspection, the modal point of |
| 1244 |
% the {\smaller SVG} values occurs around 0.6, so |
| 1245 |
% use use this to determine if the randomly-selected color |
| 1246 |
% is `dark' or |
| 1247 |
% `light'. Because it's a decimal |
| 1248 |
% fraction, we express it as a dimension and strip off the |
| 1249 |
% `pt' later.\par |
| 1250 |
% \begin{macrocode} |
| 1251 |
\newlength{\SIL@splitpoint} |
| 1252 |
\setlength{\SIL@splitpoint}{0.6pt} |
| 1253 |
% \end{macrocode} |
| 1254 |
% \end{CPK@length} |
| 1255 |
% \begin{CPK@macro}{\SIL@bgcol}\label{macro--SIL@bgcol} |
| 1256 |
% We establish defaults for the background color…\par |
| 1257 |
% \begin{macrocode} |
| 1258 |
\def\SIL@bgcol{White} |
| 1259 |
% \end{macrocode} |
| 1260 |
% \end{CPK@macro} |
| 1261 |
% \begin{CPK@macro}{\SIL@fgcol}\label{macro--SIL@fgcol} |
| 1262 |
% …and the foreground color.\par |
| 1263 |
% \begin{macrocode} |
| 1264 |
\def\SIL@fgcol{Black} |
| 1265 |
% \end{macrocode} |
| 1266 |
% \end{CPK@macro} |
| 1267 |
% \begin{CPK@length}{\SIL@bgval}\label{length--SIL@bgval} |
| 1268 |
% The values computed by the |
| 1269 |
% {\ttfamily{}prepdata.sh} script and stored in |
| 1270 |
% {\ttfamily{}bookshelf-svgnam.tex} are decimal fractions, |
| 1271 |
% to they need to be retrieved as lengths. This is the |
| 1272 |
% background value…\par |
| 1273 |
% \begin{macrocode} |
| 1274 |
\newlength{\SIL@bgval} |
| 1275 |
% \end{macrocode} |
| 1276 |
% \end{CPK@length} |
| 1277 |
% \begin{CPK@length}{\SIL@fgval}\label{length--SIL@fgval} |
| 1278 |
% …and the foreground value.\par |
| 1279 |
% \begin{macrocode} |
| 1280 |
\newlength{\SIL@fgval} |
| 1281 |
% \end{macrocode} |
| 1282 |
% \end{CPK@length} |
| 1283 |
% \begin{CPK@length}{\SIL@bgfgdiff}\label{length--SIL@bgfgdiff} |
| 1284 |
% The `dark' or |
| 1285 |
% `light' test discussed above also |
| 1286 |
% needs to test if the values are too close to the |
| 1287 |
% splitpoint. By examination, if the values have an |
| 1288 |
% absolute difference of 0.2 they should be visually |
| 1289 |
% distinct enough. The difference is calculated and stored |
| 1290 |
% in this length variable, as it's a decimal fraction.\par |
| 1291 |
% \begin{macrocode} |
| 1292 |
\newlength{\SIL@bgfgdiff} |
| 1293 |
% \end{macrocode} |
| 1294 |
% \end{CPK@length} |
| 1295 |
% \begin{CPK@switch}{\SIL@notyetcols}\label{switch--SIL@notyetcols} |
| 1296 |
% In the testing for colors, the nested conditionals |
| 1297 |
% set this switch true or false, so that it can be used to |
| 1298 |
% control the iteration through successive attempts to find |
| 1299 |
% suitable random values.\par |
| 1300 |
% \begin{macrocode} |
| 1301 |
\newif\ifSIL@notyetcols |
| 1302 |
% \end{macrocode} |
| 1303 |
% \end{CPK@switch} |
| 1304 |
% \subsubsection{Page border setup}\label{borders} |
| 1305 |
% \begin{CPK@macro}{\AddToShipoutPictureBG}\label{macro--AddToShipoutPictureBG} |
| 1306 |
% The page background color is set to a pale brown |
| 1307 |
% roughly matching the pine veneer of IKEA bookcases, with |
| 1308 |
% the inner page (behind the books) in a dark shadow |
| 1309 |
% brown. The technique for imposing a colored margin is |
| 1310 |
% due to \href{https://tex.stackexchange.com/questions/7725/how-to-set-a-certain-color-other-than-white-to-margin-areas}{Ulrike |
| 1311 |
% Fischer} and uses the commands from the |
| 1312 |
% \textsf{eso-pic} package.\par |
| 1313 |
% \begin{macrocode} |
| 1314 |
\pagecolor{BurlyWood} |
| 1315 |
\AddToShipoutPictureBG{% |
| 1316 |
\AtTextLowerLeft{\color{SaddleBrown}% |
| 1317 |
\rule[-\footskip]{\textwidth}{% |
| 1318 |
\dimexpr\textheight+\footskip}}} |
| 1319 |
% \end{macrocode} |
| 1320 |
% \end{CPK@macro} |
| 1321 |
% \subsubsection{Size and shape}\label{sizeshape} |
| 1322 |
% Each book is assigned a random height and width, |
| 1323 |
% within the bounds set by the maxima and minima. The final |
| 1324 |
% dimensions may then be modified by the choice of layout |
| 1325 |
% and font.\par |
| 1326 |
% \begin{macrocode} |
| 1327 |
\newlength{\SIL@bookheight} |
| 1328 |
\newlength{\SIL@bookwidth} |
| 1329 |
\newlength{\SIL@minbookwidth} |
| 1330 |
\newlength{\SIL@maxbookwidth} |
| 1331 |
\newlength{\SIL@minbookheight} |
| 1332 |
\newlength{\SIL@maxbookheight} |
| 1333 |
% \end{macrocode} |
| 1334 |
% \subsubsection{Title and author dimensions}\label{titling} |
| 1335 |
% The title and author need to be measured, and |
| 1336 |
% decisions are made about what size they need to be. The |
| 1337 |
% two layouts (author separately at the top, and author |
| 1338 |
% inline to title) are distinguished with the |
| 1339 |
% {\ttfamily{}\textbackslash{}SIL@topauthor} conditional. If the title |
| 1340 |
% (with or without the author can fit on one line (rather |
| 1341 |
% than multiple lines) this is signalled with the |
| 1342 |
% {\ttfamily{}\textbackslash{}SIL@titleoneline} conditional.\par |
| 1343 |
% \begin{macrocode} |
| 1344 |
\newlength{\SIL@titlewidth} |
| 1345 |
\newlength{\SIL@authorwidth} |
| 1346 |
\newlength{\SIL@titleheight} |
| 1347 |
\newlength{\SIL@authorheight} |
| 1348 |
\newlength{\SIL@scaledtitle} |
| 1349 |
\newlength{\SIL@heightfortitle} |
| 1350 |
\newbox\SIL@titlebox |
| 1351 |
\newif\ifSIL@topauthor |
| 1352 |
\newif\ifSIL@titleoneline |
| 1353 |
% \end{macrocode} |
| 1354 |
% \subsubsection{Handling the math} |
| 1355 |
% \begin{CPK@counter}{SIL@scale}\label{counter--SIL@scale} |
| 1356 |
% To extract the integer part of a fixed-point value, |
| 1357 |
% we define a simple strip which uses the integer and |
| 1358 |
% throws away the rest. The integer ends up in this |
| 1359 |
% counter.\par |
| 1360 |
% \begin{macrocode} |
| 1361 |
\newcounter{SIL@scale} |
| 1362 |
% \end{macrocode} |
| 1363 |
% \end{CPK@counter} |
| 1364 |
% \begin{CPK@macro}{\SIL@scaleint}\label{macro--SIL@scaleint} |
| 1365 |
% The integer macro returns the counter above.\par |
| 1366 |
% \begin{macrocode} |
| 1367 |
\def\SIL@scaleint#1.#2\sentinel{% |
| 1368 |
\setcounter{SIL@scale}{#1}} |
| 1369 |
% \end{macrocode} |
| 1370 |
% \end{CPK@macro} |
| 1371 |
% \subsubsection{Settings} |
| 1372 |
% We set the space around a box and the thickness of the |
| 1373 |
% rule, and remove the page numbers.\par |
| 1374 |
% \begin{macrocode} |
| 1375 |
\fboxsep1em\fboxrule.1pt |
| 1376 |
\pagestyle{empty} |
| 1377 |
% \end{macrocode} |
| 1378 |
% |
| 1379 |
% \subsubsection{Auxillary macro: fitting text in a box} |
| 1380 |
% |
| 1381 |
% \begin{CPK@macro}{\SIL@fittext}\label{macro--SIL@fittext} |
| 1382 |
% For typesetting title we use an auxillary macro |\SIL@fittext|. It |
| 1383 |
% has four parameters: the text to be typeset, the width ($W$), the |
| 1384 |
% height $H$, and the box $W\times H$ to put the text into. We want |
| 1385 |
% to get the maximal font size that still fits in the box. |
| 1386 |
% Unfortunately there is a limitation on the maximal number of fonts |
| 1387 |
% \TeX\ can handle (currently 9000 by default). Since each size |
| 1388 |
% change counts as a new font, things can quickly go out of hand. |
| 1389 |
% Therefore instead of scaling the font we scale the box. |
| 1390 |
% |
| 1391 |
% So our aim is to find the maximal scaling factor $S$ such as (1)~the |
| 1392 |
% text is typeset in a $w\times h$ box, (2)~the text box scales to the |
| 1393 |
% given width, $W=Sw$, (3)~the text box does not overflow the height, |
| 1394 |
% $H\le Sh$. |
| 1395 |
% |
| 1396 |
% The algorithm is the following: |
| 1397 |
% \begin{enumerate} |
| 1398 |
% \item If the text fits in one line, we expand the box for the line |
| 1399 |
% to occupy $W$, setting $S=W/w$. |
| 1400 |
% \item Otherwise, we try to typeset the text in the box of horizontal |
| 1401 |
% size $W$ ($S=1$) and calculate box height $h$. We determine how |
| 1402 |
% much we can expand or shrink the box, setting $S=H/h$. |
| 1403 |
% \item We typeset the text in the box of width $w=W/S$. |
| 1404 |
% \item Due to changed line breaks its height $h$ might be higher than |
| 1405 |
% $H/S$. In this case we start to decrease $S$ by 5\% on each step |
| 1406 |
% and repeat typesetting until $w\le W/S$ |
| 1407 |
% \end{enumerate} |
| 1408 |
% |
| 1409 |
% Now, the implementation. |
| 1410 |
% |
| 1411 |
% First, we calculate $W$ and $H$ by stripping the pt dimension |
| 1412 |
% \begin{macrocode} |
| 1413 |
\def\SIL@fittext#1#2#3#4{% |
| 1414 |
\@tempdima=#2\relax |
| 1415 |
\edef\SIL@W{\strip@pt\@tempdima}% |
| 1416 |
\@tempdima=#3\relax |
| 1417 |
\edef\SIL@H{\strip@pt\@tempdima}% |
| 1418 |
% \end{macrocode} |
| 1419 |
% Try to set up the text in one line |
| 1420 |
% \begin{macrocode} |
| 1421 |
\setbox#4=\hbox{\raggedright\noindent#1}% |
| 1422 |
\@tempdima=\wd#4\relax |
| 1423 |
\edef\SIL@w{\strip@pt\@tempdima}% |
| 1424 |
\ifdim#2>\@tempdima\relax |
| 1425 |
\FPeval\SIL@S{\SIL@W/\SIL@w}% |
| 1426 |
\typeout{Text fits in one line: have H=\SIL@w pt, want \SIL@W pt}% |
| 1427 |
\typeout{Trying S=\SIL@S}% |
| 1428 |
\else |
| 1429 |
% \end{macrocode} |
| 1430 |
% We start with the scale factor $S=1$. We add |\vskip0pt| to the |
| 1431 |
% text to set the box depth to zero. |
| 1432 |
% \begin{macrocode} |
| 1433 |
\typeout{Text does not fit in one line}% |
| 1434 |
\def\SIL@S{1}% |
| 1435 |
\FPeval\SIL@w{\SIL@W/\SIL@S}% |
| 1436 |
\setbox#4=\vbox{\hsize=\SIL@w pt\relax |
| 1437 |
\raggedright\noindent#1\vskip0pt}% |
| 1438 |
\@tempdima=\ht#4\relax |
| 1439 |
\edef\SIL@h{\strip@pt\@tempdima}% |
| 1440 |
\@tempdima = \SIL@S \@tempdima\relax |
| 1441 |
\typeout{Trying S=\SIL@S. Got H=\the\@tempdima. Want \SIL@H pt}% |
| 1442 |
\FPeval\SIL@S{\SIL@H/\SIL@h}% |
| 1443 |
\fi |
| 1444 |
% \end{macrocode} |
| 1445 |
% Rescaling the box for the first time. If $S$ on the previous step |
| 1446 |
% is below 1, start again with 1. |
| 1447 |
% \begin{macrocode} |
| 1448 |
\FPmax\SIL@S\SIL@S{1}% |
| 1449 |
\FPeval\SIL@w{\SIL@W/\SIL@S}% |
| 1450 |
\setbox#4=\vbox{\hsize=\SIL@w pt\relax |
| 1451 |
\raggedright\noindent#1\vskip0pt}% |
| 1452 |
\@tempdima=\ht#4\relax |
| 1453 |
\edef\SIL@h{\strip@pt\@tempdima}% |
| 1454 |
\@tempdima = \SIL@S \@tempdima\relax |
| 1455 |
\typeout{Trying S=\SIL@S. Got H=\the\@tempdima. Want \SIL@H pt}% |
| 1456 |
% \end{macrocode} |
| 1457 |
% If the text does not fit, keep reducing it by 5\% at a type |
| 1458 |
% \begin{macrocode} |
| 1459 |
\ifdim\@tempdima>#3\relax |
| 1460 |
\loop |
| 1461 |
\FPeval\SIL@S{0.95*\SIL@S}% |
| 1462 |
\FPeval\SIL@w{\SIL@W/\SIL@S}% |
| 1463 |
\setbox#4=\vbox{\hsize=\SIL@w pt\relax |
| 1464 |
\raggedright\noindent#1\vskip0pt}% |
| 1465 |
\@tempdima=\ht#4\relax |
| 1466 |
\edef\SIL@h{\strip@pt\@tempdima}% |
| 1467 |
\@tempdima = \SIL@S \@tempdima\relax |
| 1468 |
\typeout{Trying S=\SIL@S. Got H=\the\@tempdima. Want \SIL@H pt}% |
| 1469 |
\ifdim\@tempdima>#3\repeat |
| 1470 |
\fi |
| 1471 |
% \end{macrocode} |
| 1472 |
% And the final typesetting |
| 1473 |
% \begin{macrocode} |
| 1474 |
\setbox#4=\vbox to #3{\hsize=#2\relax |
| 1475 |
\vfill |
| 1476 |
\noindent |
| 1477 |
\scalebox{\SIL@S}{\vbox{\hsize=\SIL@w pt\relax |
| 1478 |
\raggedright\noindent#1\vskip0pt}}% |
| 1479 |
\vfill}% |
| 1480 |
} |
| 1481 |
% \end{macrocode} |
| 1482 |
% |
| 1483 |
% \end{CPK@macro} |
| 1484 |
% |
| 1485 |
% |
| 1486 |
% \subsubsection{Selecting the font for the book}\label{fontsel} |
| 1487 |
% |
| 1488 |
% In a multilingual library some books can be typeset only in specific |
| 1489 |
% fonts. Here we randomly select a font to typeset the given book. |
| 1490 |
% |
| 1491 |
% We define a macro that checks whether the given string can be |
| 1492 |
% typeset in the font just defined by fontspec. |
| 1493 |
% |
| 1494 |
% We write the program in expl3 syntax because it has nice mapping |
| 1495 |
% subroutines and becasue fontspec internal variables are in expl3. |
| 1496 |
% |
| 1497 |
% \begin{macrocode} |
| 1498 |
\ExplSyntaxOn |
| 1499 |
% \end{macrocode} |
| 1500 |
% An auxillary routine checking whether the character can be typeset |
| 1501 |
% with the current font. Copied from fontspec internals |
| 1502 |
% \begin{macrocode} |
| 1503 |
\prg_new_conditional:Nnn \__SIL_primitive_font_glyph_if_exists:n {TF,F} |
| 1504 |
{ |
| 1505 |
\tex_iffontchar:D \SILmfont `#1 \scan_stop: |
| 1506 |
\prg_return_true: |
| 1507 |
\else: |
| 1508 |
\prg_return_false: |
| 1509 |
\fi: |
| 1510 |
} |
| 1511 |
% \end{macrocode} |
| 1512 |
% And the document command |
| 1513 |
% \begin{macrocode} |
| 1514 |
\prg_new_conditional:Nnn \__SIL_can_typeset:n {TF} |
| 1515 |
{ |
| 1516 |
\typeout{Trying ~ to ~ typeset ~ #1} |
| 1517 |
\bool_set_true:N \l_tmpa_bool |
| 1518 |
\str_map_inline:nn {#1} { |
| 1519 |
\__SIL_primitive_font_glyph_if_exists:nTF {##1} {}{ |
| 1520 |
\bool_set_false:N \l_tmpa_bool |
| 1521 |
\typeout{Cannot ~ typeset ~ ##1} |
| 1522 |
\str_map_break: |
| 1523 |
} |
| 1524 |
} |
| 1525 |
\bool_if:nTF \l_tmpa_bool {\prg_return_true:} {\prg_return_false:} |
| 1526 |
} |
| 1527 |
|
| 1528 |
\cs_generate_variant:Nn \__SIL_can_typeset:nTF {x} |
| 1529 |
|
| 1530 |
\NewDocumentCommand\CanTypesetTF { m m m}{ |
| 1531 |
\__SIL_can_typeset:xTF{#1}{#2}{#3} |
| 1532 |
} |
| 1533 |
\ExplSyntaxOff |
| 1534 |
% \end{macrocode} |
| 1535 |
% |
| 1536 |
% We define some counters and flags for the font selection |
| 1537 |
% \begin{macrocode} |
| 1538 |
\def\SIL@maxfonttries{100} |
| 1539 |
\newif\ifSIL@fontfound |
| 1540 |
% \end{macrocode} |
| 1541 |
% |
| 1542 |
% |
| 1543 |
% Another twist is that we cannot have too many fonts used. Therefore |
| 1544 |
% we add all fontsel files to a stack, and after having |
| 1545 |
% 2100 of them, we reuse opened files. Again, it is easy to do in |
| 1546 |
% expl3. |
| 1547 |
% \begin{macrocode} |
| 1548 |
\ExplSyntaxOn |
| 1549 |
\seq_new:N \l__SIL_fontstack |
| 1550 |
\NewDocumentCommand\AddFontToStack {m} {% |
| 1551 |
\seq_gput_right:Ne \l__SIL_fontstack {#1} |
| 1552 |
} |
| 1553 |
\NewDocumentCommand\ReuseFont {} { |
| 1554 |
\seq_rand_item:N \l__SIL_fontstack |
| 1555 |
} |
| 1556 |
\ExplSyntaxOff |
| 1557 |
\newcount\SIL@num@fontsel@files |
| 1558 |
\SIL@num@fontsel@files=0 |
| 1559 |
\def\SIL@max@fontsel@files{5500} |
| 1560 |
% \end{macrocode} |
| 1561 |
% |
| 1562 |
% \subsubsection{Making the book}\label{mb} |
| 1563 |
% The {\ttfamily{}\textbackslash{}makebook} macro is huge, and |
| 1564 |
% handles all the detail of making a book spine. It takes |
| 1565 |
% two mandatory arguments: the author and the title of the |
| 1566 |
% book.\par |
| 1567 |
% \begin{CPK@macro}{\makebook}\label{macro--makebook} |
| 1568 |
% Start by announcing the entry label and setting the |
| 1569 |
% values that need to be reset every time.\par |
| 1570 |
% \begin{macrocode} |
| 1571 |
\newcommand{\makebook}[2]{% |
| 1572 |
\typeout{^^JTypesetting #1---#2}% |
| 1573 |
\setcounter{SIL@maxloop}{10}% |
| 1574 |
\setcounter{SIL@loopcount}{0}% |
| 1575 |
% observed |
| 1576 |
\setlength{\SIL@minbookwidth}{5mm}% |
| 1577 |
\setlength{\SIL@maxbookwidth}{20mm}% |
| 1578 |
% A5 to A4 height |
| 1579 |
\setlength{\SIL@minbookheight}{70mm}% |
| 1580 |
\setlength{\SIL@maxbookheight}{110mm}% |
| 1581 |
\setlength{\SIL@bookwidth}{0pt}% |
| 1582 |
\setlength{\SIL@bookheight}{0pt}% |
| 1583 |
\setlength{\SIL@heightfortitle}{0pt}% |
| 1584 |
\SIL@topauthorfalse |
| 1585 |
% \end{macrocode} |
| 1586 |
% \end{CPK@macro} |
| 1587 |
% \begin{CPK@macro}{\loop}\label{macro--loop} |
| 1588 |
% Start a loop which will pick two random integers, |
| 1589 |
% one for background and one for foreground colors. Look |
| 1590 |
% these up in the {\ttfamily{}\textbackslash{}SIL@svgcolval} (in |
| 1591 |
% {\ttfamily{}bookshelf-svgnam.tex}) to get the brightness |
| 1592 |
% values, and calculate the absolute distance between |
| 1593 |
% them.\par |
| 1594 |
% \begin{macrocode} |
| 1595 |
\loop |
| 1596 |
\addtocounter{SIL@loopcount}{1}% |
| 1597 |
\typeout{Try \theSIL@loopcount}% |
| 1598 |
\setrannum{\c@SIL@bgcolno}{1}{% |
| 1599 |
\c@SIL@maxcolno}% |
| 1600 |
\typeout{BG=\theSIL@bgcolno}% |
| 1601 |
\setrannum{\c@SIL@fgcolno}{1}{% |
| 1602 |
\c@SIL@maxcolno}% |
| 1603 |
\typeout{FG=\theSIL@fgcolno}% |
| 1604 |
\setlength{\SIL@bgval}{% |
| 1605 |
\SIL@svgcolval{\theSIL@bgcolno}pt}% |
| 1606 |
\typeout{BGval=\the\SIL@bgval}% |
| 1607 |
\setlength{\SIL@fgval}{% |
| 1608 |
\SIL@svgcolval{\theSIL@fgcolno}pt}% |
| 1609 |
\typeout{FGval=\the\SIL@fgval}% |
| 1610 |
\setlength{\SIL@bgfgdiff}{% |
| 1611 |
\SIL@bgval - \SIL@fgval}% |
| 1612 |
\typeout{Split gap is \the\SIL@bgfgdiff}% |
| 1613 |
\ifdim\SIL@bgfgdiff<0pt |
| 1614 |
\setlength{\SIL@bgfgdiff}{% |
| 1615 |
\SIL@fgval - \SIL@bgval}% |
| 1616 |
\typeout{Using absolute value |
| 1617 |
\the\SIL@bgfgdiff}% |
| 1618 |
\fi |
| 1619 |
% \end{macrocode} |
| 1620 |
% The colours need to be separated either side of the |
| 1621 |
% 0.6 splitpoint value of the calculated brightness, so |
| 1622 |
% make this the outer test, and make the inner test for |
| 1623 |
% the separation difference. This will return true if the |
| 1624 |
% colors are separated enough, and come from opposite |
| 1625 |
% sides of the split point. If the loop makes \DescribeCounter{SIL@maxloop}{\ttfamily{}SIL@maxloop} |
| 1626 |
% iterations without finding a pair of values, use |
| 1627 |
% the default white on black.\par |
| 1628 |
% \begin{macrocode} |
| 1629 |
\ifdim\SIL@bgval<\SIL@splitpoint |
| 1630 |
\ifdim\SIL@fgval>\SIL@splitpoint |
| 1631 |
\ifdim\SIL@bgfgdiff>0.2pt |
| 1632 |
\SIL@notyetcolsfalse |
| 1633 |
\else |
| 1634 |
\SIL@notyetcolstrue |
| 1635 |
\fi |
| 1636 |
\else |
| 1637 |
\SIL@notyetcolstrue |
| 1638 |
\fi |
| 1639 |
\else |
| 1640 |
\ifdim\SIL@fgval<\SIL@splitpoint |
| 1641 |
\ifdim\SIL@bgfgdiff>0.2pt |
| 1642 |
\SIL@notyetcolsfalse |
| 1643 |
\else |
| 1644 |
\SIL@notyetcolstrue |
| 1645 |
\fi |
| 1646 |
\else |
| 1647 |
\SIL@notyetcolstrue |
| 1648 |
\fi |
| 1649 |
\fi |
| 1650 |
\typeout{BG=\theSIL@bgcolno, |
| 1651 |
FG=\theSIL@fgcolno}% |
| 1652 |
\ifnum\c@SIL@loopcount>\c@SIL@maxloop |
| 1653 |
\SIL@notyetcolsfalse |
| 1654 |
\fi |
| 1655 |
\ifSIL@notyetcols\repeat |
| 1656 |
\def\SIL@bgcol{\SIL@svgcolname{% |
| 1657 |
\theSIL@bgcolno}}% |
| 1658 |
\def\SIL@fgcol{\SIL@svgcolname{% |
| 1659 |
\theSIL@fgcolno}}% |
| 1660 |
\ifnum\c@SIL@loopcount>\c@SIL@maxloop |
| 1661 |
\typeout{Using default colors after \the\c@SIL@maxloop\space attempts}% |
| 1662 |
\def\SIL@bgcol{Black}% |
| 1663 |
\def\SIL@fgcol{White}% |
| 1664 |
\fi |
| 1665 |
\typeout{BG=\SIL@bgcol, FG=\SIL@fgcol}% |
| 1666 |
% \end{macrocode} |
| 1667 |
% Now pick a random font: the files generated by |
| 1668 |
% {\ttfamily{}prepdata.sh} are named as integers with |
| 1669 |
% a {\ttfamily{}.tex} extension in the |
| 1670 |
% {\ttfamily{}fontsel} directory. These files load |
| 1671 |
% the font as {\ttfamily{}\textbackslash{}SILmfont} (no |
| 1672 |
% {\ttfamily{}@} sign, because this is |
| 1673 |
% occurring in user mode), and define |
| 1674 |
% {\ttfamily{}\textbackslash{}SILmfontname} as the name (for the |
| 1675 |
% same reason).\par |
| 1676 |
% \begin{macrocode} |
| 1677 |
\c@SIL@loopcount=1\relax |
| 1678 |
\loop |
| 1679 |
\ifnum\SIL@num@fontsel@files<\SIL@max@fontsel@files |
| 1680 |
\advance\SIL@num@fontsel@files by 1\relax |
| 1681 |
\typeout{Opening new fontsel file, counter=\the\SIL@num@fontsel@files}% |
| 1682 |
\setrannum{\c@SIL@fontsel}{1}{\c@SIL@maxfont}% |
| 1683 |
\AddFontToStack{\the\c@SIL@fontsel}% |
| 1684 |
\else |
| 1685 |
\typeout{Reusing fontsel file}% |
| 1686 |
\expandafter\c@SIL@fontsel\ReuseFont\relax |
| 1687 |
\fi |
| 1688 |
\input{fontsel/\[email protected]}\unskip% |
| 1689 |
\typeout{Trying \SILmfontname, attempt \the\c@SIL@loopcount}% |
| 1690 |
\CanTypesetTF{#2---#1}{\global |
| 1691 |
\SIL@fontfoundtrue}{\global |
| 1692 |
\SIL@fontfoundfalse}% |
| 1693 |
\ifSIL@fontfound |
| 1694 |
\c@SIL@loopcount=\SIL@maxfonttries\relax |
| 1695 |
\else |
| 1696 |
\addtocounter{SIL@loopcount}{1}% |
| 1697 |
\fi |
| 1698 |
\ifnum\c@SIL@loopcount<\SIL@maxfonttries\repeat |
| 1699 |
\ifSIL@fontfound |
| 1700 |
\typeout{Set in \SILmfontname}% |
| 1701 |
% \end{macrocode} |
| 1702 |
% |
| 1703 |
% |
| 1704 |
% Measure the author width and height at the default |
| 1705 |
% size (10pt). If the author fits in 90\% of the |
| 1706 |
% maximum width of the book, we put it at the top of the |
| 1707 |
% spine and shrink the book width to 1.1 times the set |
| 1708 |
% width, provided that is not less than the defined |
| 1709 |
% minimum width. The book width is therefore fixed at this |
| 1710 |
% point and won't change later.\par |
| 1711 |
% \begin{macrocode} |
| 1712 |
\settowidth{\SIL@authorwidth}{% |
| 1713 |
\SILmfont#1}% |
| 1714 |
\typeout{Author width: \the\SIL@authorwidth}% |
| 1715 |
\settoheight{\SIL@authorheight}{% |
| 1716 |
\SILmfont#1}% |
| 1717 |
\typeout{Author height: \the\SIL@authorheight}% |
| 1718 |
\ifdim\SIL@authorwidth<.9\SIL@maxbookwidth |
| 1719 |
\typeout{Author width is less than 90\% |
| 1720 |
of \the\SIL@maxbookwidth}% |
| 1721 |
\setlength{\SIL@bookwidth}{% |
| 1722 |
1.1\SIL@authorwidth}% |
| 1723 |
\typeout{Book width set to \the\SIL@bookwidth}% |
| 1724 |
\ifdim\SIL@bookwidth<\SIL@minbookwidth |
| 1725 |
\setlength{\SIL@bookwidth}{% |
| 1726 |
\SIL@minbookwidth}% |
| 1727 |
\typeout{Book width reset to min |
| 1728 |
\the\SIL@minbookheight}% |
| 1729 |
\fi |
| 1730 |
\SIL@topauthortrue |
| 1731 |
\else |
| 1732 |
\typeout{Author won't fit in .9 of |
| 1733 |
\the\SIL@maxbookwidth}% |
| 1734 |
\fi |
| 1735 |
% \end{macrocode} |
| 1736 |
% We now have enough data to make a shot at the |
| 1737 |
% dimensions. Pick a random book height and set the height |
| 1738 |
% available for the title (set sideways) to 90\% of |
| 1739 |
% that, so that it fits comfortably. Then if the author |
| 1740 |
% was earlier assigned to the top of the spine, reduce |
| 1741 |
% this height available for the title by 1.2 times the |
| 1742 |
% height occupied by the author (again, to leave a little |
| 1743 |
% space). In this case, the width has already been set; |
| 1744 |
% otherwise, generate a random width now.\par |
| 1745 |
% \begin{macrocode} |
| 1746 |
\typeout{Limits: width=\the\SIL@minbookwidth |
| 1747 |
–\the\SIL@maxbookwidth; |
| 1748 |
height=\the\SIL@minbookheight |
| 1749 |
–\the\SIL@maxbookheight}% |
| 1750 |
\setrandim{\SIL@bookheight}% |
| 1751 |
{\SIL@minbookheight}% |
| 1752 |
{\SIL@maxbookheight}% |
| 1753 |
\typeout{Height generated as |
| 1754 |
\the\SIL@bookheight}% |
| 1755 |
\setlength{\SIL@heightfortitle}% |
| 1756 |
{.9\SIL@bookheight}% |
| 1757 |
\typeout{Height available for title (90\%): |
| 1758 |
\the\SIL@heightfortitle}% |
| 1759 |
\ifSIL@topauthor |
| 1760 |
\typeout{Width set because author fits: |
| 1761 |
\the\SIL@bookwidth}% |
| 1762 |
\addtolength{\SIL@heightfortitle}% |
| 1763 |
{-1.2\SIL@authorheight}% |
| 1764 |
\typeout{Height available for title reset to |
| 1765 |
\the\SIL@heightfortitle}% |
| 1766 |
\else |
| 1767 |
\setrandim{\SIL@bookwidth}% |
| 1768 |
{\SIL@minbookwidth}% |
| 1769 |
{\SIL@maxbookwidth}% |
| 1770 |
\typeout{Width generated as |
| 1771 |
\the\SIL@bookwidth}% |
| 1772 |
\fi |
| 1773 |
% \end{macrocode} |
| 1774 |
% Finally, set a {\ttfamily{}\textbackslash{}vbox} to the |
| 1775 |
% defined width \emph{less} the space |
| 1776 |
% occupied by the {\ttfamily{}\textbackslash{}fcolorbox} border and |
| 1777 |
% rule; then set the {\ttfamily{}\textbackslash{}fcolorbox} with the |
| 1778 |
% chosen colors, with the author at the top if that's what |
| 1779 |
% was selected earlier, and the title below, either scaled |
| 1780 |
% using {\ttfamily{}\textbackslash{}scalebox} if it was a |
| 1781 |
% single-line title, or with the amended font size if it |
| 1782 |
% was a multiline title.\par |
| 1783 |
% For a setting with the author inline to the title, |
| 1784 |
% just do the scaling of the title.\par |
| 1785 |
% \begin{macrocode} |
| 1786 |
\leavevmode\vbox{\hsize\SIL@bookwidth |
| 1787 |
\advance\hsize by2\fboxsep |
| 1788 |
\advance\hsize by2\fboxrule |
| 1789 |
\fcolorbox{black}{\SIL@bgcol}{% |
| 1790 |
\ifSIL@topauthor |
| 1791 |
\typeout{Setting with top author}% |
| 1792 |
\vbox to\SIL@bookheight{\hsize\SIL@bookwidth |
| 1793 |
\typeout{Spine is a vbox to |
| 1794 |
\the\SIL@bookheight, |
| 1795 |
hsize=\the\SIL@bookwidth}% |
| 1796 |
\centering |
| 1797 |
\SILmfont\color{\SIL@fgcol}% |
| 1798 |
#1% |
| 1799 |
\par\vfill |
| 1800 |
\SIL@fittext{\color{\SIL@fgcol}\SILmfont |
| 1801 |
#2}{\SIL@heightfortitle}{\SIL@bookwidth}% |
| 1802 |
{\SIL@titlebox}% |
| 1803 |
\rotatebox{90}{\box\SIL@titlebox}% |
| 1804 |
}% |
| 1805 |
\else |
| 1806 |
\typeout{Setting author inline to title}% |
| 1807 |
\vbox to\SIL@bookheight{\hsize\SIL@bookwidth |
| 1808 |
\SIL@fittext{\color{\SIL@fgcol}\SILmfont |
| 1809 |
#1\quad |
| 1810 |
---\quad#2}{\SIL@bookheight}{\SIL@bookwidth}% |
| 1811 |
{\SIL@titlebox}% |
| 1812 |
\rotatebox{90}{\box\SIL@titlebox}% |
| 1813 |
}% |
| 1814 |
\fi |
| 1815 |
}% |
| 1816 |
% \end{macrocode} |
| 1817 |
% At the bottom, add a colored bar to fake up the |
| 1818 |
% shelf the books stand on. The number is the number of |
| 1819 |
% the font that was selected, and is there for |
| 1820 |
% error-tracing purposes only.\par |
| 1821 |
% \begin{macrocode} |
| 1822 |
\\\fboxsep0pt\fboxrule0pt% |
| 1823 |
\colorbox{BurlyWood}{\hbox to\hsize{% |
| 1824 |
\hfil\vrule height3mm depth6mm width0pt |
| 1825 |
\normalfont\scriptsize\theSIL@fontsel\hfil}}% |
| 1826 |
}% |
| 1827 |
\penalty0 |
| 1828 |
\else % font not found |
| 1829 |
\typeout{Did not find font for #1--#2}% |
| 1830 |
|
| 1831 |
\fi} |
| 1832 |
% \end{macrocode} |
| 1833 |
% \end{CPK@macro} |
| 1834 |
% |
| 1835 |
% \begin{macrocode} |
| 1836 |
\raggedright |
| 1837 |
% \end{macrocode} |
| 1838 |
% |
| 1839 |
% \iffalse |
| 1840 |
%</class> |
| 1841 |
% \fi |
| 1842 |
% \nocite{*} |
| 1843 |
% \clearpage |
| 1844 |
% \raggedright |
| 1845 |
% \raggedright\printbibliography |
| 1846 |
% \Finale |
| 1847 |
|