From e2ca0b949de808865ea3c39087f4a6057ee0bb2a Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Fri, 22 Feb 2019 23:12:27 +0000 Subject: fitbox (22feb19) git-svn-id: svn://tug.org/texlive/trunk@50088 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/latex/fitbox/fitbox.sty | 96 ++++++++++++++++++++++++--- 1 file changed, 87 insertions(+), 9 deletions(-) (limited to 'Master/texmf-dist/tex/latex/fitbox') diff --git a/Master/texmf-dist/tex/latex/fitbox/fitbox.sty b/Master/texmf-dist/tex/latex/fitbox/fitbox.sty index 2dbc31bd33a..c517752fbce 100644 --- a/Master/texmf-dist/tex/latex/fitbox/fitbox.sty +++ b/Master/texmf-dist/tex/latex/fitbox/fitbox.sty @@ -36,21 +36,45 @@ %% \NeedsTeXFormat{LaTeX2e} \ProvidesPackage{fitbox} -[2019/02/10 v1.01 Fitting boxes on a page] +[2019/02/20 v1.02 Fitting boxes on a page] \newdimen\fitboxnatheight \newdimen\fitboxnatwidth \RequirePackage{xkeyval} \define@cmdkeys{FTBX}{maxheight, minheight, maxwidth, minwidth, - belowboxspace, maxenlargepage} + belowboxspace, maxenlargepage, colsep, maincapheight, + subcapheight} +\define@key{FTBX}{colsepexpr}{% + \setbox\@tempboxa=\hbox{#1}% + \edef\cmdKV@FTBX@colsep{\wd\@tempboxa}} +\define@key{FTBX}{maincaplines}{% + \@tempdima=\z@ + \advance\@tempdima by #1\baselineskip\relax + \ifnum#1>0\relax + \advance\@tempdima by \parskip + \fi + \advance\@tempdima by \abovecaptionskip + \advance\@tempdima by \belowcaptionskip + \edef\cmdKV@FTBX@maincapheight{\the\@tempdima}} +\define@key{FTBX}{subcaplines}{% + \@tempdima=\z@ + \advance\@tempdima by #1\baselineskip\relax + \ifnum#1>0\relax + \advance\@tempdima by \parskip + \fi + \advance\@tempdima by \abovecaptionskip + \advance\@tempdima by \belowcaptionskip + \edef\cmdKV@FTBX@subcapheight{\the\@tempdima}} \def\fitboxset#1{\setkeys{FTBX}{#1}} \fitboxset{maxheight=\textheight, minheight=\fitboxnatheight, maxwidth=\hsize, minwidth=\fitboxnatwidth, - belowboxspace=0pt, maxenlargepage=0pt} + belowboxspace=0pt, maxenlargepage=0pt, colsepexpr={aaa}, + maincaplines=1, subcaplines=0} \newbox\FTBX@box \newdimen\FTBX@desired@maxheight \newdimen\FTBX@desired@minheight \newdimen\FTBX@available@height -\newcommand\fitbox[2][]{\leavevmode +\def\fitbox{\@ifstar\@@fitbox\@fitbox} +\newcommand\@fitbox[2][]{\noindent \fitboxset{#1}% \setbox\FTBX@box=\hbox{#2}% \fitboxnatwidth=\wd\FTBX@box\relax @@ -70,17 +94,17 @@ Consider changing it to \the\textheight}% \fi \expandafter\ifdim\cmdKV@FTBX@maxheight>\textheight\relax - \PackageWarning{fitbox}{Desired height is too laege. + \PackageWarning{fitbox}{Desired height is too large. Consider changing it to \the\textheight}% \fi % Calculating the minimal and maximal height - \Gscale@div{\@tempa}{\cmdKV@FTBX@maxwidth}{\fitboxnatwidth}% - \FTBX@desired@maxheight=\@tempa\fitboxnatheight\relax + \Gscale@div{\@FTBX@tempa}{\cmdKV@FTBX@maxwidth}{\fitboxnatwidth}% + \FTBX@desired@maxheight=\@FTBX@tempa\fitboxnatheight\relax \expandafter\ifdim\cmdKV@FTBX@maxheight<\FTBX@desired@maxheight\relax \expandafter\FTBX@desired@maxheight=\cmdKV@FTBX@maxheight\relax \fi - \Gscale@div{\@tempa}{\cmdKV@FTBX@minwidth}{\fitboxnatwidth}% - \FTBX@desired@minheight=\@tempa\fitboxnatheight\relax + \Gscale@div{\@FTBX@tempa}{\cmdKV@FTBX@minwidth}{\fitboxnatwidth}% + \FTBX@desired@minheight=\@FTBX@tempa\fitboxnatheight\relax \expandafter\ifdim\cmdKV@FTBX@minheight>\FTBX@desired@minheight\relax \expandafter\FTBX@desired@minheight=\cmdKV@FTBX@minheight\relax \fi @@ -114,6 +138,60 @@ \resizebox*{!}{\FTBX@desired@maxheight}{\box\FTBX@box}% \fi } +\newcommand\@@fitbox[2][]{\noindent + \fitboxset{#1}% + \setbox\FTBX@box=\hbox{#2}% + \fitboxnatwidth=\wd\FTBX@box\relax + \fitboxnatheight=\ht\FTBX@box\relax + \advance\fitboxnatheight by \dp\FTBX@box\relax + % Checking the sizes + \expandafter\ifdim\cmdKV@FTBX@minwidth>\columnwidth\relax + \PackageWarning{fitbox}{Minimal width is too large. Consider + changing it to \the\hsize}% + \fi + \expandafter\ifdim\cmdKV@FTBX@maxwidth>\hsize\relax + \PackageWarning{fitbox}{Desired width is too large. Consider + changing it to \the\hsize}% + \fi + \expandafter\ifdim\cmdKV@FTBX@minheight>\textheight\relax + \PackageWarning{fitbox}{Minimal height is too large. + Consider changing it to \the\textheight}% + \fi + \expandafter\ifdim\cmdKV@FTBX@maxheight>\textheight\relax + \PackageWarning{fitbox}{Desired height is too large. + Consider changing it to \the\textheight}% + \fi + % Calculating the minimal and maximal height + \Gscale@div{\@FTBX@tempa}{\cmdKV@FTBX@maxwidth}{\fitboxnatwidth}% + \FTBX@desired@maxheight=\@FTBX@tempa\fitboxnatheight\relax + \expandafter\ifdim\cmdKV@FTBX@maxheight<\FTBX@desired@maxheight\relax + \expandafter\FTBX@desired@maxheight=\cmdKV@FTBX@maxheight\relax + \fi + \Gscale@div{\@FTBX@tempa}{\cmdKV@FTBX@minwidth}{\fitboxnatwidth}% + \FTBX@desired@minheight=\@FTBX@tempa\fitboxnatheight\relax + \expandafter\ifdim\cmdKV@FTBX@minheight>\FTBX@desired@minheight\relax + \expandafter\FTBX@desired@minheight=\cmdKV@FTBX@minheight\relax + \fi + \ifdim\FTBX@desired@minheight>\FTBX@desired@maxheight\relax + \PackageWarning{fitbox}{Desired min scale exceeds desired max + scale.}% + \fi + \resizebox*{!}{\FTBX@desired@maxheight}{\box\FTBX@box}% +} +\newcommand\SetFitboxLayout[3][]{% + \fitboxset{#1}% + \@tempdima=\textheight + \advance\@tempdima by -\cmdKV@FTBX@maincapheight\relax + \divide\@tempdima by #2\relax + \advance\@tempdima by -\cmdKV@FTBX@subcapheight\relax + \edef\cmdKV@FTBX@maxheight{\the\@tempdima}% + \@tempdima=\columnwidth + \@tempdimb=\cmdKV@FTBX@colsep\relax + \advance\@tempdima by -#3\@tempdimb\relax + \advance\@tempdima by \@tempdimb\relax + \divide\@tempdima by #3\relax + \edef\cmdKV@FTBX@maxwidth{\the\@tempdima}% +} \endinput %% %% End of file `fitbox.sty'. -- cgit v1.2.3