summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/figsize/figsize.sty
blob: ac4d7475d9b5cdee1e85d8d70f1e438c3561380e (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
%%    FIGSIZE
%%        Package to dynamically size figures relative to the page
%%        size.
%%
%%    USER COMMANDS
%%    \usepackage{figsize}
%%        If option distort is present then the included images will
%%        be allowed to have different x & y scaling.  Otherwise
%%        the aspect ratio will be kept.
%%
%%    \SetFigLayout[extra lines of space to add]{rows}{cols}
%%    To set the sizes of graphics relative to the page size in a
%%    cell of a matrix with rows and cols specified.  Optional
%%    integers can be specified to increase the space allowed for
%%    captions.  If a value of 8 is placed, then 8 extra lines of
%%    caption text will be allowed for.
%%
%%    \includegraphics{file}
%%    To include the graphics with the current most size settings.
%%
%%
%%    Anthony Tanbakuchi
%%    Mar.18.2002
%%
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{figsize}[2002/03/18 v0.1 FigSize sizes graphics for graphicx package]
\RequirePackage{calc}[1998/07/07]

%\RequirePackage[tight]{subfigure}[2002/01/01]
\RequirePackage{subfigure}


\RequirePackage{graphicx}[1999/01/01]
\RequirePackage{ifthen}[1994/06/01]

    %The new includegraphics command to automatically size figure
    \let\Oldincludegraphics\includegraphics
    \renewcommand{\includegraphics}[2][width=\figwidth, totalheight=\figheight, keepaspectratio]{\Oldincludegraphics[#1]{#2}}



\newlength{\figwidth}
\newlength{\figheight}


\newcommand{\SetFigLayout}[3][0]{\setlength{\figheight}{\textheight}%
%\addtolength{\figheight}{-0.1\textheight}% 10% for the bottom caption
%\addtolength{\figheight}{-1.4cm}% for caption text 1 line
\addtolength{\figheight}{-\baselineskip-\parskip}% for caption text 1 line
\addtolength{\figheight}{-\abovecaptionskip}%
\addtolength{\figheight}{-\belowcaptionskip}%
\setlength{\figheight}{\figheight / #2}%
\addtolength{\figheight}{(-\baselineskip-\parskip) * (#2-1)}% for subcaption 1 line
\addtolength{\figheight}{-\baselineskip * #1}%  %For additional optional spacing
%
\setlength{\figwidth}{\textwidth}%
\ifthenelse{#3 > 1}{\addtolength{\figwidth}{-0.05\textwidth}}{}% 5% space if multiple cols
\setlength{\figwidth}{\figwidth / #3}%
}

\endinput