diff options
author | Karl Berry <karl@freefriends.org> | 2019-02-22 23:12:27 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2019-02-22 23:12:27 +0000 |
commit | e2ca0b949de808865ea3c39087f4a6057ee0bb2a (patch) | |
tree | ccb341f268123355798d7d4c346ca0ea338ed9c3 | |
parent | 802c94cd45c6b7988569f2050511c00087e91030 (diff) |
fitbox (22feb19)
git-svn-id: svn://tug.org/texlive/trunk@50088 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/doc/latex/fitbox/README | 8 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/fitbox/fitbox.bib | 8 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/fitbox/fitbox.pdf | bin | 257736 -> 295166 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/fitbox/napoleon.png | bin | 0 -> 31195 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/fitbox/sample-subfigure.pdf | bin | 0 -> 88777 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/fitbox/sample-subfigure.tex | 73 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/fitbox/sample.pdf | bin | 83215 -> 83215 bytes | |||
-rw-r--r-- | Master/texmf-dist/source/latex/fitbox/Makefile | 2 | ||||
-rw-r--r-- | Master/texmf-dist/source/latex/fitbox/fitbox.dtx | 204 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/fitbox/fitbox.sty | 96 |
10 files changed, 362 insertions, 29 deletions
diff --git a/Master/texmf-dist/doc/latex/fitbox/README b/Master/texmf-dist/doc/latex/fitbox/README index 688742d9deb..bdd64eb941a 100644 --- a/Master/texmf-dist/doc/latex/fitbox/README +++ b/Master/texmf-dist/doc/latex/fitbox/README @@ -6,7 +6,13 @@ fit on the page. It scales the box to the maximal allowed size within the user-set limits. If there there is not enough space on the page, the box is moved to the next one. + +version 1.02 2019/02/20 Bug fixes + New command \fitbox* for boxes inside floats + New command \SetFitboxLayout for emulation of figsize + package functionality + version 1.01 2019/02/10 Use the width of the box around the graphics for default max width. Do not adjust user provided values even if they - seem nonsensical (but warn the user)
\ No newline at end of file + seem nonsensical (but warn the user) diff --git a/Master/texmf-dist/doc/latex/fitbox/fitbox.bib b/Master/texmf-dist/doc/latex/fitbox/fitbox.bib index 8e3f9e1727f..e7fbc0b6bbb 100644 --- a/Master/texmf-dist/doc/latex/fitbox/fitbox.bib +++ b/Master/texmf-dist/doc/latex/fitbox/fitbox.bib @@ -4,3 +4,11 @@ title = {{UK} List of {\TeX} Frequently Asked Questions}, year = {2015}, } + +@Manual{FigSize, + title = {The \textsl{FigSize} Package}, + author = {Anthony A. Tanbakuchi}, + month = {March}, + year = 2002, + note = {\url{https://ctan.org/pkg/figsize}}} + diff --git a/Master/texmf-dist/doc/latex/fitbox/fitbox.pdf b/Master/texmf-dist/doc/latex/fitbox/fitbox.pdf Binary files differindex da4caffbe07..3fc9228d468 100644 --- a/Master/texmf-dist/doc/latex/fitbox/fitbox.pdf +++ b/Master/texmf-dist/doc/latex/fitbox/fitbox.pdf diff --git a/Master/texmf-dist/doc/latex/fitbox/napoleon.png b/Master/texmf-dist/doc/latex/fitbox/napoleon.png Binary files differnew file mode 100644 index 00000000000..994fcd9cc69 --- /dev/null +++ b/Master/texmf-dist/doc/latex/fitbox/napoleon.png diff --git a/Master/texmf-dist/doc/latex/fitbox/sample-subfigure.pdf b/Master/texmf-dist/doc/latex/fitbox/sample-subfigure.pdf Binary files differnew file mode 100644 index 00000000000..ba8f3147b70 --- /dev/null +++ b/Master/texmf-dist/doc/latex/fitbox/sample-subfigure.pdf diff --git a/Master/texmf-dist/doc/latex/fitbox/sample-subfigure.tex b/Master/texmf-dist/doc/latex/fitbox/sample-subfigure.tex new file mode 100644 index 00000000000..cd8fd196b7e --- /dev/null +++ b/Master/texmf-dist/doc/latex/fitbox/sample-subfigure.tex @@ -0,0 +1,73 @@ +\documentclass{article} +\usepackage{graphicx} +\usepackage{fitbox} +\usepackage{subfig} +\begin{document} + +The use of fitbox with a subfigure. Note that the optional argument +for the command counts the lines for the subcaptions. + +\SetFitboxLayout[subcaplines=1]{3}{2} + + + + +\begin{figure} + \centering + \subfloat[First + Napoleon]{\fitbox*{\includegraphics{napoleon}}}\quad + \subfloat[Second + Napoleon]{\fitbox*{\includegraphics{napoleon}}}\\ + \subfloat[Third + Napoleon]{\fitbox*{\includegraphics{napoleon}}}\quad + \subfloat[Fourth + Napoleon]{\fitbox*{\includegraphics{napoleon}}}\\ + \subfloat[Fifth + Napoleon]{\fitbox*{\includegraphics{napoleon}}}\quad + \subfloat[Sixth + Napoleon]{\fitbox*{\includegraphics{napoleon}}} + \caption{Six Napoleons, \texttt{\textbackslash SetFitboxLayout[subcaplines=1]\{3\}\{2\}}} + \label{fig:napoleons} +\end{figure} + +\SetFitboxLayout{3}{2} + +\begin{figure} + \centering + \subfloat{\fitbox*{\includegraphics{napoleon}}}\quad + \subfloat{\fitbox*{\includegraphics{napoleon}}}\\ + \subfloat{\fitbox*{\includegraphics{napoleon}}}\quad + \subfloat{\fitbox*{\includegraphics{napoleon}}}\\ + \subfloat{\fitbox*{\includegraphics{napoleon}}}\quad + \subfloat{\fitbox*{\includegraphics{napoleon}}} + \caption{Six Napoleons, no subcaptions, \texttt{\textbackslash SetFitboxLayout\{3\}\{2\}}} + \label{fig:napoleons1} +\end{figure} + +\SetFitboxLayout[subcaplines=1, maincaplines=2]{2}{3} + + + + +\begin{figure} + \centering + \subfloat[First + Napoleon]{\fitbox*{\includegraphics{napoleon}}}\quad + \subfloat[Second + Napoleon]{\fitbox*{\includegraphics{napoleon}}}\quad + \subfloat[Third + Napoleon]{\fitbox*{\includegraphics{napoleon}}}\\ + \subfloat[Fourth + Napoleon]{\fitbox*{\includegraphics{napoleon}}}\quad + \subfloat[Fifth + Napoleon]{\fitbox*{\includegraphics{napoleon}}}\quad + \subfloat[Sixth + Napoleon]{\fitbox*{\includegraphics{napoleon}}} + \caption{Six Napoleons, another arrangement\\ + \texttt{\textbackslash SetFitboxLayout[subcaplines=1, + maincaplines=2]\{2\}\{3\}}} + \label{fig:napoleons3} +\end{figure} + + +\end{document} diff --git a/Master/texmf-dist/doc/latex/fitbox/sample.pdf b/Master/texmf-dist/doc/latex/fitbox/sample.pdf Binary files differindex 92a2a75c9be..f1e26175b5f 100644 --- a/Master/texmf-dist/doc/latex/fitbox/sample.pdf +++ b/Master/texmf-dist/doc/latex/fitbox/sample.pdf diff --git a/Master/texmf-dist/source/latex/fitbox/Makefile b/Master/texmf-dist/source/latex/fitbox/Makefile index 980068232b3..d363063c177 100644 --- a/Master/texmf-dist/source/latex/fitbox/Makefile +++ b/Master/texmf-dist/source/latex/fitbox/Makefile @@ -6,7 +6,7 @@ # PACKAGE=fitbox -SAMPLES = sample.tex +SAMPLES = sample.tex sample-subfigure.tex all: $(PACKAGE).pdf ${SAMPLES:%.tex=%.pdf} diff --git a/Master/texmf-dist/source/latex/fitbox/fitbox.dtx b/Master/texmf-dist/source/latex/fitbox/fitbox.dtx index 48cff414b24..c445c03d877 100644 --- a/Master/texmf-dist/source/latex/fitbox/fitbox.dtx +++ b/Master/texmf-dist/source/latex/fitbox/fitbox.dtx @@ -21,7 +21,7 @@ %</gobble> %<style>\ProvidesPackage{fitbox} %<*style> -[2019/02/10 v1.01 Fitting boxes on a page] +[2019/02/20 v1.02 Fitting boxes on a page] % \end{macrocode} %</style> %<*gobble> @@ -62,7 +62,7 @@ % \GetFileInfo{fitbox.dtx} % % -% \title{Fit graphics on a page\thanks{\copyright 2015 Boris Veytsman} +% \title{Fit graphics on a page\thanks{\copyright 2015--2019 Boris Veytsman} % \thanks{This package was commissined by Neadwerx, \url{http://www.neadwerx.com/}}} % \author{Boris Veytsman \thanks{borisv@lk.net}} % \date{\filedate, \fileversion} @@ -147,7 +147,12 @@ % \item If this also fails, \TeX\ starts a new page and fits the box % there. % \end{enumerate} -% +% +% \DescribeMacro{\fitbox*}% +% The starred version \cs{fitbox*} is intended to be used inside +% floats, where page length is not well defined. This command uses +% only the first two steps of the alogithm above, scaling the box up +% to the maximal dimensions provided by the user. % % \DescribeMacro{\fitboxset}% % The options can be set individually for each \cs{fitbox} command, or @@ -166,11 +171,11 @@ % \cs{fitboxnatheight} are actually \emph{total heights}, including % both height and depth of the corresponding boxes. For example, % \begin{verbatim} -% \fitboxeset{minheight=0.5\fitboxnatheight} +% \fitboxset{minheight=0.5\fitboxnatheight} % \end{verbatim} % means that the box cannot be scaled down more than 50\%. % -% The following options are recognized: +% The following options are recognized by the \cs{fitbox} command: % \begin{description} % \item[maxheight:] The maximal total height of the box. By default % \cs{textheight}. @@ -185,6 +190,42 @@ % \item[maxenlargepage:] The maximal amount to add to the current % page. By default zero. % \end{description} +% +% \DescribeMacro{\SetFitboxLayout}% +% Since version 1.02 the package added the functionality of +% \textsl{FigSize} package~\cite{FigSize}. The latter has a handy +% command \cs{SetFigLayout}, which can be used to scale all figures on +% a page. This package uses the command \cs{SetFitboxLayout} that +% somewhat mimics \cs{SetFigLayout}. The macro has the arguments +% \cs{SetFitboxLayout}\oarg{keys}\marg{rows}\marg{columns}, and helps +% to scale the boxes into a grid. However, unlike \textsl{FigSize} +% package, we do not redefine \cs{includegraphics} command: you should +% use \cs{fitbox} for your graphics. The command \cs{SetFitboxLayout} +% is just \cs{fitboxset} with special values of the parameters. These +% commands can be mixed, with the latest command overriding the +% previous ones. +% +% The following keys are recognized by the \cs{SetFitboxLayout} command: +% \begin{description} +% \item[colsep:] the distance between the columns; by default the size +% of \cs{quad}. +% \item[colsepexpr:] if set, the width of the expression becomes +% \texttt{colsep}. For example, \path{colsepexpr=\quad} makes +% separation between the columns the size of \cs{quad}. +% \item[maincapheight:] The height of the main caption. By default, +% $\cs{abovecaptionskip}+\cs{belowcaptionskip}+ +% n\cs{baselineskip})$ +% where $n$ is the expected number of lines in the main caption (by +% default 1). +% \item[maincaplines:] The number of lines in the main caption. By +% default 1. +% \item[subcapheight:] The height of the subcaption. By default, +% $\cs{abovecaptionskip}+\cs{belowcaptionskip}+m\cs{baselineskip}$ +% where $m$ is the expected number of lines in the subcaptions (by +% default 0). +% \item[subcaplines:] The number of lines in the subcaptions. By +% default 0. +% \end{description} % % %\StopEventually{\clearpage @@ -224,13 +265,40 @@ % \end{macro} % % -% +% \changes{v1.01}{2019/02/20}{New keys for \cs{SetFitboxLayout}} % We use |xkeyval| interface: % \begin{macrocode} \RequirePackage{xkeyval} \define@cmdkeys{FTBX}{maxheight, minheight, maxwidth, minwidth, - belowboxspace, maxenlargepage} + belowboxspace, maxenlargepage, colsep, maincapheight, + subcapheight} +% \end{macrocode} +% +% Setting some keys changes other keys +% \begin{macrocode} +\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}} % \end{macrocode} +% % % \begin{macro}{\fitboxset} % Setting everything @@ -245,7 +313,8 @@ % \begin{macrocode} \fitboxset{maxheight=\textheight, minheight=\fitboxnatheight, maxwidth=\hsize, minwidth=\fitboxnatwidth, - belowboxspace=0pt, maxenlargepage=0pt} + belowboxspace=0pt, maxenlargepage=0pt, colsepexpr={aaa}, + maincaplines=1, subcaplines=0} % \end{macrocode} % % @@ -262,25 +331,43 @@ % % \begin{macro}{\FTBX@desired@maxheight} % The desired maximal height +% \begin{macrocode} \newdimen\FTBX@desired@maxheight +% \end{macrocode} % \end{macro} % % % \begin{macro}{\FTBX@desired@minheight} -% The desired minimal height +% The desired minimal height +% \begin{macrocode} \newdimen\FTBX@desired@minheight +% \end{macrocode} % \end{macro} % % \begin{macro}{\FTBX@available@height} -% The desired available height +% The desired available height +% \begin{macrocode} \newdimen\FTBX@available@height +% \end{macrocode} % \end{macro} % % \begin{macro}{\fitbox} -%\changes{v1.01}{2019/02/10}{Do not force adjusting the width} -% The main command +% \changes{v1.02}{2019/02/18}{Split into normal and starred version} +% The main command % \begin{macrocode} -\newcommand\fitbox[2][]{\leavevmode +\def\fitbox{\@ifstar\@@fitbox\@fitbox} +% \end{macrocode} +% +% \end{macro} +% +% \begin{macro}{\@fitbox} +% \changes{v1.01}{2019/02/10}{Do not force width adjustment} +% \changes{v1.02}{2019/02/17}{\cs{noident} instead of \cs{leavevmode} +% (suggested by Frank Mittelbach)} +% \changes{v1.02}{2019/02/18}{Split into normal and starred version} +% The main command---``normal'' version +% \begin{macrocode} +\newcommand\@fitbox[2][]{\noindent \fitboxset{#1}% \setbox\FTBX@box=\hbox{#2}% \fitboxnatwidth=\wd\FTBX@box\relax @@ -300,17 +387,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 @@ -348,6 +435,87 @@ % % \end{macro} % +% \begin{macro}{\@@fitbox} +% \changes{v1.01}{2019/02/10}{Do not force width adjustment} +% \changes{v1.02}{2019/02/17}{\cs{noident} instead of \cs{leavevmode} +% (suggested by Frank Mittelbach)} +% \changes{v1.02}{2019/02/18}{Split into normal and starred version} +% The main command---``starred'' version. Simplified computations. +% \begin{macrocode} +\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}% +} +% \end{macrocode} +% +% \end{macro} +% +% +%\subsection{Multi-figure layout} +%\label{sec:layout} +% +% +% +% \begin{macro}{\SetFitboxLayout} +% \changes{v1.02}{2019/02/17}{New macro} +% \changes{v1.02}{2019/02/20}{Key-value interface} +% A macro styles after \cs{SetFigsizeLayout} of \textsl{FigSize} +% package. +% \begin{macrocode} +\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}% +} +% \end{macrocode} +% +% \end{macro} +% % \begin{macrocode} %</style> % \end{macrocode} 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'. |