You are on page 1of 12

The FigSize Package

Anthony A. Tanbakuchi
atanbakuchi@hotmail.com
v0.1 last revised 2002/3/18

Abstract

The FigSize package enables automatic sizing of graphics, especially


when including graphics with the graphicx package. The user only has to
specify the number of graphics that should fit to a page or fraction there
of and the package will dynamically calculate the correct graphics sizes
relative to the page size. Thus, graphics can be auto-sized to fill a whole
page or fraction and manual changes of graphic sizes are never needed
when changing document layouts! Finally, the package’s dynamic lengths
can be used to allow other document element sizes to be dynamic.

1 Usage

Perhaps the best way to see how this package works is to skip to the examples
section. However, below is a more general explanation of the package and its
use.

Loading the package:

\loadpackage{figsize}

Next, to allow the FigSize package to dynamically define widths and heights for
the graphic simply specify the desired layout using,

\SetFigLayout[<extra space for long captions>]{<rows>}{<columns>}.

Where you specify the number of rows and columns of graphics that should fit
to a page. Optionally, if you have a long caption you can tell the package how
many extra lines of text that should be allowed for on the page as well.

1
Then, just include the graphic using the command from the graphicx package
(which is just the advanced version of the graphics package),

\includegraphics{filename}1

Thus, if one issues the command \SetFigLayout{2}{1} the algorithm knows


that any graphics inserted after this point with the command \includegraphics{...}
should be sized so that two high by one wide will fit on a page.

When \SetFigLayout{}{} is issued the package redefines two new page relative
lengths \figwidth and \figheight. Then, \includegraphics{...} is rede-
fined to by default have optional parameters set to
[width=\figwidth, totalheight=\figheight, keepaspectratio].

By default, this package makes the assumption that figures should be resized
while keeping their aspect ratio. This may not be the desired effect, to remove
this effect insert figures using,
\includegraphics[width=\figwidth, totalheight=\figheight]{...}
Further, one can utilize all the optional facilities provided by the \includegraphics{...}
command, simply use the format,
\includegraphics[width=\figwidth, totalheight=\figheight, <more options>]{...}

Moreover, one can use the new dynamic widths \figwidth and \figheight for
other types of environments like tables, pictures, and so on.

2 Package Requirements

When the FigSize package is loaded it loads the subfigure, graphicx, ifthen,
and calc packages. These packages must already exist on the LATEXsystem for
the FigSize package to work properly.

3 Examples

The best way to see how this package works is through examples. The next few
examples illustrate common uses for the FigSize package.

The following code sets the size of the graphics so that 4 rows by 3 columns of
them fit to a page. The result is shown in Figure 1 and 2.
1 For a detailed explanation on how to use the graphics package and the

\includegraphics command see the guide to using graphics with LATEX. Found online at
http://www.ctan.org/tex-archive/help/Catalogue/entries/grfguide.html?

2
\begin{figure}
\SetFigLayout{3}{3}
\subfigure[A subfigure.]{\includegraphics{epsfig}}
\hfill
\subfigure[A subfigure.]{\includegraphics{epsfig}}
\hfill
\subfigure[A subfigure.]{\includegraphics{epsfig}} \\
\subfigure[A subfigure.]{\includegraphics{epsfig}}
\hfill
\subfigure[A subfigure.]{\includegraphics{epsfig}}
\hfill
\subfigure[A subfigure.]{\includegraphics{epsfig}} \\
\subfigure[A subfigure.]{\includegraphics{epsfig}}
\hfill
\subfigure[A subfigure.]{\includegraphics{epsfig}}
\hfill
\subfigure[A subfigure.]{
\includegraphics[angle=45, width=\figwidth,
totalheight=\figheight, keepaspectratio]{epsfig}}

\caption{This is where your caption text goes. No


optional parameters.}\label{fig:1}
\end{figure}

\begin{figure}
\SetFigLayout{3}{3}
\subfigure[A subfigure.]{
\includegraphics[width=\figwidth, totalheight=\figheight]{epsfig}}
\hfill
\subfigure[A subfigure.]{
\includegraphics[width=\figwidth, totalheight=\figheight]{epsfig}}
\hfill
\subfigure[A subfigure.]{
\includegraphics[width=\figwidth, totalheight=\figheight]{epsfig}} \\
\subfigure[A subfigure.]{
\includegraphics[width=\figwidth, totalheight=\figheight]{epsfig}}
\hfill
\subfigure[A subfigure.]{
\includegraphics[width=\figwidth, totalheight=\figheight]{epsfig}}
\hfill
\subfigure[A subfigure.]{
\includegraphics[width=\figwidth, totalheight=\figheight]{epsfig}} \\
\subfigure[A subfigure.]{
\includegraphics[width=\figwidth, totalheight=\figheight]{epsfig}}
\hfill
\subfigure[A subfigure.]{

3
Efficiency of Defect Detection Efficiency of Defect Detection Efficiency of Defect Detection
4.5 4.5 4.5

4 4 4

3.5 3.5 3.5

3 3 3

Standard Deviations

Standard Deviations

Standard Deviations
2.5 2.5 2.5
100% Defect Detection Region 100% Defect Detection Region 100% Defect Detection Region

2 2 2

1.5 1.5 1.5

1 1 1

0.5 0.5 0.5

0 0 0
0 0.005 0.01 0.015 0.02 0.025 0.03 0.035 0 0.005 0.01 0.015 0.02 0.025 0.03 0.035 0 0.005 0.01 0.015 0.02 0.025 0.03 0.035
Image Noise Variance Image Noise Variance Image Noise Variance

(a) A subfigure. (b) A subfigure. (c) A subfigure.


Efficiency of Defect Detection Efficiency of Defect Detection Efficiency of Defect Detection
4.5 4.5 4.5

4 4 4

3.5 3.5 3.5

3 3 3
Standard Deviations

Standard Deviations

Standard Deviations
2.5 2.5 2.5
100% Defect Detection Region 100% Defect Detection Region 100% Defect Detection Region

2 2 2

1.5 1.5 1.5

1 1 1

0.5 0.5 0.5

0 0 0
0 0.005 0.01 0.015 0.02 0.025 0.03 0.035 0 0.005 0.01 0.015 0.02 0.025 0.03 0.035 0 0.005 0.01 0.015 0.02 0.025 0.03 0.035
Image Noise Variance Image Noise Variance Image Noise Variance

(d) A subfigure. (e) A subfigure. (f) A subfigure.

Efficiency of Defect Detection Efficiency of Defect Detection

on
cti
4.5 4.5

ete
D
ct
efe
D
of
4 4

y
nc
ie
ic
Eff
3.5 3.5

35
0.0
3 3

n
io
eg
Standard Deviations

Standard Deviations

3
0.0
on
cti
2.5 2.5

ete
4.5
100% Defect Detection Region 100% Defect Detection Region

D
ct
efe

25
0.0
4

D
0%
2 2

10
3.5

ria 2
e
Va 0.0
nc
3
1.5 1.5

e
ois
ns

ag 5
tio
ev 2.5

N
Im .01
ia

e
0
D
ard
nd 2
1 1

1
Sta

0.0
1.5

1
0.5 0.5

05
0.0
0.5
0 0

0
0
0 0.005 0.01 0.015 0.02 0.025 0.03 0.035 0 0.005 0.01 0.015 0.02 0.025 0.03 0.035
Image Noise Variance Image Noise Variance

(g) A subfigure. (h) A subfigure. (i) A subfigure.

Figure 1: This is where your caption text goes. No optional parameters.

\includegraphics[width=\figwidth, totalheight=\figheight]{epsfig}}
\hfill
\subfigure[A subfigure.]{
\includegraphics[angle=45, width=\figwidth,
totalheight=\figheight]{epsfig}}

\caption{This is where your caption text goes.


Optional parameters causing the aspect ratio to be
disregarded.}\label{fig:1b}
\end{figure}

The following code produces a graphic occupying the whole page (maximally).

4
Efficiency of Defect Detection Efficiency of Defect Detection Efficiency of Defect Detection
4.5 4.5 4.5

4 4 4

3.5 3.5 3.5

3 3 3
Standard Deviations

Standard Deviations

Standard Deviations
2.5 2.5 2.5
100% Defect Detection Region 100% Defect Detection Region 100% Defect Detection Region

2 2 2

1.5 1.5 1.5

1 1 1

0.5 0.5 0.5

0 0 0
0 0.005 0.01 0.015 0.02 0.025 0.03 0.035 0 0.005 0.01 0.015 0.02 0.025 0.03 0.035 0 0.005 0.01 0.015 0.02 0.025 0.03 0.035
Image Noise Variance Image Noise Variance Image Noise Variance

(a) A subfigure. (b) A subfigure. (c) A subfigure.

Efficiency of Defect Detection Efficiency of Defect Detection Efficiency of Defect Detection


4.5 4.5 4.5

4 4 4

3.5 3.5 3.5

3 3 3
Standard Deviations

Standard Deviations

Standard Deviations
2.5 2.5 2.5
100% Defect Detection Region 100% Defect Detection Region 100% Defect Detection Region

2 2 2

1.5 1.5 1.5

1 1 1

0.5 0.5 0.5

0 0 0
0 0.005 0.01 0.015 0.02 0.025 0.03 0.035 0 0.005 0.01 0.015 0.02 0.025 0.03 0.035 0 0.005 0.01 0.015 0.02 0.025 0.03 0.035
Image Noise Variance Image Noise Variance Image Noise Variance

(d) A subfigure. (e) A subfigure. (f) A subfigure.

Efficiency of Defect Detection Efficiency of Defect Detection


4.5 4.5

4 4
n
tio
c
ete

3.5 3.5
D
ct
fe
De
of
y
nc
icie

3 3
Eff
Standard Deviations

Standard Deviations

2.5 2.5
35

100% Defect Detection Region 100% Defect Detection Region


0.0
ion
g
Re

3
0.0
on

2 2
cti
ete
4.5

tD
fec

25
De

0.0
4

0%
10

1.5 1.5
3.5

ari .02
ce
eV 0
an
3

ois
s n

ag 5

1 1
tio
via2.5

eN
Im 0.01
De
ard
nd 2

1
Sta

0.0
1.5

0.5 0.5
1

05
0.0
0.5

0 0
0 0.005 0.01 0.015 0.02 0.025 0.03 0.035 0 0.005 0.01 0.015 0.02 0.025 0.03 0.035
0
0

Image Noise Variance Image Noise Variance

(g) A subfigure. (h) A subfigure. (i) A subfigure.

Figure 2: This is where your caption text goes. Optional parameters causing
the aspect ratio to be disregarded.

5
Efficiency of Defect Detection
4.5

3.5

3
Standard Deviations

2.5
100% Defect Detection Region

1.5

0.5

0
0 0.005 0.01 0.015 0.02 0.025 0.03 0.035
Image Noise Variance

Figure 3: A graphic meant to occupy a whole page. Note that the aspect ratio
is respected so the graphic can only occupy the whole text width.

The result is shown in Figures 3 and 4.

\begin{figure}
\SetFigLayout{1}{1}
{\includegraphics{epsfig}}
\caption{A graphic meant to occupy a whole page. Note
that the aspect ratio is respected so the graphic
can only occupy the whole text width.}
\end{figure}

\begin{figure}
\SetFigLayout{1}{1}
{\includegraphics[%
width=\figwidth, totalheight=\figheight]{epsfig}}
\caption{Now the graphic occupies the whole page because
we manually specified the parameters to the

6
include graphics command which omitted keepaspectratio.}
\end{figure}

The next figure is sized such that only two graphics occupy at most half of the
page, allowing for document text to flow onto the rest of the page. The result
is shown in Figure 5.

\begin{figure}
\centering
\SetFigLayout[3]{2}{2}
\subfigure[]{\includegraphics{epsfig}} \hfill
\subfigure[]{\includegraphics{epsfig}}
\end{figure}

The following code is an example of including a full size graphic with a long
caption. The option 5 tells the algorithm to leave space for 5 extra lines of cap-
tion text. Without providing telling the algorithm that the caption is expected
to take at most 5 extra lines than the one allowed an over full box would occur
on the page.

\begin{figure}
\SetFigLayout[5]{1}{1}
{\includegraphics[%
width=\figwidth, totalheight=\figheight]{epsfig}}
\caption{This is where your caption text goes.
This is where your caption text goes.
This is where your caption text goes.
This is where your caption text goes.
This is where your caption text goes.
This is where your caption text goes.
This is where your caption text goes.}
\end{figure}

Figure 7 shows how you can mix and match the sizes relative graphic sizes.

\begin{figure}
\centering
\SetFigLayout[3]{2}{2}
\subfigure[]{\includegraphics{epsfig}} \hfill

7
Efficiency of Defect Detection
4.5

3.5

3
Standard Deviations

2.5
100% Defect Detection Region

1.5

0.5

0
0 0.005 0.01 0.015 0.02 0.025 0.03 0.035
Image Noise Variance
Figure 4: Now the graphic occupies the whole page because we manually speci-
fied the parameters to the include graphics command which omitted keepaspec-
tratio.
8
Efficiency of Defect Detection Efficiency of Defect Detection
4.5 4.5

4 4

3.5 3.5

3 3

Standard Deviations

Standard Deviations
2.5 2.5
100% Defect Detection Region 100% Defect Detection Region

2 2

1.5 1.5

1 1

0.5 0.5

0 0
0 0.005 0.01 0.015 0.02 0.025 0.03 0.035 0 0.005 0.01 0.015 0.02 0.025 0.03 0.035
Image Noise Variance Image Noise Variance

(a) (b)

Figure 5: This is where your caption text goes.

\subfigure[]{\includegraphics{epsfig}}
%Now change the size mid way
\SetFigLayout[3]{2}{1}
\subfigure[]{\includegraphics{epsfig}}
\caption{This is where your caption text goes.}
\end{figure}

Finally, we can utilize the \figwidth and \figheight commands for other
environments like tables as shown in Table 1. The code that produced the
tables was,

\begin{table}
\caption{Two tables that are half page width}\label{tab:1}
\SetFigLayout{1}{2}
\begin{tabular*}{\figwidth}{ccc}
\hline
A & B & C \\ \hline
555 & 111 & 333 \\
555 & 111 & 333 \\
555 & 111 & 333 \\
555 & 111 & 333 \\
555 & 111 & 333 \\
\hline
\end{tabular*}
\hfill
\begin{tabular*}{\figwidth}{ccc}
\hline
A & B & C \\ \hline

9
Efficiency of Defect Detection
4.5

3.5

3
Standard Deviations

2.5
100% Defect Detection Region

1.5

0.5

0
0 0.005 0.01 0.015 0.02 0.025 0.03 0.035
Image Noise Variance

Figure 6: This is where your caption text goes. This is where your caption text
goes. This is where your caption text goes. This is where your caption text
goes. This is where your caption text goes. This is where your caption text
goes. This is where your caption text goes.

10
Efficiency of Defect Detection Efficiency of Defect Detection
4.5 4.5

4 4

3.5 3.5

3 3
Standard Deviations

Standard Deviations
2.5 2.5
100% Defect Detection Region 100% Defect Detection Region

2 2

1.5 1.5

1 1

0.5 0.5

0 0
0 0.005 0.01 0.015 0.02 0.025 0.03 0.035 0 0.005 0.01 0.015 0.02 0.025 0.03 0.035
Image Noise Variance Image Noise Variance

(a) (b)
Efficiency of Defect Detection
4.5

3.5

3
Standard Deviations

2.5
100% Defect Detection Region

1.5

0.5

0
0 0.005 0.01 0.015 0.02 0.025 0.03 0.035
Image Noise Variance

(c)

Figure 7: This is where your caption text goes.

11
Table 1: Two tables that are half page width
A B C A B C
555 111 333 555 111 333
555 111 333 555 111 333
555 111 333 555 111 333
555 111 333 555 111 333
555 111 333 555 111 333

555
& 111 & 333 \\
555
& 111 & 333 \\
555
& 111 & 333 \\
555
& 111 & 333 \\
555
& 111 & 333 \\
\hline
\end{tabular*}

\end{table}

4 Closing

If you like this package, find bugs, or just have useful comments please let the
me know at atanbakuchi@hotmail.com. Please note that I am not a TEXhack,
just someone who had a wish for this type of package and managed to find a
solution.

12

You might also like