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.

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 L^{A}TEXsystem 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.

1For a detailed explanation on how to use the graphics package and the \includegraphics command see the guide to using graphics with L^{A}TEX. Found online at http://www.ctan.org/tex-archive/help/Catalogue/entries/grfguide.html?

\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.]{

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

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

(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).

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

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

(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.

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

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 caption 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

Figure 4: Now the graphic occupies the whole page because we manually specified the parameters to the include graphics command which omitted keepaspectratio.

(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

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.

(c)

Figure 7: This is where your caption text goes.

Table 1: Two tables that are half page width

A B C 555 111 333 555 111 333 555 111 333 555 111 333 555 111 333  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 \\
    \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.