blob: d7cb4baa52c90fdb43beda26795213fca34725a0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
\ProvidesPackage{scalerel}
[2013/03/11 v1.1
Routines for constrained scaling and stretching of objects,
relative to a reference object or in absolute terms]
%% Copyright 2013 Steven B. Segletes
%
% 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 this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Steven B. Segletes.
% V1.01 Correct typos in documentation
% V1.1 Corrected usepackage dependencies; Significant doc rewrite.
\usepackage{calc}
\usepackage{graphicx}
\global\newlength\thesrwidth
\global\newlength\thesrheight
\global\newlength\srblobheight
\global\newlength\srblobdepth
\global\newlength\mnxsrwidth
\newsavebox{\prebox}
\newcommand\scalerel{\@ifstar{\scalerelplain}{\scalerelplus}}
\newcommand\scalerelplain[3][99in]{%
\sbox{\prebox}{$#2$}%
\setbox0\hbox{$#3$}%
\setlength\srblobheight{\ht0+\dp0}%
\setlength\srblobdepth{\dp0}%
\setbox0\hbox{$#2$}%
\setlength\thesrwidth{\wd0*\ratio{\srblobheight}{\ht0+\dp0}}%
\setlength\thesrheight{\ht0*\ratio{\srblobheight}{\ht0+\dp0}}%
\setlength\mnxsrwidth{#1}%
\ifdim\thesrwidth>\mnxsrwidth\setlength\thesrwidth{\mnxsrwidth}\fi%
\raisebox{-\srblobdepth+\dp0*\ratio{\srblobheight}{\ht0+\dp0}}%
{\resizebox{\thesrwidth}{\thesrheight}{\usebox{\prebox}}}%
}
\newcommand\scalerelplus[3][99in]{\scalerelplain[#1]{#2}{#3}#3}
\newcommand\stretchrel{\@ifstar{\stretchrelplain}{\stretchrelplus}}
\newcommand\stretchrelplain[3][10000]{%
\sbox{\prebox}{$#2$}%
\setbox0\hbox{$#3$}%
\setlength\srblobheight{\ht0+\dp0}%
\setlength\srblobdepth{\dp0}%
\setbox0\hbox{$#2$}%
\setlength\thesrwidth{\wd0}%
\setlength\thesrheight{\ht0*\ratio{\srblobheight}{\ht0+\dp0}}%
\setlength\mnxsrwidth{\thesrheight*100/#1}
\ifdim\thesrwidth<\mnxsrwidth\setlength\thesrwidth{\mnxsrwidth}\fi%
\raisebox{-\srblobdepth+\dp0*\ratio{\srblobheight}{\ht0+\dp0}}%
{\resizebox{\thesrwidth}{\thesrheight}{\usebox{\prebox}}}%
}
\newcommand\stretchrelplus[3][10000]{\stretchrelplain[#1]{#2}{#3}#3}
\newcommand\scaleto[3][99in]{%
\sbox{\prebox}{$#2$}%
\setlength\srblobheight{#3}%
\setlength\srblobdepth{0pt}%
\setbox0\hbox{$#2$}%
\setlength\thesrwidth{\wd0*\ratio{\srblobheight}{\ht0+\dp0}}%
\setlength\thesrheight{\ht0*\ratio{\srblobheight}{\ht0+\dp0}}%
\setlength\mnxsrwidth{#1}%
\ifdim\thesrwidth>\mnxsrwidth\setlength\thesrwidth{\mnxsrwidth}\fi%
\setlength\srblobdepth{\dp0*\ratio{\srblobheight}{\ht0+\dp0}}%
\raisebox{-\srblobdepth+\dp0*\ratio{\srblobheight}{\ht0+\dp0}}%
{\resizebox{\thesrwidth}{\thesrheight}{\usebox{\prebox}}}%
}
\newcommand\stretchto[3][10000]{%
\sbox{\prebox}{$#2$}%
\setlength\srblobheight{#3}%
\setlength\srblobdepth{0pt}%
\setbox0\hbox{$#2$}%
\setlength\thesrwidth{\wd0}%
\setlength\thesrheight{\ht0*\ratio{\srblobheight}{\ht0+\dp0}}%
\setlength\mnxsrwidth{\thesrheight*100/#1}
\ifdim\thesrwidth<\mnxsrwidth\setlength\thesrwidth{\mnxsrwidth}\fi%
\setlength\srblobdepth{\dp0*\ratio{\srblobheight}{\ht0+\dp0}}%
\raisebox{-\srblobdepth+\dp0*\ratio{\srblobheight}{\ht0+\dp0}}%
{\resizebox{\thesrwidth}{\thesrheight}{\usebox{\prebox}}}%
}
\endinput
|