From a5057ac1a22b059b5347631b76a2c863f2ffd0a3 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Wed, 5 Jul 2006 23:41:50 +0000 Subject: new package boxhandler git-svn-id: svn://tug.org/texlive/trunk@1776 c570f23f-e606-0410-a88d-b1316a301751 --- .../texmf-dist/tex/latex/boxhandler/boxhandler.sty | 464 +++++++++++++++++++++ 1 file changed, 464 insertions(+) create mode 100644 Master/texmf-dist/tex/latex/boxhandler/boxhandler.sty (limited to 'Master/texmf-dist/tex/latex/boxhandler') diff --git a/Master/texmf-dist/tex/latex/boxhandler/boxhandler.sty b/Master/texmf-dist/tex/latex/boxhandler/boxhandler.sty new file mode 100644 index 00000000000..136171eaacc --- /dev/null +++ b/Master/texmf-dist/tex/latex/boxhandler/boxhandler.sty @@ -0,0 +1,464 @@ +%% +%% This is file `boxhandler.sty', +%% generated with the docstrip utility. +%% +%% The original source files were: +%% +%% boxhandler.dtx (with options: `package') +%% +%% IMPORTANT NOTICE: +%% +%% For the copyright see the source file. +%% +%% Any modified versions of this file must be renamed +%% with new filenames distinct from boxhandler.sty. +%% +%% For distribution of the original source see the terms +%% for copying and modification in the file boxhandler.dtx. +%% +%% This generated file may be distributed as long as the +%% original source files, as listed above, are part of the +%% same distribution. (The sources need not necessarily be +%% in the same archive or directory.) +%% +%% boxhandler.sty +%% Copyright Steven B. Segletes. +%% +%% This file may be redistributed and/or modified with attribution. +%% +%% This is boxhandler.sty, derived from earlier incarnations of savcap.sty & +%% arlcaptions.sty. +%% +\ProvidesPackage{boxhandler} +[2006/04/24 v1.03 + Flexible Captioning Styles and Deferred Box/List Printing] +\NeedsTeXFormat{LaTeX2e} +%% Examples of a number of calls provided in this style are given below, +%% in no particular order: +%% +%%| |\\ +%%|\bxtable[t] |\\ +%%| {This is a test of nonwrapping caption\label{tb:mytable}} |\\ +%%| { |\\ +%%| \begin{tabular}{|c|c|c|} |\\ +%%| \hline |\\ +%%| column 1 data & 2nd column data & and the third column data\\|\\ +%%| \hline |\\ +%%| \end{tabular} |\\ +%%| } |\\ +%%| |\\ +%%|\usepackage{graphicx} |\\ +%%|\bxfigure[h] |\\ +%%| {Here is an example of a particularly long caption that will |\\ +%%| test wrapping} |\\ +%%| {\includegraphics[width=3.64in,height=4.30in]{Atest1.eps}} |\\ +%%| |\\ +%%|\relaxCaptionWidth[2in] |\\ +%%| |\\ +%%|\captionStyle{}{c} |\\ +%%| |\\ +%%|\setlength\captionGap{3ex} |\\ +%%| |\\ +%%|\setcounter{abovecaptionskipterm}{10} |\\ +%%|\setcounter{belowcaptionskipterm}{0} |\\ +%%| |\\ +%%|\TableFontSize\normalsize |\\ +%%| |\\ +%%|\LRFigurePlacement{flushleft} |\\ +%%| |\\ +%%|\killtableofcontents |\\ +%%| |\\ +%%|\holdFigures |\\ +%%| |\\ +%%|\clearFigures |\\ +%%| |\\ +%%|\newsavebox{\mybox} |\\ +%%|\SaveCBox{\mybox}{\framebox(200,100){Ack!}} |\\ +%%| |\\ +%%|\ReciteFigure[h]{\figcapii}{\figii}{\figcapwdthii} |\\ +%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\usepackage{pbox} +\newcounter{TableIndex} \setcounter{TableIndex}{0} +\newcounter{FigureIndex} \setcounter{FigureIndex}{0} +\newcounter{TableClearedIndex} \setcounter{TableClearedIndex}{0} +\newcounter{FigureClearedIndex} \setcounter{FigureClearedIndex}{0} +\let\old@makecaption \@makecaption% SAVE PREVAILING \@makecaption STYLE +\newlength\oldabovecaptionskip +\setlength\oldabovecaptionskip \abovecaptionskip +\newlength\oldbelowcaptionskip +\setlength\oldbelowcaptionskip \belowcaptionskip +%% \captionGap CAN BE INCREASED TO PLACE MORE SPACE BETWEEN THE CAPTION +%% LABEL AND THE ACTUAL CAPTION TEXT. +\newlength\captionGap \setlength\captionGap{1ex} +%% \TableDeadMargin AND \FigureDeadMargin REFER TO THE TABLE & FIGURE +%% MARGIN OF A BOX THAT COUNTS TOWARDS ITS SIZE, BUT IN WHICH NO +%% ACTIVE DATA FALLS; DEADMARGIN ASSUMED ON BOTH LEFT & RIGHT SIDE. +\newlength\TableDeadMargin \setlength\TableDeadMargin{0.375em} +\newlength\FigureDeadMargin \setlength\FigureDeadMargin{0em} +%% INITIALIZE \above- AND \belowcaptionskip VALUES; CAN BE RESET +%% USED TO SET GAPS ABOVE & BELOW CAPTIONS +\newcounter{abovecaptionskipterm} \setcounter{abovecaptionskipterm}{10} +\newcounter{belowcaptionskipterm} \setcounter{belowcaptionskipterm}{7} +%% RESET \@minCaptionBoxWidth TO Default VALUE WITH \relaxCaptionWidth +%% SET \@minCaptionBoxWidth TO USER VALUE WITH \relaxCaptionWidth[] +\newlength\@minCaptionBoxWidth +\newlength\@minCaptionBoxWidthDefault +\setlength\@minCaptionBoxWidthDefault{1in} +%% RESET \@maxCaptionBoxWidth TO Default WITH \limitCaptionWidth +%% SET \@maxCaptionBoxWidth WITH \limitCaptionWidth[] +\newlength\@maxCaptionBoxWidth +\newlength\@maxCaptionBoxWidthDefault +\setlength\@maxCaptionBoxWidthDefault{\textwidth} +%% DEFINE promptTablesFlag & PROVIDE ROUTINE TO CHANGE IT FROM +%% "PROMPT"(1) TO "ON HOLD"(0) +\newcounter{promptTablesFlag} \setcounter{promptTablesFlag}{1} +\newcommand\holdTables{\setcounter{promptTablesFlag}{0}} +%% SAME FOR promptFiguresFlag +\newcounter{promptFiguresFlag} \setcounter{promptFiguresFlag}{1} +\newcommand\holdFigures{\setcounter{promptFiguresFlag}{0}} +%% DEFAULT CaptionFontSize & TableFontSize AS \small; CAN BE RESET +\let \CaptionFontSize \small +\let \TableFontSize \small +%% DEFAULT TABLE & FIGURE LR ALIGNMENT TO center; +%% CAN RESET TO flushleft/-right +\def \LRTablePlacement {center} +\def \LRFigurePlacement {center} +%% WITHIN-CAPTION JUSTIFICATION CAN BE SET +%% OPTIONS: {}, {\raggedleft}, {\raggedright}, or {\centering} +\def\CaptionJustification{} % <---DEFAULT IS FULL JUSTIFICATION +%% WORKING VARIABLES +\newlength\DeadMargin +\newlength\@DataBoxWidth +\newlength\CaptionBoxWidth +\newlength\@DataBoxOffset +\newlength\@CaptionBoxOffset +\newlength\@captionIDwidth +\newlength\@captionWidth +\newlength\@DataBoxSurplus + +\newcommand\bxtable[3][t]{ + \StoreTable[#1]{#2}{#3} + \ifnum \arabic{promptTablesFlag} = 1 + \addtocounter{TableClearedIndex}{1} + \def\TableBoxLabel{tbl\roman{TableIndex}} + \def\TableCaptionLabel{tblcap\roman{TableIndex}} + \def\TblCaptionWidthLabel{tblcapwdth\roman{TableIndex}} + \ReciteTable[#1]{\csname\TableCaptionLabel\endcsname} + {\csname\TableBoxLabel\endcsname} + {\csname\TblCaptionWidthLabel\endcsname} + \fi +} + +\newcommand\StoreTable[3][]{ + \addtocounter{TableIndex}{1} + \setlength\DeadMargin\TableDeadMargin + \def\TableBoxLabel{tbl\roman{TableIndex}} + \def\TableCaptionLabel{tblcap\roman{TableIndex}} + \def\TblCaptionWidthLabel{tblcapwdth\roman{TableIndex}} + \expandafter\SaveCBox\csname\TableBoxLabel\endcsname{\TableFontSize#3} + \expandafter\def\csname\TableCaptionLabel\endcsname{#2} + \expandafter\newlength\csname\TblCaptionWidthLabel\endcsname + \expandafter\setlength\csname\TblCaptionWidthLabel\endcsname + \CaptionBoxWidth +} + +\newcommand\ReciteTable[4][h]{ + \begin{table}[#1] + \begin{\LRTablePlacement} + \let\@makecaption \new@makecaption + \setlength\abovecaptionskip{\arabic{abovecaptionskipterm}\p@} + \setlength\belowcaptionskip{\arabic{belowcaptionskipterm}\p@} + \set@DataBoxWidth{#3} + \setlength\CaptionBoxWidth{#4} + \set@BoxOffsets + \rule{\@CaptionBoxOffset}{0em}% + \parbox{\CaptionBoxWidth}{\caption {#2}}% + \rule{\@CaptionBoxOffset}{0em}% + \par + \rule{\@DataBoxOffset}{0in}% + \usebox{#3} + \rule{\@DataBoxOffset}{0in}% + \let\@makecaption \old@makecaption + \setlength\abovecaptionskip \oldabovecaptionskip + \setlength\belowcaptionskip \oldbelowcaptionskip + \end{\LRTablePlacement} + \end{table} +} + +\newcommand\clearTables{ + \clearpage + \clearlistoftables + \clearpage +%%DO UNTIL ALL HELD TABLES ARE CLEARED + \whiledo{\arabic{TableClearedIndex} < \arabic{TableIndex}}{ + \addtocounter{TableClearedIndex}{1} +%% \TableBoxLabel : tbli, tblii, tbliii, tbliv, etc. +%% \TableCaptionLabel : tblcapi, tblcapii, tblcapiii, tblcapiv, etc. +%% \TblCaptionWidthLabel: tblcapwdthi, tblcapwdthii, tblcapwdthiii,etc. + \def\TableBoxLabel{tbl\roman{TableClearedIndex}} + \def\TableCaptionLabel{tblcap\roman{TableClearedIndex}} + \def\TblCaptionWidthLabel{tblcapwdth\roman{TableClearedIndex}} + \theClearedTable{\csname\TableCaptionLabel\endcsname} + {\csname\TableBoxLabel\endcsname} + {\csname\TblCaptionWidthLabel\endcsname} + } +} + +%% \theClearedTable CAN BE RENEWED IF DIFFERENT OUTPUT FORMAT IS DESIRED +\newcommand\theClearedTable[4][h]{ +%% CLEAR THIS TABLE ON A PAGE BY ITSELF, CENTERED VERTICALLY + \vspace*{\fill} + \ReciteTable[#1]{#2}{#3}{#4} + \vspace*{\fill} + \clearpage +} + +\newcommand\bxfigure[3][t]{ + \StoreFigure[#1]{#2}{#3} + \ifnum \arabic{promptFiguresFlag} = 1 + \addtocounter{FigureClearedIndex}{1} + \def\FigureBoxLabel{fig\roman{FigureIndex}} + \def\FigureCaptionLabel{figcap\roman{FigureIndex}} + \def\FigCaptionWidthLabel{figcapwdth\roman{FigureIndex}} + \ReciteFigure[#1]{\csname\FigureCaptionLabel\endcsname} + {\csname\FigureBoxLabel\endcsname} + {\csname\FigCaptionWidthLabel\endcsname} + \fi +} + +\newcommand\StoreFigure[3][]{ + \addtocounter{FigureIndex}{1} + \setlength\DeadMargin\FigureDeadMargin + \def\FigureBoxLabel{fig\roman{FigureIndex}} + \def\FigureCaptionLabel{figcap\roman{FigureIndex}} + \def\FigCaptionWidthLabel{figcapwdth\roman{FigureIndex}} + \expandafter\SaveCBox\csname\FigureBoxLabel\endcsname{#3} + \expandafter\def\csname\FigureCaptionLabel\endcsname{#2} + \expandafter\newlength\csname\FigCaptionWidthLabel\endcsname + \expandafter\setlength\csname\FigCaptionWidthLabel\endcsname + \CaptionBoxWidth +} + +\newcommand\ReciteFigure[4][h]{ + \begin{figure}[#1] + \begin{\LRFigurePlacement} + \let\@makecaption \new@makecaption + \setlength\abovecaptionskip{\arabic{abovecaptionskipterm}\p@} + \setlength\belowcaptionskip{\arabic{belowcaptionskipterm}\p@} + \set@DataBoxWidth{#3} + \setlength\CaptionBoxWidth{#4} + \set@BoxOffsets + \rule{\@DataBoxOffset}{0in}% + \usebox{#3}% + \rule{\@DataBoxOffset}{0in}% + \par + \rule{\@CaptionBoxOffset}{0em}% + \parbox{\CaptionBoxWidth}{\caption {#2}}% + \rule{\@CaptionBoxOffset}{0em}% + \let\@makecaption \old@makecaption + \setlength\abovecaptionskip \oldabovecaptionskip + \setlength\belowcaptionskip \oldbelowcaptionskip + \end{\LRFigurePlacement} + \end{figure} +} + +\newcommand\clearFigures{ + \clearpage + \clearlistoffigures + \clearpage +%%DO UNTIL ALL HELD FIGURES ARE CLEARED + \whiledo{\arabic{FigureClearedIndex} < \arabic{FigureIndex}}{ + \addtocounter{FigureClearedIndex}{1} +%% \FigureBoxLabel: : figi, figii, figiii, figiv, etc. +%% \FigureCaptionLabel : figcapi, figcapii, figcapiii, figcapiv, etc. +%% \FigCaptionWidthLabel: figcapwdthi, figcapwdthii, figcapwdthiii,etc. + \def\FigureBoxLabel{fig\roman{FigureClearedIndex}} + \def\FigureCaptionLabel{figcap\roman{FigureClearedIndex}} + \def\FigCaptionWidthLabel{figcapwdth\roman{FigureClearedIndex}} + \theClearedFigure{\csname\FigureCaptionLabel\endcsname} + {\csname\FigureBoxLabel\endcsname} + {\csname\FigCaptionWidthLabel\endcsname} + } +} + +%% \theClearedFigure CAN BE RENEWED IF DIFFERENT OUTPUT FORMAT DESIRED +\newcommand\theClearedFigure[4][h]{ +%% CLEAR THIS FIGURE ON A PAGE BY ITSELF, CENTERED VERTICALLY + \vspace*{\fill} + \ReciteFigure[#1]{#2}{#3}{#4} + \vspace*{\fill} + \clearpage +} + +\newcommand\relaxCaptionWidth[1][\@minCaptionBoxWidthDefault]{ + \setlength\@minCaptionBoxWidth{#1} + \ifdim \@minCaptionBoxWidth > \@maxCaptionBoxWidth + \setlength\@maxCaptionBoxWidth\@minCaptionBoxWidth + \fi +} +\relaxCaptionWidth% SET INITIAL \@minCaptionBoxWidth TO DEFAULT VALUE + +\newcommand\limitCaptionWidth[1][\@maxCaptionBoxWidthDefault]{ + \setlength\@maxCaptionBoxWidth{#1} + \ifdim \@maxCaptionBoxWidth < \@minCaptionBoxWidth + \setlength\@minCaptionBoxWidth\@maxCaptionBoxWidth + \fi +} +\limitCaptionWidth% SET INITIAL \@maxCaptionBoxWidth TO DEFAULT VALUE + +\newcommand\constrainCaptionWidth[2][-1in]{ + \ifdim #1 < 0in + \setlength\@minCaptionBoxWidth{#2} + \setlength\@maxCaptionBoxWidth{#2} + \else + \ifdim #1 < #2 + \setlength\@minCaptionBoxWidth{#1} + \setlength\@maxCaptionBoxWidth{#2} + \else + \setlength\@minCaptionBoxWidth{#2} + \setlength\@maxCaptionBoxWidth{#1} + \fi + \fi +} + +\newcommand\SaveCBox[2]{ + \newsavebox{#1} + \sbox{#1}{#2} + \set@BoxWidths{#1} +} + +\newcommand\set@BoxWidths[1]{% of DataBox & CaptionBox (-2\DeadMargin) + \set@DataBoxWidth{#1} + \set@CaptionBoxWidth +} + +\newcommand\set@DataBoxWidth[1]{ + \setlength {\@DataBoxWidth}{\widthof{\usebox{#1}}} +} + +\newcommand\set@CaptionBoxWidth{ + \setlength\CaptionBoxWidth\@DataBoxWidth + \addtolength{\CaptionBoxWidth}{-2\DeadMargin} + \ifdim \CaptionBoxWidth < \@minCaptionBoxWidth + \setlength\CaptionBoxWidth\@minCaptionBoxWidth + \fi + \ifdim \CaptionBoxWidth > \@maxCaptionBoxWidth + \setlength\CaptionBoxWidth\@maxCaptionBoxWidth + \fi +} + +\newcommand\set@BoxOffsets{ + \setlength\@DataBoxSurplus{\@DataBoxWidth} + \addtolength\@DataBoxSurplus{-\CaptionBoxWidth} + \ifdim \@DataBoxSurplus > 0in + \setlength\@CaptionBoxOffset{0.5\@DataBoxSurplus} + \setlength\@DataBoxOffset{0in} + \else + \setlength\@CaptionBoxOffset{0in} + \setlength\@DataBoxOffset{-0.5\@DataBoxSurplus} + \fi +} + +\long\def\offset@caption#1#2{ + \setlength\@captionIDwidth{\widthofpbox{\CaptionFontSize{#1.}}} + \addtolength\@captionIDwidth\captionGap + \setlength\@captionWidth\CaptionBoxWidth + \addtolength\@captionWidth{-\@captionIDwidth} + \CaptionFontSize{#1.}\hfill\parbox[t]{\@captionWidth} + {\CaptionJustification\CaptionFontSize{#2.}}% +} + +\long\def\nooffset@caption#1#2{% + \CaptionJustification\CaptionFontSize #1.\rule{\captionGap}{0in}#2.% +} + +\long\def\shortleft@caption#1#2{% + \raggedright \CaptionFontSize #1.\rule{\captionGap}{0in}#2.% +} + +\long\def\shortcenter@caption#1#2{% + \centering \CaptionFontSize #1.\rule{\captionGap}{0in}#2.% +} + +\long\def\shortright@caption#1#2{% + \raggedleft \CaptionFontSize #1.\rule{\captionGap}{0in}#2.% +} + +\long\def\new@makecaption#1#2{% + \vskip\abovecaptionskip + \sbox\@tempboxa{\CaptionFontSize #1.\rule{\captionGap}{0in}#2.}% + \ifdim \wd\@tempboxa >\hsize + \long@caption{#1}{#2} + \else + \short@caption{#1}{#2} + \fi + \vskip\belowcaptionskip +} + +\newcommand\captionStyle[2]{ + \if o#1 \let\long@caption \offset@caption \fi + \if n#1 \let\long@caption \nooffset@caption \fi + \if l#2 \let\short@caption \shortleft@caption \fi + \if c#2 \let\short@caption \shortcenter@caption \fi + \if r#2 \let\short@caption \shortright@caption \fi +} + +%% SET DEFAULT CAPTION STYLE: CAPTION ID OFFSET FOR LONG CAPTIONS, +%% SHORT CAPTIONS LEFT ALIGNED +\captionStyle{o}{l} + +\newcommand\killtableofcontents{ + \renewcommand\tableofcontents{} +} + +%%LIST OF FIGURES HANDLING: +\newcounter{lofInvocations} \setcounter{lofInvocations}{0} +\newcounter{lofPrints} \setcounter{lofPrints}{0} +\let\oldlistoffigures\listoffigures + +\newcommand\killlistoffigures{ + \def\oldlistoffigures {} + \renewcommand\listoffigures{} +} + +\newcommand\holdlistoffigures{ + \renewcommand\listoffigures{\addtocounter{lofInvocations}{1}} +} + +\newcommand\clearlistoffigures{ + \whiledo{\arabic{lofPrints} < \arabic{lofInvocations}}{ + \addtocounter{lofPrints}{1} + \oldlistoffigures + } +} + +%%LIST OF TABLES HANDLING: +\newcounter{lotInvocations} \setcounter{lotInvocations}{0} +\newcounter{lotPrints} \setcounter{lotPrints}{0} +\let\oldlistoftables\listoftables + +\newcommand\killlistoftables{ + \def\oldlistoftables {} + \renewcommand\listoftables{} +} + +\newcommand\holdlistoftables{ + \renewcommand\listoftables{\addtocounter{lotInvocations}{1}} +} + +\newcommand\clearlistoftables{ + \whiledo{\arabic{lotPrints} < \arabic{lotInvocations}}{ + \addtocounter{lotPrints}{1} + \oldlistoftables + } +} + +%% TO RETAIN BACKWARD COMPATIBILITY WITH THE PREDECESSOR TO boxtable, +%% THE FOLLOWING ASSIGNMENTS ARE MADE. +\let\arltable\bxtable +\let\arlfigure\bxfigure + +\endinput +%% +%% End of file `boxhandler.sty'. -- cgit v1.2.3