From b8487f5800276cf85bb543f7405b7315580bc450 Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Mon, 17 Aug 2015 22:18:08 +0000
Subject: fitbox (17aug15)

git-svn-id: svn://tug.org/texlive/trunk@38139 c570f23f-e606-0410-a88d-b1316a301751
---
 Master/texmf-dist/tex/latex/fitbox/fitbox.sty | 124 ++++++++++++++++++++++++++
 1 file changed, 124 insertions(+)
 create mode 100644 Master/texmf-dist/tex/latex/fitbox/fitbox.sty

(limited to 'Master/texmf-dist/tex/latex/fitbox/fitbox.sty')

diff --git a/Master/texmf-dist/tex/latex/fitbox/fitbox.sty b/Master/texmf-dist/tex/latex/fitbox/fitbox.sty
new file mode 100644
index 00000000000..4e0d63b964d
--- /dev/null
+++ b/Master/texmf-dist/tex/latex/fitbox/fitbox.sty
@@ -0,0 +1,124 @@
+%%
+%% This is file `fitbox.sty',
+%% generated with the docstrip utility.
+%%
+%% The original source files were:
+%%
+%% fitbox.dtx  (with options: `style')
+%% 
+%% IMPORTANT NOTICE:
+%% 
+%% For the copyright see the source file.
+%% 
+%% Any modified versions of this file must be renamed
+%% with new filenames distinct from fitbox.sty.
+%% 
+%% For distribution of the original source see the terms
+%% for copying and modification in the file fitbox.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.)
+%% Copyright 2015, Boris Veytsman <borisv@lk.net
+%% 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 the license is in
+%%    http://www.latex-project.org/lppl.txt
+%% and version 1.3 or later is part of all distributions of
+%% LaTeX version 2003/06/01 or later.
+%%
+%% This work has the LPPL maintenance status `maintained'.
+%%
+%% The Current Maintainer of this work is Boris Veytsman
+%%
+\NeedsTeXFormat{LaTeX2e}
+\ProvidesPackage{fitbox}
+[2015/02/02 v1.00 Fitting boxes on a page]
+\newdimen\fitboxnatheight
+\newdimen\fitboxnatwidth
+\RequirePackage{xkeyval}
+\define@cmdkeys{FTBX}{maxheight, minheight, maxwidth, minwidth,
+  belowboxspace, maxenlargepage}
+\def\fitboxset#1{\setkeys{FTBX}{#1}}
+\fitboxset{maxheight=\textheight, minheight=\fitboxnatheight,
+  maxwidth=\textwidth, minwidth=\fitboxnatwidth,
+  belowboxspace=0pt, maxenlargepage=0pt}
+\newbox\FTBX@box
+\newdimen\FTBX@desired@maxheight
+\newdimen\FTBX@desired@minheight
+\newdimen\FTBX@available@height
+\newcommand\fitbox[2][]{\leavevmode
+  \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 larger than page
+        width.  Adjusting...}%
+      \def\cmd@KV@FTBX@minwidth{\columnwidth}%
+  \fi
+  \expandafter\ifdim\cmdKV@FTBX@maxwidth>\columnwidth\relax
+      \PackageWarning{fitbox}{Desired width is larger than page
+        width.  Adjusting...}%
+      \def\cmd@KV@FTBX@maxwidth{\columnwidth}%
+  \fi
+  \expandafter\ifdim\cmdKV@FTBX@minheight>\textheight\relax
+      \PackageWarning{fitbox}{Minimal height is larger than page
+        height.  Adjusting...}%
+      \def\cmd@KV@FTBX@minheight{\textheight}%
+  \fi
+  \expandafter\ifdim\cmdKV@FTBX@maxheight>\textheight\relax
+      \PackageWarning{fitbox}{Desired height is larger than page
+        height.  Adjusting...}%
+      \def\cmd@KV@FTBX@maxheight{\textheight}%
+  \fi
+  % Calculating the minimal and maximal height
+  \Gscale@div{\@tempa}{\cmdKV@FTBX@maxwidth}{\fitboxnatwidth}%
+  \FTBX@desired@maxheight=\@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
+  \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 min
+        scale.  Adjusting...}%
+      \FTBX@desired@minheight=\FTBX@desired@maxheight\relax
+  \fi
+  \FTBX@available@height=\pagegoal\relax
+  \ifdim\FTBX@available@height>\vsize\relax
+    \FTBX@available@height=\vsize
+  \fi
+  \advance\FTBX@available@height by -\pagetotal\relax
+  \advance\FTBX@available@height by -\cmdKV@FTBX@belowboxspace\relax
+  \advance\FTBX@available@height by -\baselineskip\relax
+  \ifdim\FTBX@desired@maxheight>\FTBX@available@height\relax
+     \ifdim\FTBX@available@height<\FTBX@desired@minheight\relax
+        \@tempdima=\FTBX@desired@minheight\relax
+        \advance\@tempdima by
+        -\FTBX@available@height\relax
+        \expandafter\ifdim\cmdKV@FTBX@maxenlargepage<\@tempdima\relax
+          \newpage
+          \resizebox*{!}{\FTBX@desired@maxheight}{\box\FTBX@box}%
+        \else
+          \enlargethispage{\@tempdima}%
+          \resizebox*{!}{\FTBX@desired@minheight}{\box\FTBX@box}%
+        \fi
+      \else
+       \resizebox*{!}{\FTBX@available@height}{\box\FTBX@box}%
+      \fi
+  \else
+     \resizebox*{!}{\FTBX@desired@maxheight}{\box\FTBX@box}%
+  \fi
+}
+\endinput
+%%
+%% End of file `fitbox.sty'.
-- 
cgit v1.2.3

