summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/fitbox
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2019-02-22 23:12:27 +0000
committerKarl Berry <karl@freefriends.org>2019-02-22 23:12:27 +0000
commite2ca0b949de808865ea3c39087f4a6057ee0bb2a (patch)
treeccb341f268123355798d7d4c346ca0ea338ed9c3 /Master/texmf-dist/source/latex/fitbox
parent802c94cd45c6b7988569f2050511c00087e91030 (diff)
fitbox (22feb19)
git-svn-id: svn://tug.org/texlive/trunk@50088 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/fitbox')
-rw-r--r--Master/texmf-dist/source/latex/fitbox/Makefile2
-rw-r--r--Master/texmf-dist/source/latex/fitbox/fitbox.dtx204
2 files changed, 187 insertions, 19 deletions
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}