summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/figsize/figsize.tex
blob: f0139b84c1df257868cc6182c86fa5c2c018a813 (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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
\documentclass{article}
\usepackage{figsize}


\title{The FigSize Package}
\author{Anthony A. Tanbakuchi \\{\small atanbakuchi@hotmail.com} \\ v0.1 last revised 2002/3/18}
\date{}

\parskip=12pt
\parindent=0pt
\begin{document}
\maketitle
\begin{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.
\end{abstract}

\section{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:

    \verb"\loadpackage{figsize}"\\

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


    \verb"\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),

\verb"\includegraphics{filename}"\footnote{For a detailed
explanation on how to use the graphics package and the
$\backslash$includegraphics command see the guide to using
graphics with \LaTeX. Found online at
http://www.ctan.org/tex-archive/help/Catalogue/entries/grfguide.html?}

Thus, if one issues the command \verb"\SetFigLayout{2}{1}" the
algorithm knows that any graphics inserted after this point with
the command \verb"\includegraphics{...}" should be sized so that
two high by one wide will fit on a page.

When \verb"\SetFigLayout{}{}" is issued the package redefines two
new page relative lengths \verb"\figwidth" and \verb"\figheight".
Then, \verb"\includegraphics{...}" is redefined to by default have
optional parameters set to \\
    \verb"[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,\\
    \verb"\includegraphics[width=\figwidth, totalheight=\figheight]{...}"\\
\noindent Further, one can utilize all the optional facilities
provided by the \verb"\includegraphics{...}" command, simply use
the format,\\
    \verb"\includegraphics[width=\figwidth, totalheight=\figheight, <more options>]{...}"

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

\section{Package Requirements}
When the FigSize package is loaded  it loads the
\textbf{subfigure}, \textbf{graphicx}, \textbf{ifthen}, and
\textbf{calc} packages.  These packages must already exist on the
\LaTeX system for the FigSize package to work properly.

\section{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
\ref{fig:1} and \ref{fig:1b}.

\begin{verbatim}
\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.]{
    \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}
\end{verbatim}


\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.]{\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). The result is shown in Figures \ref{fig:2} and
\ref{fig:2b}.

\begin{verbatim}
\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}
\end{verbatim}

\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.}\label{fig:2}
\end{figure}

\begin{verbatim}
\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}
\end{verbatim}

\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.}\label{fig:2b}
\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 \ref{fig:3}.

\begin{verbatim}
\begin{figure}
    \centering
    \SetFigLayout[3]{2}{2}
    \subfigure[]{\includegraphics{epsfig}} \hfill
    \subfigure[]{\includegraphics{epsfig}}
\end{figure}
\end{verbatim}
\
\begin{figure}
    \centering
    \SetFigLayout[3]{2}{2}
    \subfigure[]{\includegraphics{epsfig}} \hfill
    \subfigure[]{\includegraphics{epsfig}}
    \caption{This is where your caption text goes.}\label{fig:3}
\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{verbatim}

\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}
\end{verbatim}

\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.}\label{fig:4}
\end{figure}

Figure \ref{fig:5} shows how you can mix and match the sizes
relative graphic sizes.

\begin{verbatim}
\begin{figure}
    \centering
    \SetFigLayout[3]{2}{2}
    \subfigure[]{\includegraphics{epsfig}} \hfill
    \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}
\end{verbatim}

\begin{figure}
    \centering
    \SetFigLayout[3]{2}{2}
    \subfigure[]{\includegraphics{epsfig}} \hfill
    \subfigure[]{\includegraphics{epsfig}}
    \SetFigLayout[3]{2}{1}
    \subfigure[]{\includegraphics{epsfig}}
    \caption{This is where your caption text goes.}\label{fig:5}
\end{figure}

Finally, we can utilize the \verb"\figwidth" and \verb"\figheight"
commands for other environments like tables as shown in Table
\ref{tab:1}.  The code that produced the tables was,

\begin{verbatim}
\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
  555 & 111 & 333 \\
  555 & 111 & 333 \\
  555 & 111 & 333 \\
  555 & 111 & 333 \\
  555 & 111 & 333 \\
      \hline
 \end{tabular*}

\end{table}
\end{verbatim}



\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
  555 & 111 & 333 \\
  555 & 111 & 333 \\
  555 & 111 & 333 \\
  555 & 111 & 333 \\
  555 & 111 & 333 \\
      \hline
 \end{tabular*}

\end{table}



\section{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 \TeX hack, just someone who had a wish for this
type of package and managed to find a solution.
\end{document}