pdf export update

This commit is contained in:
NT 2021-04-22 10:26:01 +08:00
parent d9f6c73a68
commit 559b4ed019
6 changed files with 2033 additions and 2 deletions

701
latex-helpers/fncychap.sty Normal file
View File

@ -0,0 +1,701 @@
%% Copyright 2007 Ulf Lindgren
%
% This work may be distributed and/or modified under the conditions of the LaTeX
% Project Public License, either version 1.3 of this license or (at your option)
% any later version. The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX version
% 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Ulf Lindgren.
%
% This work consists of all files listed in manifest.txt.
%
%% This statement added 2010/12/10 by Clea F. Rees following correspondence
%% between Ulf Lindgren and Karl Berry concerning licensing.
%%% Copyright Ulf A. Lindgren
%%%
%%% Note Premission is granted to modify this file under
%%% the condition that it is saved using another
%%% file and package name.
%%%
%%% Revision 1.1 (1997)
%%%
%%% Jan. 8th Modified package name base date option
%%% Jan. 22th Modified FmN and FmTi for error in book.cls
%%% \MakeUppercase{#}->{\MakeUppercase#}
%%% Apr. 6th Modified Lenny option to prevent undesired
%%% skip of line.
%%% Nov. 8th Fixed \@chapapp for AMS
%%%
%%% Revision 1.2 (1998)
%%%
%%% Feb. 11th Fixed appendix problem related to Bjarne
%%% Aug. 11th Fixed problem related to 11pt and 12pt
%%% suggested by Tomas Lundberg. THANKS!
%%%
%%% Revision 1.3 (2004)
%%% Sep. 20th problem with frontmatter, mainmatter and
%%% backmatter, pointed out by Lapo Mori
%%%
%%% Revision 1.31 (2004)
%%% Sep. 21th problem with the Rejne definition streched text
%%% caused ugly gaps in the vrule aligned with the title
%%% text. Kindly pointed out to me by Hendri Adriaens
%%%
%%% Revision 1.32 (2005)
%%% Jun. 23th compatibility problem with the KOMA class 'scrbook.cls'
%%% a remedy is a redefinition of '\@schapter' in
%%% line with that used in KOMA. The problem was pointed
%%% out to me by Mikkel Holm Olsen
%%%
%%% Revision 1.33 (2005)
%%% Aug. 9th misspelled ``TWELV'' corrected, the error was pointed
%%% out to me by George Pearson
%%%
%%% Revision 1.34 (2007)
%%% Added an alternative to Lenny provided by Peter
%%% Osborne (2005-11-28)
%%% Corrected front, main and back matter, based on input
%%% from Bas van Gils (2006-04-24)
%%% Jul. 30th Added Bjornstrup option provided by Jean-Marc
%%% Francois (2007-01-05).
%%% Reverted to \MakeUppercase{#} see rev 1.1, solved
%%% problem with MakeUppercase and MakeLowercase pointed
%%% out by Marco Feuerstein (2007-06-06)
%%% Last modified Jul. 2007
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesPackage{fncychap}
[2007/07/30 v1.34
LaTeX package (Revised chapters)]
%%%% For conditional inclusion of color
\newif\ifusecolor
\usecolorfalse
%%%% DEFINITION OF Chapapp variables
\newcommand{\CNV}{\huge\bfseries}
\newcommand{\ChNameVar}[1]{\renewcommand{\CNV}{#1}}
%%%% DEFINITION OF TheChapter variables
\newcommand{\CNoV}{\huge\bfseries}
\newcommand{\ChNumVar}[1]{\renewcommand{\CNoV}{#1}}
\newif\ifUCN
\UCNfalse
\newif\ifLCN
\LCNfalse
\def\ChNameLowerCase{\LCNtrue\UCNfalse}
\def\ChNameUpperCase{\UCNtrue\LCNfalse}
\def\ChNameAsIs{\UCNfalse\LCNfalse}
%%%%% Fix for AMSBook 971008
\@ifundefined{@chapapp}{\let\@chapapp\chaptername}{}
%%%%% Fix for Bjarne and appendix 980211
\newif\ifinapp
\inappfalse
\renewcommand\appendix{\par
\setcounter{chapter}{0}%
\setcounter{section}{0}%
\inapptrue%
\renewcommand\@chapapp{\appendixname}%
\renewcommand\thechapter{\@Alph\c@chapter}}
%%%%% Fix for frontmatter, mainmatter, and backmatter 040920
\@ifundefined{@mainmatter}{\newif\if@mainmatter \@mainmattertrue}{}
%%%%%
\newcommand{\FmN}[1]{%
\ifUCN
{\MakeUppercase{#1}}\LCNfalse
\else
\ifLCN
{\MakeLowercase{#1}}\UCNfalse
\else #1
\fi
\fi}
%%%% DEFINITION OF Title variables
\newcommand{\CTV}{\Huge\bfseries}
\newcommand{\ChTitleVar}[1]{\renewcommand{\CTV}{#1}}
%%%% DEFINITION OF the basic rule width
\newlength{\RW}
\setlength{\RW}{1pt}
\newcommand{\ChRuleWidth}[1]{\setlength{\RW}{#1}}
\newif\ifUCT
\UCTfalse
\newif\ifLCT
\LCTfalse
\def\ChTitleLowerCase{\LCTtrue\UCTfalse}
\def\ChTitleUpperCase{\UCTtrue\LCTfalse}
\def\ChTitleAsIs{\UCTfalse\LCTfalse}
\newcommand{\FmTi}[1]{%
\ifUCT
{\MakeUppercase{#1}}\LCTfalse
\else
\ifLCT
{\MakeLowercase{#1}}\UCTfalse
\else {#1}
\fi
\fi}
\newlength{\mylen}
\newlength{\myhi}
\newlength{\px}
\newlength{\py}
\newlength{\pyy}
\newlength{\pxx}
\def\mghrulefill#1{\leavevmode\leaders\hrule\@height #1\hfill\kern\z@}
\newcommand{\DOCH}{%
\CNV\FmN{\@chapapp}\space \CNoV\thechapter
\par\nobreak
\vskip 20\p@
}
\newcommand{\DOTI}[1]{%
\CTV\FmTi{#1}\par\nobreak
\vskip 40\p@
}
\newcommand{\DOTIS}[1]{%
\CTV\FmTi{#1}\par\nobreak
\vskip 40\p@
}
%%%%%% SONNY DEF
\DeclareOption{Sonny}{%
\ChNameVar{\Large\sf}
\ChNumVar{\Huge}
\ChTitleVar{\Large\sf}
\ChRuleWidth{0.5pt}
\ChNameUpperCase
\renewcommand{\DOCH}{%
\raggedleft
\CNV\FmN{\@chapapp}\space \CNoV\thechapter
\par\nobreak
\vskip 40\p@}
\renewcommand{\DOTI}[1]{%
\CTV\raggedleft\mghrulefill{\RW}\par\nobreak
\vskip 5\p@
\CTV\FmTi{#1}\par\nobreak
\mghrulefill{\RW}\par\nobreak
\vskip 40\p@}
\renewcommand{\DOTIS}[1]{%
\CTV\raggedleft\mghrulefill{\RW}\par\nobreak
\vskip 5\p@
\CTV\FmTi{#1}\par\nobreak
\mghrulefill{\RW}\par\nobreak
\vskip 40\p@}
}
%%%%%% LENNY DEF
\DeclareOption{Lenny}{%
\ChNameVar{\fontsize{14}{16}\usefont{OT1}{phv}{m}{n}\selectfont}
\ChNumVar{\fontsize{60}{62}\usefont{OT1}{ptm}{m}{n}\selectfont}
\ChTitleVar{\Huge\bfseries\rm}
\ChRuleWidth{1pt}
\renewcommand{\DOCH}{%
\settowidth{\px}{\CNV\FmN{\@chapapp}}
\addtolength{\px}{2pt}
\settoheight{\py}{\CNV\FmN{\@chapapp}}
\addtolength{\py}{1pt}
\settowidth{\mylen}{\CNV\FmN{\@chapapp}\space\CNoV\thechapter}
\addtolength{\mylen}{1pt}
\settowidth{\pxx}{\CNoV\thechapter}
\addtolength{\pxx}{-1pt}
\settoheight{\pyy}{\CNoV\thechapter}
\addtolength{\pyy}{-2pt}
\setlength{\myhi}{\pyy}
\addtolength{\myhi}{-1\py}
\par
\parbox[b]{\textwidth}{%
\rule[\py]{\RW}{\myhi}%
\hskip -\RW%
\rule[\pyy]{\px}{\RW}%
\hskip -\px%
\raggedright%
\CNV\FmN{\@chapapp}\space\CNoV\thechapter%
\hskip1pt%
\mghrulefill{\RW}%
\rule{\RW}{\pyy}\par\nobreak%
\vskip -\baselineskip%
\vskip -\pyy%
\hskip \mylen%
\mghrulefill{\RW}\par\nobreak%
\vskip \pyy}%
\vskip 20\p@}
\renewcommand{\DOTI}[1]{%
\raggedright
\CTV\FmTi{#1}\par\nobreak
\vskip 40\p@}
\renewcommand{\DOTIS}[1]{%
\raggedright
\CTV\FmTi{#1}\par\nobreak
\vskip 40\p@}
}
%%%%%% Peter Osbornes' version of LENNY DEF
\DeclareOption{PetersLenny}{%
% five new lengths
\newlength{\bl} % bottom left : orig \space
\setlength{\bl}{6pt}
\newcommand{\BL}[1]{\setlength{\bl}{#1}}
\newlength{\br} % bottom right : orig 1pt
\setlength{\br}{1pt}
\newcommand{\BR}[1]{\setlength{\br}{#1}}
\newlength{\tl} % top left : orig 2pt
\setlength{\tl}{2pt}
\newcommand{\TL}[1]{\setlength{\tl}{#1}}
\newlength{\trr} % top right :orig 1pt
\setlength{\trr}{1pt}
\newcommand{\TR}[1]{\setlength{\trr}{#1}}
\newlength{\blrule} % top right :orig 1pt
\setlength{\trr}{0pt}
\newcommand{\BLrule}[1]{\setlength{\blrule}{#1}}
\ChNameVar{\fontsize{14}{16}\usefont{OT1}{phv}{m}{n}\selectfont}
\ChNumVar{\fontsize{60}{62}\usefont{OT1}{ptm}{m}{n}\selectfont}
\ChTitleVar{\Huge\bfseries\rm}
\ChRuleWidth{1pt}
\renewcommand{\DOCH}{%
%%%%%%% tweaks for 1--9 and A--Z
\ifcase\c@chapter\relax%
\or\BL{-3pt}\TL{-4pt}\BR{0pt}\TR{-6pt}%1
\or\BL{0pt}\TL{-4pt}\BR{2pt}\TR{-4pt}%2
\or\BL{0pt}\TL{-4pt}\BR{2pt}\TR{-4pt}%3
\or\BL{0pt}\TL{5pt}\BR{2pt}\TR{-4pt}%4
\or\BL{0pt}\TL{3pt}\BR{2pt}\TR{-4pt}%5
\or\BL{-1pt}\TL{0pt}\BR{2pt}\TR{-2pt}%6
\or\BL{0pt}\TL{-3pt}\BR{2pt}\TR{-2pt}%7
\or\BL{0pt}\TL{-3pt}\BR{2pt}\TR{-2pt}%8
\or\BL{0pt}\TL{-3pt}\BR{-4pt}\TR{-2pt}%9
\or\BL{-3pt}\TL{-3pt}\BR{2pt}\TR{-7pt}%10
\or\BL{-6pt}\TL{-6pt}\BR{0pt}\TR{-9pt}%11
\or\BL{-6pt}\TL{-6pt}\BR{2pt}\TR{-7pt}%12
\or\BL{-5pt}\TL{-5pt}\BR{0pt}\TR{-9pt}%13
\or\BL{-6pt}\TL{-6pt}\BR{0pt}\TR{-9pt}%14
\or\BL{-3pt}\TL{-3pt}\BR{3pt}\TR{-6pt}%15
\or\BL{-3pt}\TL{-3pt}\BR{3pt}\TR{-6pt}%16
\or\BL{-5pt}\TL{-3pt}\BR{-8pt}\TR{-6pt}%17
\or\BL{-5pt}\TL{-5pt}\BR{0pt}\TR{-9pt}%18
\or\BL{-3pt}\TL{-3pt}\BR{-6pt}\TR{-9pt}%19
\or\BL{0pt}\TL{0pt}\BR{0pt}\TR{-5pt}%20
\fi
\ifinapp\ifcase\c@chapter\relax%
\or\BL{0pt}\TL{14pt}\BR{5pt}\TR{-19pt}%A
\or\BL{0pt}\TL{-5pt}\BR{-3pt}\TR{-8pt}%B
\or\BL{-3pt}\TL{-2pt}\BR{1pt}\TR{-6pt}\BLrule{0pt}%C
\or\BL{0pt}\TL{-5pt}\BR{-3pt}\TR{-8pt}\BLrule{0pt}%D
\or\BL{0pt}\TL{-5pt}\BR{2pt}\TR{-3pt}%E
\or\BL{0pt}\TL{-5pt}\BR{-10pt}\TR{-1pt}%F
\or\BL{-3pt}\TL{0pt}\BR{0pt}\TR{-7pt}%G
\or\BL{0pt}\TL{-5pt}\BR{3pt}\TR{-1pt}%H
\or\BL{0pt}\TL{-5pt}\BR{3pt}\TR{-1pt}%I
\or\BL{2pt}\TL{0pt}\BR{-3pt}\TR{1pt}%J
\or\BL{0pt}\TL{-5pt}\BR{3pt}\TR{-1pt}%K
\or\BL{0pt}\TL{-5pt}\BR{2pt}\TR{-19pt}%L
\or\BL{0pt}\TL{-5pt}\BR{3pt}\TR{-1pt}%M
\or\BL{0pt}\TL{-5pt}\BR{-2pt}\TR{-1pt}%N
\or\BL{-3pt}\TL{-2pt}\BR{-3pt}\TR{-11pt}%O
\or\BL{0pt}\TL{-5pt}\BR{-9pt}\TR{-3pt}%P
\or\BL{-3pt}\TL{-2pt}\BR{-3pt}\TR{-11pt}%Q
\or\BL{0pt}\TL{-5pt}\BR{4pt}\TR{-8pt}%R
\or\BL{-2pt}\TL{-2pt}\BR{-2pt}\TR{-7pt}%S
\or\BL{-3pt}\TL{0pt}\BR{-5pt}\TR{4pt}\BLrule{8pt}%T
\or\BL{-7pt}\TL{-11pt}\BR{-5pt}\TR{-7pt}\BLrule{0pt}%U
\or\BL{-14pt}\TL{-5pt}\BR{-14pt}\TR{-1pt}\BLrule{14pt}%V
\or\BL{-10pt}\TL{-9pt}\BR{-13pt}\TR{-3pt}\BLrule{7pt}%W
\or\BL{0pt}\TL{-5pt}\BR{3pt}\TR{-1pt}\BLrule{0pt}%X
\or\BL{-6pt}\TL{-4pt}\BR{-7pt}\TR{1pt}\BLrule{7pt}%Y
\or\BL{0pt}\TL{-5pt}\BR{3pt}\TR{-1pt}\BLrule{0pt}%Z
\fi\fi
%%%%%%%
\settowidth{\px}{\CNV\FmN{\@chapapp}}
\addtolength{\px}{\tl} %MOD change 2pt to \tl
\settoheight{\py}{\CNV\FmN{\@chapapp}}
\addtolength{\py}{1pt}
\settowidth{\mylen}{\CNV\FmN{\@chapapp}\space\CNoV\thechapter}
\addtolength{\mylen}{\trr}% MOD change 1pt to \tr
\settowidth{\pxx}{\CNoV\thechapter}
\addtolength{\pxx}{-1pt}
\settoheight{\pyy}{\CNoV\thechapter}
\addtolength{\pyy}{-2pt}
\setlength{\myhi}{\pyy}
\addtolength{\myhi}{-1\py}
\par
\parbox[b]{\textwidth}{%
\rule[\py]{\RW}{\myhi}%
\hskip -\RW%
\rule[\pyy]{\px}{\RW}%
\hskip -\px%
\raggedright%
\CNV\FmN{\@chapapp}\rule{\blrule}{\RW}\hskip\bl\CNoV\thechapter%MOD
% \CNV\FmN{\@chapapp}\space\CNoV\thechapter %ORIGINAL
\hskip\br% %MOD 1pt to \br
\mghrulefill{\RW}%
\rule{\RW}{\pyy}\par\nobreak%
\vskip -\baselineskip%
\vskip -\pyy%
\hskip \mylen%
\mghrulefill{\RW}\par\nobreak%
\vskip \pyy}%
\vskip 20\p@}
\renewcommand{\DOTI}[1]{%
\raggedright
\CTV\FmTi{#1}\par\nobreak
\vskip 40\p@}
\renewcommand{\DOTIS}[1]{%
\raggedright
\CTV\FmTi{#1}\par\nobreak
\vskip 40\p@}
}
%
%%%%%% BJORNSTRUP DEF
\DeclareOption{Bjornstrup}{%
\usecolortrue
% pzc (Zapf Chancelery) is nice. ppl (Palatino) is cool too.
\ChNumVar{\fontsize{76}{80}\usefont{OT1}{pzc}{m}{n}\selectfont}
\ChTitleVar{\raggedleft\Large\sffamily\bfseries}
\setlength{\myhi}{10pt} % Space between grey box border and text
\setlength{\mylen}{\textwidth}
\addtolength{\mylen}{-2\myhi}
\renewcommand{\DOCH}{%
\settowidth{\py}{\CNoV\thechapter}
\addtolength{\py}{-10pt} % Amount of space by which the
% % number is shifted right
\fboxsep=0pt%
\colorbox[gray]{.85}{\rule{0pt}{40pt}\parbox[b]{\textwidth}{\hfill}}%
\kern-\py\raise20pt%
\hbox{\color[gray]{.5}\CNoV\thechapter}\\%
}
\renewcommand{\DOTI}[1]{%
\nointerlineskip\raggedright%
\fboxsep=\myhi%
\vskip-1ex%
\colorbox[gray]{.85}{\parbox[t]{\mylen}{\CTV\FmTi{#1}}}\par\nobreak%
\vskip 40\p@%
}
\renewcommand{\DOTIS}[1]{%
\fboxsep=0pt
\colorbox[gray]{.85}{\rule{0pt}{40pt}\parbox[b]{\textwidth}{\hfill}}\\%
\nointerlineskip\raggedright%
\fboxsep=\myhi%
\colorbox[gray]{.85}{\parbox[t]{\mylen}{\CTV\FmTi{#1}}}\par\nobreak%
\vskip 40\p@%
}
}
%%%%%%% GLENN DEF
\DeclareOption{Glenn}{%
\ChNameVar{\bfseries\Large\sf}
\ChNumVar{\Huge}
\ChTitleVar{\bfseries\Large\rm}
\ChRuleWidth{1pt}
\ChNameUpperCase
\ChTitleUpperCase
\renewcommand{\DOCH}{%
\settoheight{\myhi}{\CTV\FmTi{Test}}
\setlength{\py}{\baselineskip}
\addtolength{\py}{\RW}
\addtolength{\py}{\myhi}
\setlength{\pyy}{\py}
\addtolength{\pyy}{-1\RW}
\raggedright
\CNV\FmN{\@chapapp}\space\CNoV\thechapter
\hskip 3pt\mghrulefill{\RW}\rule[-1\pyy]{2\RW}{\py}\par\nobreak}
\renewcommand{\DOTI}[1]{%
\addtolength{\pyy}{-4pt}
\settoheight{\myhi}{\CTV\FmTi{#1}}
\addtolength{\myhi}{\py}
\addtolength{\myhi}{-1\RW}
\vskip -1\pyy
\rule{2\RW}{\myhi}\mghrulefill{\RW}\hskip 2pt
\raggedleft\CTV\FmTi{#1}\par\nobreak
\vskip 80\p@}
\newlength{\backskip}
\renewcommand{\DOTIS}[1]{%
% \setlength{\py}{10pt}
% \setlength{\pyy}{\py}
% \addtolength{\pyy}{\RW}
% \setlength{\myhi}{\baselineskip}
% \addtolength{\myhi}{\pyy}
% \mghrulefill{\RW}\rule[-1\py]{2\RW}{\pyy}\par\nobreak
% \addtolength{}{}
%\vskip -1\baselineskip
% \rule{2\RW}{\myhi}\mghrulefill{\RW}\hskip 2pt
% \raggedleft\CTV\FmTi{#1}\par\nobreak
% \vskip 60\p@}
%% Fix suggested by Tomas Lundberg
\setlength{\py}{25pt} % eller vad man vill
\setlength{\pyy}{\py}
\setlength{\backskip}{\py}
\addtolength{\backskip}{2pt}
\addtolength{\pyy}{\RW}
\setlength{\myhi}{\baselineskip}
\addtolength{\myhi}{\pyy}
\mghrulefill{\RW}\rule[-1\py]{2\RW}{\pyy}\par\nobreak
\vskip -1\backskip
\rule{2\RW}{\myhi}\mghrulefill{\RW}\hskip 3pt %
\raggedleft\CTV\FmTi{#1}\par\nobreak
\vskip 40\p@}
}
%%%%%%% CONNY DEF
\DeclareOption{Conny}{%
\ChNameUpperCase
\ChTitleUpperCase
\ChNameVar{\centering\Huge\rm\bfseries}
\ChNumVar{\Huge}
\ChTitleVar{\centering\Huge\rm}
\ChRuleWidth{2pt}
\renewcommand{\DOCH}{%
\mghrulefill{3\RW}\par\nobreak
\vskip -0.5\baselineskip
\mghrulefill{\RW}\par\nobreak
\CNV\FmN{\@chapapp}\space \CNoV\thechapter
\par\nobreak
\vskip -0.5\baselineskip
}
\renewcommand{\DOTI}[1]{%
\mghrulefill{\RW}\par\nobreak
\CTV\FmTi{#1}\par\nobreak
\vskip 60\p@
}
\renewcommand{\DOTIS}[1]{%
\mghrulefill{\RW}\par\nobreak
\CTV\FmTi{#1}\par\nobreak
\vskip 60\p@
}
}
%%%%%%% REJNE DEF
\DeclareOption{Rejne}{%
\ChNameUpperCase
\ChTitleUpperCase
\ChNameVar{\centering\Large\rm}
\ChNumVar{\Huge}
\ChTitleVar{\centering\Huge\rm}
\ChRuleWidth{1pt}
\renewcommand{\DOCH}{%
\settoheight{\py}{\CNoV\thechapter}
\parskip=0pt plus 1pt % Set parskip to default, just in case v1.31
\addtolength{\py}{-1pt}
\CNV\FmN{\@chapapp}\par\nobreak
\vskip 20\p@
\setlength{\myhi}{2\baselineskip}
\setlength{\px}{\myhi}
\addtolength{\px}{-1\RW}
\rule[-1\px]{\RW}{\myhi}\mghrulefill{\RW}\hskip
10pt\raisebox{-0.5\py}{\CNoV\thechapter}\hskip 10pt\mghrulefill{\RW}\rule[-1\px]{\RW}{\myhi}\par\nobreak
\vskip -3\p@% Added -2pt vskip to correct for streched text v1.31
}
\renewcommand{\DOTI}[1]{%
\setlength{\mylen}{\textwidth}
\parskip=0pt plus 1pt % Set parskip to default, just in case v1.31
\addtolength{\mylen}{-2\RW}
{\vrule width\RW}\parbox{\mylen}{\CTV\FmTi{#1}}{\vrule width\RW}\par\nobreak%
\vskip -3pt\rule{\RW}{2\baselineskip}\mghrulefill{\RW}\rule{\RW}{2\baselineskip}%
\vskip 60\p@% Added -2pt in vskip to correct for streched text v1.31
}
\renewcommand{\DOTIS}[1]{%
\setlength{\py}{\fboxrule}
\setlength{\fboxrule}{\RW}
\setlength{\mylen}{\textwidth}
\addtolength{\mylen}{-2\RW}
\fbox{\parbox{\mylen}{\vskip 2\baselineskip\CTV\FmTi{#1}\par\nobreak\vskip \baselineskip}}
\setlength{\fboxrule}{\py}
\vskip 60\p@
}
}
%%%%%%% BJARNE DEF
\DeclareOption{Bjarne}{%
\ChNameUpperCase
\ChTitleUpperCase
\ChNameVar{\raggedleft\normalsize\rm}
\ChNumVar{\raggedleft \bfseries\Large}
\ChTitleVar{\raggedleft \Large\rm}
\ChRuleWidth{1pt}
%% Note thechapter -> c@chapter fix appendix bug
%% Fixed misspelled 12
\newcounter{AlphaCnt}
\newcounter{AlphaDecCnt}
\newcommand{\AlphaNo}{%
\ifcase\number\theAlphaCnt
\ifnum\c@chapter=0
ZERO\else{}\fi
\or ONE\or TWO\or THREE\or FOUR\or FIVE
\or SIX\or SEVEN\or EIGHT\or NINE\or TEN
\or ELEVEN\or TWELVE\or THIRTEEN\or FOURTEEN\or FIFTEEN
\or SIXTEEN\or SEVENTEEN\or EIGHTEEN\or NINETEEN\fi
}
\newcommand{\AlphaDecNo}{%
\setcounter{AlphaDecCnt}{0}
\@whilenum\number\theAlphaCnt>0\do
{\addtocounter{AlphaCnt}{-10}
\addtocounter{AlphaDecCnt}{1}}
\ifnum\number\theAlphaCnt=0
\else
\addtocounter{AlphaDecCnt}{-1}
\addtocounter{AlphaCnt}{10}
\fi
\ifcase\number\theAlphaDecCnt\or TEN\or TWENTY\or THIRTY\or
FORTY\or FIFTY\or SIXTY\or SEVENTY\or EIGHTY\or NINETY\fi
}
\newcommand{\TheAlphaChapter}{%
\ifinapp
\thechapter
\else
\setcounter{AlphaCnt}{\c@chapter}
\ifnum\c@chapter<20
\AlphaNo
\else
\AlphaDecNo\AlphaNo
\fi
\fi
}
\renewcommand{\DOCH}{%
\mghrulefill{\RW}\par\nobreak
\CNV\FmN{\@chapapp}\par\nobreak
\CNoV\TheAlphaChapter\par\nobreak
\vskip -1\baselineskip\vskip 5pt\mghrulefill{\RW}\par\nobreak
\vskip 20\p@
}
\renewcommand{\DOTI}[1]{%
\CTV\FmTi{#1}\par\nobreak
\vskip 40\p@
}
\renewcommand{\DOTIS}[1]{%
\CTV\FmTi{#1}\par\nobreak
\vskip 40\p@
}
}
\DeclareOption*{%
\PackageWarning{fancychapter}{unknown style option}
}
\ProcessOptions* \relax
\ifusecolor
\RequirePackage{color}
\fi
\def\@makechapterhead#1{%
\vspace*{50\p@}%
{\parindent \z@ \raggedright \normalfont
\ifnum \c@secnumdepth >\m@ne
\if@mainmatter%%%%% Fix for frontmatter, mainmatter, and backmatter 040920
\DOCH
\fi
\fi
\interlinepenalty\@M
\if@mainmatter%%%%% Fix for frontmatter, mainmatter, and backmatter 060424
\DOTI{#1}%
\else%
\DOTIS{#1}%
\fi
}}
%%% Begin: To avoid problem with scrbook.cls (fncychap version 1.32)
%%OUT:
%\def\@schapter#1{\if@twocolumn
% \@topnewpage[\@makeschapterhead{#1}]%
% \else
% \@makeschapterhead{#1}%
% \@afterheading
% \fi}
%%IN:
\def\@schapter#1{%
\if@twocolumn%
\@makeschapterhead{#1}%
\else%
\@makeschapterhead{#1}%
\@afterheading%
\fi}
%%% End: To avoid problem with scrbook.cls (fncychap version 1.32)
\def\@makeschapterhead#1{%
\vspace*{50\p@}%
{\parindent \z@ \raggedright
\normalfont
\interlinepenalty\@M
\DOTIS{#1}
\vskip 40\p@
}}
\endinput

548
latex-helpers/framed.sty Normal file
View File

@ -0,0 +1,548 @@
% framed.sty v 0.96 2011/10/22
% Copyright (C) 1992-2011 by Donald Arseneau (asnd@triumf.ca)
% These macros may be freely transmitted, reproduced, or modified
% for any purpose provided that this notice is left intact.
%
%====================== Begin Instructions =======================
%
% framed.sty
% ~~~~~~~~~~
% Create framed, shaded, or differently highlighted regions that can
% break across pages. The environments defined are
% framed - ordinary frame box (\fbox) with edge at margin
% oframed - framed with open top/bottom at page breaks
% shaded - shaded background (\colorbox) bleeding into margin
% shaded* - shaded background (\colorbox) with edge at margin
% snugshade - shaded with tight fit around text (esp. in lists)
% snugshade* - like snugshade with shading edge at margin
% leftbar - thick vertical line in left margin
%
% to be used like
% \begin{framed}
% copious text
% \end{framed}
%
% But the more general purpose of this package is to facilitate the
% definition of new environments that take multi-line material,
% wrap it with some non-breakable formatting (some kind of box or
% decoration) and allow page breaks in the material. Such environments
% are defined to declare (or use) \FrameCommand for applying the boxy
% decoration, and \MakeFramed{settings} ... \endMakeFramed wrapped
% around the main text argument (environment body).
%
% The "framed" environment uses "\fbox", by default, as its "\FrameCommand"
% with the additional settings "\fboxrule=\FrameRule" and "\fboxsep=\FrameSep".
% You can change these lengths (using "\setlength") and you can change
% the definition of "\FrameCommand" to use much fancier boxes.
%
% In fact, the "shaded" environment just redefines \FrameCommand to be
% "\colorbox{shadecolor}" (and you have to define the color `"shadecolor"':
% "\definecolor{shadecolor}...").
%
% Although the intention is for other packages to define the varieties
% of decoration, a command "\OpenFbox" is defined for frames with open
% tops or bottoms, and used for the "oframed" environment. This facility
% is based on a more complex and capable command "\CustomFBox" which can
% be used for a wider range of frame styles. One such style of a title-bar
% frame with continuation marks is provided as an example. It is used by
% the "titled-frame" environment. To make use of "titled-frame" in your
% document, or the "\TitleBarFrame" command in your own environment
% definitions, you must define the colors TFFrameColor (for the frame)
% and a contrasting TFTitleColor (for the title text).
%
% A page break is allowed, and even encouraged, before the framed
% environment. If you want to attach some text (a box title) to the
% frame, then the text should be inserted by \FrameCommand so it cannot
% be separated from the body.
%
% The contents of the framed regions are restricted:
% Floats, footnotes, marginpars and head-line entries will be lost.
% (Some of these may be handled in a later version.)
% This package will not work with the page breaking of multicol.sty,
% or other systems that perform column-balancing.
%
% The MakeFramed environment does the work. Its `settings' argument
% should contain any adjustments to the text width (via a setting of
% "\hsize"). Here, the parameter "\width" gives the measured extra width
% added by the frame, so a common setting is "\advance\hsize-\width"
% which reduces the width of the text just enough that the outer edge
% of the frame aligns with the margins. The `settings' should also
% include a `restore' command -- "\@parboxrestore" or "\FrameRestore"
% or something similar; for instance, the snugshade environment uses
% settings to eliminate list indents and vertical space, but uses
% "\hspace" in "\FrameCommand" to reproduce the list margin ouside the
% shading.
%
% There are actually four variants of "\FrameCommand" to allow different
% formatting for each part of an environment broken over pages. Unbroken
% text is adorned by "\FrameCommand", whereas split text first uses
% "\FirstFrameCommand", possibly followed by "\MidFrameCommand", and
% finishing with "\LastFrameCommand". The default definitions for
% these three just invokes "\FrameCommand", so that all portions are
% framed the same way. See the oframe environment for use of distinct
% First/Mid/Last frames.
%
% Expert commands:
% \MakeFramed, \endMakeFramed: the "MakeFramed" environment
% \FrameCommand: command to draw the frame around its argument
% \FirstFrameCommand: the frame for the first part of a split environment
% \LastFrameCommand: for the last portion
% \MidFrameCommand: for any intermediate segments
% \FrameRestore: restore some text settings, but fewer than \@parboxrestore
% \FrameRule: length register; \fboxrule for default "framed".
% \FrameSep: length register; \fboxsep for default "framed".
% \FrameHeightAdjust: macro; height of frame above baseline at top of page
% \OuterFrameSep: vertical space before and after the framed env. Defaults to "\topsep"
%
% This is still a `pre-production' version because I can think of many
% features/improvements that should be made. Also, a detailed manual needs
% to be written. Nevertheless, starting with version 0.5 it should be bug-free.
%
% ToDo:
% Test more varieties of list
% Improve and correct documentation
% Propagation of \marks
% Handle footnotes (how??) floats (?) and marginpars.
% Stretchability modification.
% Make inner contents height/depth influence placement.
%======================== End Instructions ========================
\ProvidesPackage{framed}[2011/10/22 v 0.96:
framed or shaded text with page breaks]
\newenvironment{framed}% using default \FrameCommand
{\MakeFramed {\advance\hsize-\width \FrameRestore}}%
{\endMakeFramed}
\newenvironment{shaded}{%
\def\FrameCommand{\fboxsep=\FrameSep \colorbox{shadecolor}}%
\MakeFramed {\FrameRestore}}%
{\endMakeFramed}
\newenvironment{shaded*}{%
\def\FrameCommand{\fboxsep=\FrameSep \colorbox{shadecolor}}%
\MakeFramed {\advance\hsize-\width \FrameRestore}}%
{\endMakeFramed}
\newenvironment{leftbar}{%
\def\FrameCommand{\vrule width 3pt \hspace{10pt}}%
\MakeFramed {\advance\hsize-\width \FrameRestore}}%
{\endMakeFramed}
% snugshde: Shaded environment that
% -- uses the default \fboxsep instead of \FrameSep
% -- leaves the text indent unchanged (shading bleeds out)
% -- eliminates possible internal \topsep glue (\@setminipage)
% -- shrinks inside the margins for lists
% An \item label will tend to hang outside the shading, thanks to
% the small \fboxsep.
\newenvironment{snugshade}{%
\def\FrameCommand##1{\hskip\@totalleftmargin \hskip-\fboxsep
\colorbox{shadecolor}{##1}\hskip-\fboxsep
% There is no \@totalrightmargin, so:
\hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth}%
\MakeFramed {\advance\hsize-\width
\@totalleftmargin\z@ \linewidth\hsize
\@setminipage}%
}{\par\unskip\@minipagefalse\endMakeFramed}
\newenvironment{snugshade*}{%
\def\FrameCommand##1{\hskip\@totalleftmargin
\colorbox{shadecolor}{##1}%
% There is no \@totalrightmargin, so:
\hskip-\linewidth \hskip-\@totalleftmargin \hskip\columnwidth}%
\MakeFramed {\advance\hsize-\width
\@totalleftmargin\z@ \linewidth\hsize
\advance\labelsep\fboxsep
\@setminipage}%
}{\par\unskip\@minipagefalse\endMakeFramed}
\newenvironment{oframed}{% open (top or bottom) framed
\def\FrameCommand{\OpenFBox\FrameRule\FrameRule}%
\def\FirstFrameCommand{\OpenFBox\FrameRule\z@}%
\def\MidFrameCommand{\OpenFBox\z@\z@}%
\def\LastFrameCommand{\OpenFBox\z@\FrameRule}%
\MakeFramed {\advance\hsize-\width \FrameRestore}%
}{\endMakeFramed}
% A simplified entry to \CustomFBox with two customized parameters:
% the thicknesses of the top and bottom rules. Perhaps we want to
% use less \fboxsep on the open edges?
\def\OpenFBox#1#2{\fboxsep\FrameSep
\CustomFBox{}{}{#1}{#2}\FrameRule\FrameRule}
% \CustomFBox is like an amalgamation of \fbox and \@frameb@x,
% so it can be used by an alternate to \fbox or \fcolorbox, but
% it has more parameters for various customizations.
% Parameter #1 is inserted (in vmode) right after the top rule
% (useful for a title or assignments), and #2 is similar, but
% inserted right above the bottom rule.
% The thicknesses of the top, bottom, left, and right rules are
% given as parameters #3,#4,#5,#6 respectively. They should be
% \fboxrule or \z@ (or some other thickness).
% The text argument is #7.
% An instance of this can be used for the frame of \fcolorbox by
% locally defining \fbox before \fcolorbox; e.g.,
% \def\fbox{\CustomFBox{}{}\z@\z@\fboxrule\fboxrule}\fcolorbox
%
% Do we need to use different \fboxsep on different sides too?
%
\long\def\CustomFBox#1#2#3#4#5#6#7{%
\leavevmode\begingroup
\setbox\@tempboxa\hbox{%
\color@begingroup
\kern\fboxsep{#7}\kern\fboxsep
\color@endgroup}%
\hbox{%
% Here we calculate and shift for the depth. Done in
% a group because one of the arguments might be \@tempdima
% (we could use \dimexpr instead without grouping).
\begingroup
\@tempdima#4\relax
\advance\@tempdima\fboxsep
\advance\@tempdima\dp\@tempboxa
\expandafter\endgroup\expandafter
\lower\the\@tempdima\hbox{%
\vbox{%
\hrule\@height#3\relax
#1%
\hbox{%
\vrule\@width#5\relax
\vbox{%
\vskip\fboxsep % maybe these should be parameters too
\copy\@tempboxa
\vskip\fboxsep}%
\vrule\@width#6\relax}%
#2%
\hrule\@height#4\relax}%
}%
}%
\endgroup
}
% A particular type of titled frame with continuation marks.
% Parameter #1 is the title, repeated on each page.
\newenvironment{titled-frame}[1]{%
\def\FrameCommand{\fboxsep8pt\fboxrule2pt
\TitleBarFrame{\textbf{#1}}}%
\def\FirstFrameCommand{\fboxsep8pt\fboxrule2pt
\TitleBarFrame[$\blacktriangleright$]{\textbf{#1}}}%
\def\MidFrameCommand{\fboxsep8pt\fboxrule2pt
\TitleBarFrame[$\blacktriangleright$]{\textbf{#1\ (cont)}}}%
\def\LastFrameCommand{\fboxsep8pt\fboxrule2pt
\TitleBarFrame{\textbf{#1\ (cont)}}}%
\MakeFramed{\advance\hsize-20pt \FrameRestore}}%
% note: 8 + 2 + 8 + 2 = 20. Don't use \width because the frame title
% could interfere with the width measurement.
{\endMakeFramed}
% \TitleBarFrame[marker]{title}{contents}
% Frame with a label at top, optional continuation marker at bottom right.
% Frame color is TFFrameColor and title color is a contrasting TFTitleColor;
% both need to be defined before use. The frame itself use \fboxrule and
% \fboxsep. If the title is omitted entirely, the title bar is omitted
% (use a blank space to force a blank title bar).
%
\newcommand\TitleBarFrame[3][]{\begingroup
\ifx\delimiter#1\delimiter
\let\TF@conlab\@empty
\else
\def\TF@conlab{% continuation label
\nointerlineskip
\smash{\rlap{\kern\wd\@tempboxa\kern\fboxrule\kern\fboxsep #1}}}%
\fi
\let\TF@savecolor\current@color
\textcolor{TFFrameColor}{%
\CustomFBox
{\TF@Title{#2}}{\TF@conlab}%
\fboxrule\fboxrule\fboxrule\fboxrule
{\let\current@color\TF@savecolor\set@color #3}%
}\endgroup
}
% The title bar for \TitleBarFrame
\newcommand\TF@Title[1]{%
\ifx\delimiter#1\delimiter\else
\kern-0.04pt\relax
\begingroup
\setbox\@tempboxa\vbox{%
\kern0.8ex
\hbox{\kern\fboxsep\textcolor{TFTitleColor}{#1}\vphantom{Tj)}}%
\kern0.8ex}%
\hrule\@height\ht\@tempboxa
\kern-\ht\@tempboxa
\box\@tempboxa
\endgroup
\nointerlineskip
\kern-0.04pt\relax
\fi
}
\chardef\FrameRestore=\catcode`\| % for debug
\catcode`\|=\catcode`\% % (debug: insert space after backslash)
\newlength\OuterFrameSep \OuterFrameSep=\maxdimen \relax
\def\MakeFramed#1{\par
% apply default \OuterFrameSep = \topsep
\ifdim\OuterFrameSep=\maxdimen \OuterFrameSep\topsep \fi
% measure added width and height; call result \width and \height
\fb@sizeofframe\FrameCommand
\let\width\fb@frw \let\height\fb@frh
% insert pre-penalties and skips
\begingroup
\skip@\lastskip
\if@nobreak\else
\penalty9999 % updates \page parameters
\ifdim\pagefilstretch=\z@ \ifdim\pagefillstretch=\z@
% not infinitely stretchable, so encourage a page break here
\edef\@tempa{\the\skip@}%
\ifx\@tempa\zero@glue \penalty-30
\else \vskip-\skip@ \penalty-30 \vskip\skip@
\fi\fi\fi
\penalty\z@
% Give a stretchy breakpoint that will always be taken in preference
% to the \penalty 9999 used to update page parameters. The cube root
% of 10000/100 indicates a multiplier of 0.21545, but the maximum
% calculated badness is really 8192, not 10000, so the multiplier
% is 0.2301.
\advance\skip@ \z@ plus-.5\baselineskip
\advance\skip@ \z@ plus-.231\height
\advance\skip@ \z@ plus-.231\skip@
\advance\skip@ \z@ plus-.231\OuterFrameSep
\vskip-\skip@ \penalty 1800 \vskip\skip@
\fi
\addvspace{\OuterFrameSep}%
\endgroup
% clear out pending page break
\penalty\@M \vskip 2\baselineskip \vskip\height
\penalty9999 \vskip -2\baselineskip \vskip-\height
\penalty9999 % updates \pagetotal
|\message{After clearout, \pagetotal=\the\pagetotal, \pagegoal=\the\pagegoal. }%
\fb@adjheight
\setbox\@tempboxa\vbox\bgroup
#1% Modifications to \hsize (can use \width and \height)
\textwidth\hsize \columnwidth\hsize
}
\def\endMakeFramed{\par
\kern\z@
\hrule\@width\hsize\@height\z@ % possibly bad
\penalty-100 % (\hrule moves depth into height)
\egroup
%%% {\showoutput\showbox\@tempboxa}%
\begingroup
\fb@put@frame\FrameCommand\FirstFrameCommand
\endgroup
\@minipagefalse % In case it was set and not cleared
}
% \fb@put@frame takes the contents of \@tempboxa and puts all, or a piece,
% of it on the page with a frame (\FrameCommand, \FirstFrameCommand,
% \MidFrameCommand, or \LastFrameCommand). It recurses until all of
% \@tempboxa has been used up. (\@tempboxa must have zero depth.)
% #1 = attempted framing command, if no split
% #2 = framing command if split
% First iteration: Try to fit with \FrameCommand. If it does not fit,
% split for \FirstFrameCommand.
% Later iteration: Try to fit with \LastFrameCommand. If it does not
% fit, split for \MidFrameCommand.
\def\fb@put@frame#1#2{\relax
\ifdim\pagegoal=\maxdimen \pagegoal\vsize \fi
| \message{=============== Entering putframe ====================^^J
| \pagegoal=\the\pagegoal, \pagetotal=\the\pagetotal. }%
\ifinner
\fb@putboxa#1%
\fb@afterframe
\else
\dimen@\pagegoal \advance\dimen@-\pagetotal % natural space left on page
\ifdim\dimen@<2\baselineskip % Too little room on page
| \message{Page has only \the\dimen@\space room left; eject. }%
\eject \fb@adjheight \fb@put@frame#1#2%
\else % there's appreciable room left on the page
\fb@sizeofframe#1%
| \message{\string\pagetotal=\the\pagetotal,
| \string\pagegoal=\the\pagegoal,
| \string\pagestretch=\the\pagestretch,
| \string\pageshrink=\the\pageshrink,
| \string\fb@frh=\the\fb@frh. \space}
| \message{^^JBox of size \the\ht\@tempboxa\space}%
\begingroup % temporarily set \dimen@ to be...
\advance\dimen@.8\pageshrink % maximum space available on page
\advance\dimen@-\fb@frh\relax % max space available for frame's contents
%%% LOOKS SUBTRACTED AND ADDED, SO DOUBLE ACCOUNTING!
\expandafter\endgroup
% expand \ifdim, then restore \dimen@ to real room left on page
\ifdim\dimen@>\ht\@tempboxa % whole box does fit
| \message{fits in \the\dimen@. }%
% ToDo: Change this to use vsplit anyway to capture the marks
% MERGE THIS WITH THE else CLAUSE!!!
\fb@putboxa#1%
\fb@afterframe
\else % box must be split
| \message{must be split to fit in \the\dimen@. }%
% update frame measurement to use \FirstFrameCommand or \MidFrameCommand
\fb@sizeofframe#2%
\setbox\@tempboxa\vbox{% simulate frame and flexiblity of the page:
\vskip \fb@frh \@plus\pagestretch \@minus.8\pageshrink
\kern137sp\kern-137sp\penalty-30
\unvbox\@tempboxa}%
\edef\fb@resto@set{\boxmaxdepth\the\boxmaxdepth
\splittopskip\the\splittopskip}%
\boxmaxdepth\z@ \splittopskip\z@
| \message{^^JPadded box of size \the\ht\@tempboxa\space split to \the\dimen@}%
% Split box here
\setbox\tw@\vsplit\@tempboxa to\dimen@
| \toks99\expandafter{\splitfirstmark}%
| \toks98\expandafter{\splitbotmark}%
| \message{Marks are: \the\toks99, \the\toks98. }%
\setbox\tw@\vbox{\unvbox\tw@}% natural-sized
| \message{Natural height of split box is \the\ht\tw@, leaving
| \the\ht\@tempboxa\space remainder. }%
% If the split-to size > (\vsize-\topskip), then set box to full size.
\begingroup
\advance\dimen@\topskip
\expandafter\endgroup
\ifdim\dimen@>\pagegoal
| \message{Frame is big -- Use up the full column. }%
\dimen@ii\pagegoal
\advance\dimen@ii -\topskip
\advance\dimen@ii \FrameHeightAdjust\relax
\else % suspect this is implemented incorrectly:
% If the split-to size > feasible room_on_page, rebox it smaller.
\advance\dimen@.8\pageshrink
\ifdim\ht\tw@>\dimen@
| \message{Box too tall; rebox it to \the\dimen@. }%
\dimen@ii\dimen@
\else % use natural size
\dimen@ii\ht\tw@
\fi
\fi
% Re-box contents to desired size \dimen@ii
\advance\dimen@ii -\fb@frh
\setbox\tw@\vbox to\dimen@ii \bgroup
% remove simulated frame and page flexibility:
\vskip -\fb@frh \@plus-\pagestretch \@minus-.8\pageshrink
\unvbox\tw@ \unpenalty\unpenalty
\ifdim\lastkern=-137sp % whole box went to next page
| \message{box split at beginning! }%
% need work here???
\egroup \fb@resto@set \eject % (\vskip for frame size was discarded)
\fb@adjheight
\fb@put@frame#1#2% INSERTED ???
\else % Got material split off at the head
\egroup \fb@resto@set
\ifvoid\@tempboxa % it all fit after all
| \message{box split at end! }%
\setbox\@tempboxa\box\tw@
\fb@putboxa#1%
\fb@afterframe
\else % it really did split
| \message{box split as expected. Its reboxed height is \the\ht\tw@. }%
\ifdim\wd\tw@>\z@
\wd\tw@\wd\@tempboxa
\centerline{#2{\box\tw@}}% ??? \centerline bad idea
\else
| \message{Zero width means likely blank. Don't frame it (guess)}%
\box\tw@
\fi
\hrule \@height\z@ \@width\hsize
\eject
\fb@adjheight
\fb@put@frame\LastFrameCommand\MidFrameCommand
\fi\fi\fi\fi\fi
}
\def\fb@putboxa#1{%
\ifvoid\@tempboxa
\PackageWarning{framed}{Boxa is void -- discard it. }%
\else
| \message{Frame and place boxa. }%
| %{\showoutput\showbox\@tempboxa}%
\centerline{#1{\box\@tempboxa}}%
\fi
}
\def\fb@afterframe{%
\nointerlineskip \null %{\showoutput \showlists}
\penalty-30 \vskip\OuterFrameSep \relax
}
% measure width and height added by frame (#1 = frame command)
% call results \fb@frw and \fb@frh
% todo: a mechanism to handle wide frame titles
\newdimen\fb@frw
\newdimen\fb@frh
\def\fb@sizeofframe#1{\begingroup
\setbox\z@\vbox{\vskip-5in \hbox{\hskip-5in
#1{\hbox{\vrule \@height 4.7in \@depth.3in \@width 5in}}}%
\vskip\z@skip}%
| \message{Measuring frame addition for \string#1 in \@currenvir\space
| gives ht \the\ht\z@\space and wd \the\wd\z@. }%
| %{\showoutput\showbox\z@}%
\global\fb@frw\wd\z@ \global\fb@frh\ht\z@
\endgroup
}
\def\fb@adjheight{%
\vbox to\FrameHeightAdjust{}% get proper baseline skip from above.
\penalty\@M \nointerlineskip
\vskip-\FrameHeightAdjust
\penalty\@M} % useful for tops of pages
\edef\zero@glue{\the\z@skip}
\catcode`\|=\FrameRestore
% Provide configuration commands:
\providecommand\FrameCommand{%
\setlength\fboxrule{\FrameRule}\setlength\fboxsep{\FrameSep}%
\fbox}
\@ifundefined{FrameRule}{\newdimen\FrameRule \FrameRule=\fboxrule}{}
\@ifundefined{FrameSep} {\newdimen\FrameSep \FrameSep =3\fboxsep}{}
\providecommand\FirstFrameCommand{\FrameCommand}
\providecommand\MidFrameCommand{\FrameCommand}
\providecommand\LastFrameCommand{\FrameCommand}
% Height of frame above first baseline when frame starts a page:
\providecommand\FrameHeightAdjust{6pt}
% \FrameRestore has parts of \@parboxrestore, performing a similar but
% less complete restoration of the default layout. See how it is used in
% the "settings" argument of \MakeFrame. Though not a parameter, \hsize
% should be set to the desired total line width available inside the
% frame before invoking \FrameRestore.
\def\FrameRestore{%
\let\if@nobreak\iffalse
\let\if@noskipsec\iffalse
\let\-\@dischyph
\let\'\@acci\let\`\@accii\let\=\@acciii
% \message{FrameRestore:
% \@totalleftmargin=\the \@totalleftmargin,
% \rightmargin=\the\rightmargin,
% \@listdepth=\the\@listdepth. }%
% Test if we are in a list (or list-like paragraph)
\ifnum \ifdim\@totalleftmargin>\z@ 1\fi
\ifdim\rightmargin>\z@ 1\fi
\ifnum\@listdepth>\z@ 1\fi 0>\z@
% \message{In a list: \linewidth=\the\linewidth, \@totalleftmargin=\the\@totalleftmargin,
% \parshape=\the\parshape, \columnwidth=\the\columnwidth, \hsize=\the\hsize,
% \labelwidth=\the\labelwidth. }%
\@setminipage % snug fit around the item. I would like this to be non-global.
% Now try to propageate changes of width from \hsize to list parameters.
% This is deficient, but a more advanced way to indicate modification to text
% dimensions is not (yet) provided; in particular, no separate left/right
% adjustment.
\advance\linewidth-\columnwidth \advance\linewidth\hsize
\parshape\@ne \@totalleftmargin \linewidth
\else % Not in list
\linewidth=\hsize
%\message{No list, set \string\linewidth=\the\hsize. }%
\fi
\sloppy
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

5
latex-helpers/notes.txt Normal file
View File

@ -0,0 +1,5 @@
needed for:
jupyter-book build . --builder pdflatex
copy into _build/latex

451
latex-helpers/tabulary.sty Normal file
View File

@ -0,0 +1,451 @@
%%
%% This is file `tabulary.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% tabulary.dtx (with options: `package')
%% DRAFT VERSION
%%
%% File `tabulary.dtx'.
%% Copyright (C) 1995 1996 2003 2008 David Carlisle
%% This file may be distributed under the terms of the LPPL.
%% See 00readme.txt for details.
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{tabulary}
[2014/06/11 v0.10 tabulary package (DPC)]
\RequirePackage{array}
\catcode`\Z=14
\DeclareOption{debugshow}{\catcode`\Z=9\relax}
\ProcessOptions
\def\arraybackslash{\let\\=\@arraycr}
\def\@finalstrut#1{%
\unskip\ifhmode\nobreak\fi\vrule\@width\z@\@height\z@\@depth\dp#1}
\newcount\TY@count
\def\tabulary{%
\let\TY@final\tabular
\let\endTY@final\endtabular
\TY@tabular}
\def\TY@tabular#1{%
\edef\TY@{\@currenvir}%
{\ifnum0=`}\fi
\@ovxx\TY@linewidth
\@ovyy\TY@tablewidth
\count@\z@
\@tempswatrue
\@whilesw\if@tempswa\fi{%
\advance\count@\@ne
\expandafter\ifx\csname TY@F\the\count@\endcsname\relax
\@tempswafalse
\else
\expandafter\let\csname TY@SF\the\count@\expandafter\endcsname
\csname TY@F\the\count@\endcsname
\global\expandafter\let\csname TY@F\the\count@\endcsname\relax
\expandafter\let\csname TY@S\the\count@\expandafter\endcsname
\csname TY@\the\count@\endcsname
\fi}%
\global\TY@count\@ne
\TY@width\xdef{0pt}%
\global\TY@tablewidth\z@
\global\TY@linewidth#1\relax
Z\message{^^J^^JTable^^J%
Z Target Width: \the\TY@linewidth^^J%
Z \string\tabcolsep: \the\tabcolsep\space
Z \string\arrayrulewidth: \the\arrayrulewidth\space
Z \string\doublerulesep: \the\doublerulesep^^J%
Z \string\tymin: \the\tymin\space
Z \string\tymax: \the\tymax^^J}%
\let\@classz\TY@classz
\let\verb\TX@verb
\toks@{}\TY@get@body}
\let\TY@@mkpream\@mkpream
\def\TY@mkpream{%
\def\@addamp{%
\if@firstamp \@firstampfalse \else
\global\advance\TY@count\@ne
\edef\@preamble{\@preamble &}\fi
\TY@width\xdef{0pt}}%
\def\@acol{%
\TY@subwidth\col@sep
\@addtopreamble{\hskip\col@sep}}%
\let\@arrayrule\TY@arrayrule
\let\@classvi\TY@classvi
\def\@classv{\save@decl
\expandafter\NC@ecs\@nextchar\extracolsep{}\extracolsep\@@@
\sbox\z@{\d@llarbegin\@nextchar\d@llarend}%
\TY@subwidth{\wd\z@}%
\@addtopreamble{\d@llarbegin\the@toks\the\count@\relax\d@llarend}%
\prepnext@tok}%
\global\let\@mkpream\TY@@mkpream
\TY@@mkpream}
\def\TY@arrayrule{%
\TY@subwidth\arrayrulewidth
\@addtopreamble \vline}
\def\TY@classvi{\ifcase \@lastchclass
\@acol \or
\TY@subwidth\doublerulesep
\@addtopreamble{\hskip \doublerulesep}\or
\@acol \or
\@classvii
\fi}
\def\TY@tab{%
\setbox\z@\hbox\bgroup
\let\[$\let\]$%
\let\equation$\let\endequation$%
\col@sep\tabcolsep
\let\d@llarbegin\begingroup\let\d@llarend\endgroup
\let\@mkpream\TY@mkpream
\def\multicolumn##1##2##3{\multispan##1\relax}%
\CT@start\TY@tabarray}
\def\TY@tabarray{\@ifnextchar[{\TY@array}{\@array[t]}}
\def\TY@array[#1]{\@array[t]}
\def\TY@width#1{%
\expandafter#1\csname TY@\the\TY@count\endcsname}
\def\TY@subwidth#1{%
\TY@width\dimen@
\advance\dimen@-#1\relax
\TY@width\xdef{\the\dimen@}%
\global\advance\TY@linewidth-#1\relax}
\def\endtabulary{%
\gdef\@halignto{}%
\expandafter\TY@tab\the\toks@
\crcr\omit
{\xdef\TY@save@row{}%
\loop
\advance\TY@count\m@ne
\ifnum\TY@count>\z@
\xdef\TY@save@row{\TY@save@row&\omit}%
\repeat}\TY@save@row
\endarray\global\setbox1=\lastbox\setbox0=\vbox{\unvbox1
\unskip\global\setbox1=\lastbox}\egroup
\dimen@\TY@linewidth
\divide\dimen@\TY@count
\ifdim\dimen@<\tymin
\TY@warn{tymin too large (\the\tymin), resetting to \the\dimen@}%
\tymin\dimen@
\fi
\setbox\tw@=\hbox{\unhbox\@ne
\loop
\@tempdima=\lastskip
\ifdim\@tempdima>\z@
Z \message{ecs=\the\@tempdima^^J}%
\global\advance\TY@linewidth-\@tempdima
\fi
\unskip
\setbox\tw@=\lastbox
\ifhbox\tw@
Z \message{Col \the\TY@count: Initial=\the\wd\tw@\space}%
\ifdim\wd\tw@>\tymax
\wd\tw@\tymax
Z \message{> max\space}%
Z \else
Z \message{ \@spaces\space}%
\fi
\TY@width\dimen@
Z \message{\the\dimen@\space}%
\advance\dimen@\wd\tw@
Z \message{Final=\the\dimen@\space}%
\TY@width\xdef{\the\dimen@}%
\ifdim\dimen@<\tymin
Z \message{< tymin}%
\global\advance\TY@linewidth-\dimen@
\expandafter\xdef\csname TY@F\the\TY@count\endcsname
{\the\dimen@}%
\else
\expandafter\ifx\csname TY@F\the\TY@count\endcsname\z@
Z \message{***}%
\global\advance\TY@linewidth-\dimen@
\expandafter\xdef\csname TY@F\the\TY@count\endcsname
{\the\dimen@}%
\else
Z \message{> tymin}%
\global\advance\TY@tablewidth\dimen@
\global\expandafter\let\csname TY@F\the\TY@count\endcsname
\maxdimen
\fi\fi
\advance\TY@count\m@ne
\repeat}%
\TY@checkmin
\TY@checkmin
\TY@checkmin
\TY@checkmin
\TY@count\z@
\let\TY@box\TY@box@v
{\expandafter\TY@final\the\toks@\endTY@final}%
\count@\z@
\@tempswatrue
\@whilesw\if@tempswa\fi{%
\advance\count@\@ne
\expandafter\ifx\csname TY@SF\the\count@\endcsname\relax
\@tempswafalse
\else
\global\expandafter\let\csname TY@F\the\count@\expandafter\endcsname
\csname TY@SF\the\count@\endcsname
\global\expandafter\let\csname TY@\the\count@\expandafter\endcsname
\csname TY@S\the\count@\endcsname
\fi}%
\TY@linewidth\@ovxx
\TY@tablewidth\@ovyy
\ifnum0=`{\fi}}
\def\TY@checkmin{%
\let\TY@checkmin\relax
\ifdim\TY@tablewidth>\z@
\Gscale@div\TY@ratio\TY@linewidth\TY@tablewidth
\ifdim\TY@tablewidth <\TY@linewidth
\def\TY@ratio{1}%
\fi
\else
\TY@warn{No suitable columns!}%
\def\TY@ratio{1}%
\fi
\count@\z@
Z \message{^^JLine Width: \the\TY@linewidth,
Z Natural Width: \the\TY@tablewidth,
Z Ratio: \TY@ratio^^J}%
\@tempdima\z@
\loop
\ifnum\count@<\TY@count
\advance\count@\@ne
\ifdim\csname TY@F\the\count@\endcsname>\tymin
\dimen@\csname TY@\the\count@\endcsname
\dimen@\TY@ratio\dimen@
\ifdim\dimen@<\tymin
Z \message{Column \the\count@\space ->}%
\global\expandafter\let\csname TY@F\the\count@\endcsname\tymin
\global\advance\TY@linewidth-\tymin
\global\advance\TY@tablewidth-\csname TY@\the\count@\endcsname
\let\TY@checkmin\TY@@checkmin
\else
\expandafter\xdef\csname TY@F\the\count@\endcsname{\the\dimen@}%
\advance\@tempdima\csname TY@F\the\count@\endcsname
\fi
\fi
Z \dimen@\csname TY@F\the\count@\endcsname\message{\the\dimen@, }%
\repeat
Z \message{^^JTotal:\the\@tempdima^^J}%
}
\let\TY@@checkmin\TY@checkmin
\newdimen\TY@linewidth
\def\tyformat{\everypar{{\nobreak\hskip\z@skip}}}
\newdimen\tymin
\tymin=10pt
\newdimen\tymax
\tymax=2\textwidth
\def\@testpach{\@chclass
\ifnum \@lastchclass=6 \@ne \@chnum \@ne \else
\ifnum \@lastchclass=7 5 \else
\ifnum \@lastchclass=8 \tw@ \else
\ifnum \@lastchclass=9 \thr@@
\else \z@
\ifnum \@lastchclass = 10 \else
\edef\@nextchar{\expandafter\string\@nextchar}%
\@chnum
\if \@nextchar c\z@ \else
\if \@nextchar l\@ne \else
\if \@nextchar r\tw@ \else
\if \@nextchar C7 \else
\if \@nextchar L8 \else
\if \@nextchar R9 \else
\if \@nextchar J10 \else
\z@ \@chclass
\if\@nextchar |\@ne \else
\if \@nextchar !6 \else
\if \@nextchar @7 \else
\if \@nextchar <8 \else
\if \@nextchar >9 \else
10
\@chnum
\if \@nextchar m\thr@@\else
\if \@nextchar p4 \else
\if \@nextchar b5 \else
\z@ \@chclass \z@ \@preamerr \z@ \fi \fi \fi \fi\fi \fi \fi\fi \fi
\fi \fi \fi \fi \fi \fi \fi \fi \fi \fi \fi}
\def\TY@classz{%
\@classx
\@tempcnta\count@
\ifx\TY@box\TY@box@v
\global\advance\TY@count\@ne
\fi
\let\centering c%
\let\raggedright\noindent
\let\raggedleft\indent
\let\arraybackslash\relax
\prepnext@tok
\ifnum\@chnum<4
\global\expandafter\let\csname TY@F\the\TY@count\endcsname\z@
\fi
\ifnum\@chnum=6
\global\expandafter\let\csname TY@F\the\TY@count\endcsname\z@
\fi
\@addtopreamble{%
\ifcase\@chnum
\hfil \d@llarbegin\insert@column\d@llarend \hfil \or
\kern\z@
\d@llarbegin \insert@column \d@llarend \hfil \or
\hfil\kern\z@ \d@llarbegin \insert@column \d@llarend \or
$\vcenter\@startpbox{\@nextchar}\insert@column \@endpbox $\or
\vtop \@startpbox{\@nextchar}\insert@column \@endpbox \or
\vbox \@startpbox{\@nextchar}\insert@column \@endpbox \or
\d@llarbegin \insert@column \d@llarend \or% dubious "s" case
\TY@box\centering\or
\TY@box\raggedright\or
\TY@box\raggedleft\or
\TY@box\relax
\fi}\prepnext@tok}
\def\TY@box#1{%
\ifx\centering#1%
\hfil \d@llarbegin\insert@column\d@llarend \hfil \else
\ifx\raggedright#1%
\kern\z@%<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
\d@llarbegin \insert@column \d@llarend \hfil \else
\ifx\raggedleft#1%
\hfil\kern\z@ \d@llarbegin \insert@column \d@llarend \else
\ifx\relax#1%
\d@llarbegin \insert@column \d@llarend
\fi \fi \fi \fi}
\def\TY@box@v#1{%
\vtop \@startpbox{\csname TY@F\the\TY@count\endcsname}%
#1\arraybackslash\tyformat
\insert@column\@endpbox}
\newdimen\TY@tablewidth
\def\Gscale@div#1#2#3{%
\setlength\dimen@{#3}%
\ifdim\dimen@=\z@
\PackageError{graphics}{Division by 0}\@eha
\dimen@#2%
\fi
\edef\@tempd{\the\dimen@}%
\setlength\dimen@{#2}%
\count@65536\relax
\ifdim\dimen@<\z@
\dimen@-\dimen@
\count@-\count@
\fi
\loop
\ifdim\dimen@<8192\p@
\dimen@\tw@\dimen@
\divide\count@\tw@
\repeat
\dimen@ii=\@tempd\relax
\divide\dimen@ii\count@
\divide\dimen@\dimen@ii
\edef#1{\strip@pt\dimen@}}
\long\def\TY@get@body#1\end
{\toks@\expandafter{\the\toks@#1}\TY@find@end}
\def\TY@find@end#1{%
\def\@tempa{#1}%
\ifx\@tempa\TY@\def\@tempa{\end{#1}}\expandafter\@tempa
\else\toks@\expandafter
{\the\toks@\end{#1}}\expandafter\TY@get@body\fi}
\def\TY@warn{%
\PackageWarning{tabulary}}
\catcode`\Z=11
\AtBeginDocument{
\@ifpackageloaded{colortbl}{%
\expandafter\def\expandafter\@mkpream\expandafter#\expandafter1%
\expandafter{%
\expandafter\let\expandafter\CT@setup\expandafter\relax
\expandafter\let\expandafter\CT@color\expandafter\relax
\expandafter\let\expandafter\CT@do@color\expandafter\relax
\expandafter\let\expandafter\color\expandafter\relax
\expandafter\let\expandafter\CT@column@color\expandafter\relax
\expandafter\let\expandafter\CT@row@color\expandafter\relax
\expandafter\let\expandafter\CT@cell@color\expandafter\relax
\@mkpream{#1}}
\let\TY@@mkpream\@mkpream
\def\TY@classz{%
\@classx
\@tempcnta\count@
\ifx\TY@box\TY@box@v
\global\advance\TY@count\@ne
\fi
\let\centering c%
\let\raggedright\noindent
\let\raggedleft\indent
\let\arraybackslash\relax
\prepnext@tok
\expandafter\CT@extract\the\toks\@tempcnta\columncolor!\@nil
\ifnum\@chnum<4
\global\expandafter\let\csname TY@F\the\TY@count\endcsname\z@
\fi
\ifnum\@chnum=6
\global\expandafter\let\csname TY@F\the\TY@count\endcsname\z@
\fi
\@addtopreamble{%
\setbox\z@\hbox\bgroup\bgroup
\ifcase\@chnum
\hskip\stretch{.5}\kern\z@
\d@llarbegin\insert@column\d@llarend\hskip\stretch{.5}\or
\kern\z@%<<<<<<<<<<<<<<<<<<<<<<<<<<<
\d@llarbegin \insert@column \d@llarend \hfill \or
\hfill\kern\z@ \d@llarbegin \insert@column \d@llarend \or
$\vcenter\@startpbox{\@nextchar}\insert@column \@endpbox $\or
\vtop \@startpbox{\@nextchar}\insert@column \@endpbox \or
\vbox \@startpbox{\@nextchar}\insert@column \@endpbox \or
\d@llarbegin \insert@column \d@llarend \or% dubious s case
\TY@box\centering\or
\TY@box\raggedright\or
\TY@box\raggedleft\or
\TY@box\relax
\fi
\egroup\egroup
\begingroup
\CT@setup
\CT@column@color
\CT@row@color
\CT@cell@color
\CT@do@color
\endgroup
\@tempdima\ht\z@
\advance\@tempdima\minrowclearance
\vrule\@height\@tempdima\@width\z@
\unhbox\z@
}\prepnext@tok}%
\def\TY@arrayrule{%
\TY@subwidth\arrayrulewidth
\@addtopreamble{{\CT@arc@\vline}}}%
\def\TY@classvi{\ifcase \@lastchclass
\@acol \or
\TY@subwidth\doublerulesep
\ifx\CT@drsc@\relax
\@addtopreamble{\hskip\doublerulesep}%
\else
\@addtopreamble{{\CT@drsc@\vrule\@width\doublerulesep}}%
\fi\or
\@acol \or
\@classvii
\fi}%
}{%
\let\CT@start\relax
}
}
{\uccode`\*=`\ %
\uppercase{\gdef\TX@verb{%
\leavevmode\null\TX@vwarn
{\ifnum0=`}\fi\ttfamily\let\\\ignorespaces
\@ifstar{\let~*\TX@vb}{\TX@vb}}}}
\def\TX@vb#1{\def\@tempa##1#1{\toks@{##1}\edef\@tempa{\the\toks@}%
\expandafter\TX@v\meaning\@tempa\\ \\\ifnum0=`{\fi}}\@tempa!}
\def\TX@v#1!{\afterassignment\TX@vfirst\let\@tempa= }
\begingroup
\catcode`\*=\catcode`\#
\catcode`\#=12
\gdef\TX@vfirst{%
\if\@tempa#%
\def\@tempb{\TX@v@#}%
\else
\let\@tempb\TX@v@
\if\@tempa\space~\else\@tempa\fi
\fi
\@tempb}
\gdef\TX@v@*1 *2{%
\TX@v@hash*1##\relax\if*2\\\else~\expandafter\TX@v@\fi*2}
\gdef\TX@v@hash*1##*2{*1\ifx*2\relax\else#\expandafter\TX@v@hash\fi*2}
\endgroup
\def\TX@vwarn{%
\@warning{\noexpand\verb may be unreliable inside tabularx/y}%
\global\let\TX@vwarn\@empty}
\endinput
%%
%% End of file `tabulary.sty'.

318
latex-helpers/varwidth.sty Normal file
View File

@ -0,0 +1,318 @@
% varwidth.sty v 0.92 Mar 2009 Donald Arseneau asnd@triumf.ca
%
% Copyright 2003-2004,2009 by Donald Arseneau (asnd@triumf.ca).
% This software is released under the terms of the LaTeX Project Public
% License (ftp://ctan.tug.org/tex-archive/macros/latex/base/lppl.txt).
% (Essentially: Free to use, copy, distribute (sell) and change, but, if
% changed, that fact must be clearly displayed to the user.)
%
% The varwidth environment is based on minipage, and takes the same
% parameters, but the specified width is just a maximum value -- the
% environment will be typeset with a narrower "natural" width if
% possible.
%
% In a varwidth environment, paragraph line-breaks are chosen
% according to the specified width, but each line is reset to
% match a narrower natural width, if there is one.
%
% The \narrowragged command works like \raggedright, but produces
% generally narrower lines in paragraphs, with more text in the last
% line (the lines have more-equal lengths).
%
% This version works fine, but there are still many questions about
% how it would work best. Should there be a version that avoids the
% usual minipage formatting style?
%
% Numbered equations are not handled well, especially with leqno.
% AMSmath environments have not been tried, and undoubtedly fail.
%
% To do: Extend v-list wrappers to handle all e-TeX primitives.
% (pdfTeX too?)
% Capture marks and floats, propagating them out of the box
% Support numbered equations, including ams math.
%
\ProvidesPackage{varwidth}[2009/03/30 ver 0.92; \space
Variable-width minipages]
\newcommand\narrowragged{\rightskip \z@ plus .25\hsize
\@rightskip\rightskip \parfillskip\z@ plus .15\hsize
\sloppy }
\newbox\@vwid@box
% The varwidth environment is based on minipage, and takes the same
% parameters, but the specified width is only a limit -- a narrower
% natural width may be used. \varwidth uses \minipage.
\def\varwidth{\let\@minipagerestore\@vwid@setup \minipage}
% Many things may appear on vertical lists that can't be re-processed,
% so they have to be modified.
\def\@vwid@setup{%
% several things can't appear in vertical mode, so they may get
% a \vbox wrapped around them.
\let\@bsphack\@vwid@bsphack % \label and others
\let\mark\@gobble % Marks disappear in minipages anyway
\let\special\@vwid@special % \color and others
\let\pdfliteral\@vwid@pdfliteral % \color and others
\let\addtocontents\@vwid@addtocontents % \addcontentsline
% Shifted boxes (\parshape,\hangindent) will have their shifts
% indicated in a separate box.
\let\@hangfrom\@vwid@hangfrom % hanging indents
\let\list\@vwid@list
\let\endtrivlist\@vwid@endtrivlist
\postdisplaypenalty\@vwid@posteqp
\predisplaypenalty\@vwid@preeqp
\def\@eqnnum{\aftergroup\@vwid@afterva\@@vwid@eqnnum}%
\global\@vwid@roff\z@ \global\@vwid@loff\z@
% Begin an inner minipage-like vertical box (in \@tempboxa)
\let\@minipagerestore\@@vwid@minipagerestore \@minipagerestore
\setbox\@tempboxa\vbox\bgroup\begingroup
% Flag the top of the list
\penalty\@vwid@toppen
}
\let\@@vwid@minipagerestore\@minipagerestore
% At end of varwidth environment.
\def\endvarwidth{\par\@@par
\unskip
% Handle minipage-style notes.
\ifvoid\@mpfootins\else
\vskip\skip\@mpfootins
\normalcolor
\@vwid@wrap\footnoterule
\unvbox\@mpfootins
\fi
\unskip
\@minipagefalse
\endgroup\egroup % got my \@tempboxa
%{\showoutput\showbox\@tempboxa}%
% in a discarded box, sift through list measuring max width.
\begingroup\setbox\z@\vbox\bgroup
%\message{-------------------------------------------------------------}%
%\message{First pass; hsize=\the\hsize... }%{\tracingall\showlists}%%
\unvcopy\@tempboxa
\@tempdima-\maxdimen
\let\@vwid@resetb\@vwid@measure
\let\@vwid@append\relax
\sift@deathcycles\z@
\@vwid@sift
\xdef\@vwid@{\the\@tempdima}%
\egroup\endgroup
% Done measuring. Now empty \@tempboxa onto current vertical list
% which is the contents of a minipage environment
%\message{Got natural width \@vwid@ (compare \the\hsize) }%
\unvbox\@tempboxa
% Choose the natural width or the declared width, whichever is smaller.
\ifdim\@vwid@<\hsize
\hsize\@vwid@
\fi
% Go through the vertical list reboxing and moving everything into
% \@vwid@box; then spill \@vwid@box. If the natural width is narrower,
\setbox\@vwid@box\vbox{}%
\sift@deathcycles\z@
%\message{----------------------------------------------------------------}%
%\message{Second pass; hsize=\the\hsize... }%{\tracingall\showlists}%
\@vwid@sift
%\message{After sifting:}%
%{\showoutput\showbox\@vwid@box}%
\unvbox\@vwid@box
% end the minipage environment
\endminipage}
%
% Here are definitions for sifting through the vertical list, either
% measuring things or reboxing them.
%
% Penalties used as signals to the vertical-list processor:
\mathchardef\@vwid@posteqp 17321 % Penalty below equations
\mathchardef\@vwid@preeqp 17322 % Penalty above equations
\mathchardef\@vwid@postnump 17323 % Penalty below numbered equations
\mathchardef\@vwid@toppen 17324 % Penalty marking top of vertical list
\mathchardef\@vwid@offsets 17325 % Penalty below special h-offsets box
\mathchardef\@vwid@postw 17326 % Penalty below a \vbox-wrapped object
\newcount\sift@deathcycles
\def\@vwid@sift{%
\skip@\lastskip\unskip
\dimen@\lastkern\unkern
\count@\lastpenalty\unpenalty
\setbox\z@\lastbox
%{\showoutput\showbox\z@}%
\ifvoid\z@ \advance\sift@deathcycles\@ne \else \sift@deathcycles\z@ \fi
\ifnum\sift@deathcycles>33
\let\@vwid@sift\relax
\PackageWarning{varwidth}{Failed to reprocess entire contents}%
\fi
%\message{\the\sift@deathcycles: skip \the\skip@; kern \the\dimen@; penalty \the\count@. }%
%\ifhbox\z@\setbox99\hbox to0pt{\unhcopy\z@}\fi % = message
\ifnum\count@=\@vwid@preeqp \@vwid@eqmodefalse\fi
%\ifnum\count@=\@vwid@preeqp \message{End equation mode. }\fi
\ifnum\count@=\@vwid@posteqp \@vwid@eqmodetrue\fi
%\ifnum\count@=\@vwid@posteqp\message{Begin equation mode. }\fi
%\if@vwid@eqmode {\showoutput\showbox\z@}\fi
\ifnum\count@=\@vwid@toppen % finished
\let\@vwid@sift\relax
\else\ifnum\count@=\@vwid@offsets
\@vwid@setoffsets
\else
\ifnum\count@=\@vwid@postw
\else
\@vwid@resetb % reset box \z@ or measure it
\fi
\@vwid@append
\fi\fi
\@vwid@sift}
\def\@vwid@setoffsets{%
\setbox\z@=\hbox{\unhbox\z@
\global\@vwid@roff\lastkern\unkern
\global\@vwid@loff\lastkern\unkern}%
%\message{Set offsets to \the\@vwid@loff, \the\@vwid@roff. }%
}
\def\@vwid@append{% Append contents of box \z@ and glue to \@vwid@box
\setbox\@vwid@box\vbox{%
\unvbox\z@
\ifdim\dimen@=\z@\else \kern\dimen@ \fi
\vskip\skip@
\unvbox\@vwid@box
}%{\tracingall\showbox\@vwid@box}%
}
% reset box \z@ to \hsize, applying shifts, and wrap in vbox
% Don't worry about numbered equations because we won't get
% here if there are any.
\def\@vwid@resetb{%
\setbox\z@\vbox\bgroup
\ifvoid\z@
\else
\ifvbox\z@
\box\z@
\else % \hbox
\@tempdima\hsize
\advance\@tempdima-\@vwid@roff
\advance\@tempdima-\@vwid@loff
\advance\@tempdima-\p@
%\message{Test if \the\wd\z@ > \the\@tempdima, }%
\ifdim\wd\z@>\@tempdima % full-width line; rebox it
%\message{An ordinary line or alignment. (\the\wd\z@ > \the\@tempdima) }%
\hbox to\hsize
{\kern\@vwid@loff \unhbox\z@ \kern\@vwid@roff}%
\else % an equation or direct \hbox
\if@vwid@eqmode % re-center unnumbered equations
%\message{A centered equation hsize=\the\hsize. }%
\hbox to\hsize
{\hskip\@vwid@loff\@plus1fil
\unhbox\z@ \hskip\@vwid@roff\@plus1fil}%
\else % plain narrow \hbox; leave it as-is
%\message{Plain narrow box}%
\box\z@
\fi\fi\fi\fi
\egroup}
% Measure a line (in box \z@) and keep a running tally of the
% widest natural width in \@tempdima
\def\@vwid@measure{%
\ifvoid\z@
\else
% numbered equations not part of alignments can't be reset,
% so force retention of full width.
\ifnum\count@=\@vwid@postnump \ifdim\wd\z@<\linewidth
\ifdim\@tempdima<\linewidth \@tempdima\linewidth \fi
\fi\fi
\ifhbox\z@
\setbox\z@=\hbox
{\kern\@vwid@loff \unhbox\z@ \kern\@vwid@roff}%
\fi
\ifdim\wd\z@>\@tempdima \@tempdima\wd\z@ \fi
\fi}
\newdimen\@vwid@loff
\newdimen\@vwid@roff
\let\@@bsphack\@bsphack
\let\@@esphack\@esphack
\let\@@Esphack\@Esphack
\def\@vwid@bsphack{\@@bsphack
\ifx\@vwid@wrap\@firstofone
\bgroup
\else
\ifvmode
\setbox\@vwid@box \vbox\bgroup \vbox\bgroup
\let\@vwid@wrap\@firstofone
\def\@esphack{\@vwid@esphack\@@esphack}%
\def\@Esphack{\@vwid@esphack\@@Esphack}%
\fi
\fi}
\def\@vwid@esphack{\egroup
\ifx\@vwid@wrap\@firstofone\else
\egroup % end outer box
\unvbox\@vwid@box % put inner box on list without lineskip
\penalty\@vwid@postw
\fi}
% \vbox Wrapper for misc vlist items
\long\def\@vwid@wrap{\relax
\ifvmode\expandafter\@vwid@dowrap \else \expandafter\@firstofone \fi}
\long\def\@vwid@dowrap#1{%
\setbox\@vwid@box \vbox{\vbox{\let\@vwid@wrap\@firstofone
#1}\penalty\@vwid@postw
}\unvbox\@vwid@box }
\let\@@vwid@special\special
\let\@@vwid@pdfliteral\pdfliteral
\let\@@vwid@addtocontents\addtocontents
\let\@@vwid@list\list
\let\@@vwid@endtrivlist\endtrivlist
\let\@@vwid@eqnnum\@eqnnum
\long\def\@vwid@special#1{\@vwid@wrap{\@@vwid@special{#1}}}
\long\def\@vwid@pdfliteral#1{\@vwid@wrap{\@@vwid@pdfliteral{#1}}}
\long\def\@vwid@addtocontents#1#2{\@vwid@wrap{\@@vwid@addtocontents{#1}{#2}}}
\long\def\@vwid@hangfrom#1{\par
\setbox\@tempboxa\hbox{{#1}}%
\setbox\@vwid@box \vbox{\hbox{\kern\z@ \kern\z@
}\penalty\@vwid@offsets}\unvbox\@vwid@box
\def\par{\relax\ifhmode\unskip\fi
\vadjust{\hbox{\kern\hangindent\kern\z@}\penalty\@vwid@offsets}%
\@restorepar\par}%
\hangindent \wd\@tempboxa\noindent\box\@tempboxa}
\def\@vwid@list{\@vwid@setlist\@@vwid@list}
\def\@vwid@endtrivlist{\@vwid@setlist\@@vwid@endtrivlist}
\def\@vwid@setlist{\relax\ifhmode \unskip\expandafter\vadjust\fi
{\setbox\@vwid@box \vbox{\hbox{%
\advance\hsize-\linewidth \advance\hsize-\@totalleftmargin
\kern\@totalleftmargin \kern\hsize}%
\penalty\@vwid@offsets}%
\unvbox\@vwid@box}}
\newif\if@vwid@eqmode
\def\@vwid@afterva{\vadjust{\penalty\@vwid@postnump}}
% Should I do this? ...
\@ifundefined{newcolumntype}{}{%
\@ifundefined{NC@rewrite@V}{
\newcolumntype{V}[1]{%
>{\begin{varwidth}[t]{#1}\narrowragged\let\\\tabularnewline}%
l%
<{\@finalstrut\@arstrutbox\end{varwidth}}}
}{}
}
% V 0.91 Always restack contents, even if width didn't change.
% V 0.92 fix \special, \pdfliteral

View File

@ -4,12 +4,20 @@ echo
echo Note: manually quit first latex pass with shift-x
echo
cd /Users/thuerey/Dropbox/mbaDevelSelected/pbdl-book/
DIR=/Users/thuerey/Dropbox/mbaDevelSelected/pbdl-book/
cd ${DIR}
#echo Note: make sure to copy latex helpers! cp ./latex-helpers/* ./_build/latex/
mkdir _build
mkdir _build/latex
cp ./latex-helpers/* ./_build/latex/
# first preliminary build to generate .tex file
/Users/thuerey/Library/Python/3.7/bin/jupyter-book build . --builder pdflatex
# fix up latex
cd /Users/thuerey/Dropbox/mbaDevelSelected/pbdl-book/_build/latex
cd ${DIR}/_build/latex
export JPYFILENAME=book.tex
rm ${JPYFILENAME}-in.bak
mv ${JPYFILENAME} ${JPYFILENAME}-in.bak