summaryrefslogtreecommitdiff
path: root/usergrps/uktug/baskervi/3_2/bailey.tex
diff options
context:
space:
mode:
Diffstat (limited to 'usergrps/uktug/baskervi/3_2/bailey.tex')
-rw-r--r--usergrps/uktug/baskervi/3_2/bailey.tex225
1 files changed, 225 insertions, 0 deletions
diff --git a/usergrps/uktug/baskervi/3_2/bailey.tex b/usergrps/uktug/baskervi/3_2/bailey.tex
new file mode 100644
index 0000000000..af7566f7f1
--- /dev/null
+++ b/usergrps/uktug/baskervi/3_2/bailey.tex
@@ -0,0 +1,225 @@
+\newtheorem{prequestion}{Question}
+\newtheorem{preanswer}{Answer}
+\renewcommand{\thepreanswer}{}
+\newenvironment{question}{\begin{prequestion}\rm}{\end{prequestion}}
+\newenvironment{answer}{\begin{preanswer}\rm}{\end{preanswer}}
+\newcommand{\latexword}[1]{{\rm\tt #1}}
+\newcommand{\lamport}{{\it \LaTeX: A Document Preparation System\/} by Leslie
+Lamport}
+\newcommand{\shortlamp}{{\it The Manual}}
+
+\author[R.~A.~Bailey]{R.~A.~Bailey\\Goldsmiths' College, University of London}
+\title{Topical Tips --- side by side figures in \LaTeX}
+
+\begin{article}
+
+\setlength{\unitlength}{0.1cm}
+\newcommand{\blob}{\circle*{3}}
+
+\begin{question}
+How do I set two figures side by side in \LaTeX?
+\end{question}
+
+\begin{answer}
+I assume that you mean how do you set a pair of figures
+something like Figures~\ref{anova} and~\ref{hasse} below.
+
+
+\begin{figure}[htbp]
+\noindent
+\makebox[\columnwidth]{%
+\begin{minipage}[b]{0.5\columnwidth}
+\[
+\begin{array}{lc}
+\mbox{Source} & \mbox{df}\\
+\hline
+\mbox{blocks} & b-1\\
+\mbox{varieties} & k-1\\
+\mbox{residual} & (b-1)(k-1)\\
+\hline
+\mbox{total} & bk-1
+\end{array}
+\]
+\caption{The analysis-of-variance table\strut}
+\label{anova}
+\end{minipage}%
+\hfill
+\begin{minipage}[b]{0.4\columnwidth}
+\begin{center}
+\begin{picture}(20,25)(-10,-2)
+\put(0,0){\line(0,1){20}}
+\put(0,0){\blob}
+\put(0,10){\blob}
+\put(0,20){\blob}
+\put(0,-4){\makebox(0,0)[t]{$bk$ plots}}
+\put(0,24){\makebox(0,0)[b]{$1$ universe}}
+\put(2,10){\makebox(0,0)[l]{$b$ blocks}}
+\end{picture}
+\end{center}
+\caption{The Hasse diagram\strut}
+\label{hasse}
+\end{minipage}%
+}
+\end{figure}
+
+That pair of figures consists of two objects in a single \latexword{figure}
+environment (more on that later).
+Here is how I did them.
+{\fontseries{n}\selectfont\begin{verbatim}
+\begin{figure}
+ \noindent
+ \makebox[\textwidth]{%
+ \begin{minipage}[b]{0.5\textwidth}
+ <first object>
+ <first caption>
+ \end{minipage}%
+ \hfill
+ \begin{minipage}[b]{0.4\textwidth}
+ <second object>
+ <second caption>
+ \end{minipage}%
+ }
+ \end{figure}
+\end{verbatim}
+}
+\end{answer}
+(Well, what I've just said isn't totally true, but I'll come back to
+that.) The first object is an \latexword{array} inside displayed
+maths, while the second object is a \latexword{picture}. The objects
+can be anything you like, including tables and straight text.
+Figures~\ref{box} and~\ref{alice} are done similarly.
+
+In both cases I've put each object in a \latexword{minipage}: see
+pages 98--99 of \lamport, hereafter called \shortlamp. The
+\latexword{minipage} takes an argument specifying its width. Rather
+than defining the widths of the objects absolutely, I prefer to define
+them in terms of \verb+\+\latexword{textwidth}, which is described on
+page~94 of \shortlamp. I've chosen two fractions which seem to me in
+the right proportion and which add up to less than~1: in
+Figures~\ref{box} and~\ref{alice} the proportions are $0.3$ and $0.6$.
+
+Normally, \latexword{minipage}s are horizontally aligned around a
+central horizontal axis. I prefer to have the two \latexword{caption}s
+lined up nicely, so I have given both the \latexword{minipage}s the
+optional argument \latexword{b}, which aligns them at the bottom.
+
+The two \latexword{minipage}s are put inside a box which is just as
+wide as the text. This is made with \verb+\+\latexword{makebox} (see
+page~97 of \shortlamp\/), whose optional argument specifies the width
+of the box. There is a \verb+\+\latexword{noindent} before it, to make
+sure that there is no space on the left before the box starts. The
+\latexword{\%} sign immediately after the start of the box lets me
+start a new line in the input file without introducing a space before
+the first \latexword{minipage}: in other words, the first
+\latexword{minipage} is flush left to the edge of the text. In the
+same way, the \latexword{\%} sign after each
+\verb+\+\latexword{end}\verb+{+\latexword{minipage}\verb+}+ prevents a
+little inter-word space creeping in after each \latexword{minipage}.
+This fussiness is not evident in Figures~\ref{anova} and~\ref{hasse},
+but does show up in Figures~\ref{box} and~\ref{alice}, which have
+visible outer edges flush with the edges of the surrounding text.
+
+Finally, \verb+\+\latexword{hfill} is put in between the
+two \latexword{minipage}s,
+forcing them as far apart as they will go: see page~96 of \shortlamp.
+
+\begin{figure}[hbp]
+\noindent
+\makebox[\columnwidth]{%
+\begin{minipage}[b]{0.3\columnwidth}
+\begin{picture}(30,30)
+\put(0,0){\framebox(20,10){E}}
+\put(0,10){\framebox(10,10){C}}
+\put(10,10){\framebox(10,10){D}}
+\put(0,20){\framebox(10,10){A}}
+\put(10,20){\framebox(10,10){B}}
+\end{picture}
+\caption{Five objects in one figure}
+\label{box}
+\end{minipage}%
+\hfill
+\begin{minipage}[b]{0.6\columnwidth}
+\begin{flushright}
+Tomorrow, and tomorrow, and tomorrow,
+ creeps in this petty pace from day to day, to
+the last syllable of recorded time; and all our yesterdays have lighted fools
+the way to dusty death.
+\end{flushright}
+\caption{Philosophy}
+\label{alice}
+\end{minipage}%
+}
+\end{figure}
+
+I expect that you asked this question because of a misunderstanding
+about what a \LaTeX\ \latexword{figure} is. It is not really a figure
+at all: it is what \shortlamp\/ calls a {\em float}. That is, it is a
+chunk of text---or maths, or pictures, or whatever---that is treated
+as a whole and is printed in the first convenient place where there is
+room for it. It may contain any number of \latexword{caption}s (even
+none), each of which produces output beginning ``Figure \ldots''. I
+have used the word ``object'' for what you probably think of as a
+figure. You have to visually place the objects and captions within the
+\latexword{figure} so that the captions refer to the correct objects.
+
+If you do not want to force the two objects to the edges of the text, you can
+omit the \latexword{makebox} and put explicit space between the two
+\latexword{minipage}s, something like
+\begin{verbatim}
+ \begin{figure}
+ \centering
+ \begin{minipage}[b]{0.5\textwidth}
+ <first object>
+ <first caption>
+ \end{minipage}%
+ \hspace{1cm}
+ \begin{minipage}[b]{0.4\textwidth}
+ <second object>
+ <second caption>
+ \end{minipage}%
+ \end{figure}
+\end{verbatim}
+
+You can also stack two \latexword{minipage}s on top of each other in a single
+\latexword{figure}. If their total width is more than
+\verb+\+\latexword{textwidth} you do not even have to force them onto two
+separate lines. In this way you can glue five objects together in one figure in
+the arrangement shown in Figure~\ref{box}.
+
+Now to the lies. Since \BV\ is set in two columns, all the figures
+in this article have been done using \verb+\+\latexword{columnwidth}
+instead of \verb+\+\latexword{textwidth}. If you do the captions as I
+have suggested, then that for Figure~\ref{anova} appears to come out a
+little lower than that for Figure~\ref{hasse}. This is because the
+second \latexword{caption} contains the descending letter `g' whereas
+`variance table' contains no descenders. So the bottom of the `g' is
+lined up with the baseline of the first caption. To cure this, we can
+put in the useful command \verb+\+\latexword{strut}, which isn't in
+\shortlamp. It produces no visible output, and has height but no
+width. The principle is explained on page~100 of \shortlamp. The
+command \verb+\+\latexword{strut} produces a strut whose size depends
+on the current font size. It is big enough to cover the descenders and
+ascenders on ordinary letters. Two lines of ordinary text that both
+contain \verb+\+\latexword{strut} both take up the same amount of
+vertical space. So we finish the first and second captions with
+\begin{verbatim}
+ table\strut}
+\end{verbatim}
+and
+\begin{verbatim}
+ diagram\strut}
+\end{verbatim}
+being careful not to introduce an extra inter-word space before the strut.
+
+Any statistician reading this will probably object that
+Figure~\ref{anova} should be called a {\em table}. Here's the rub. I
+can put any number of \latexword{caption}s inside a \latexword{figure}
+and they will all come out ``Figure \ldots''. Similarly, I can put
+several \latexword{caption}s inside a \latexword{table} and they will
+all come out ``Table \ldots''. What I cannot do is mix ``Table''s and
+``Figure''s in the same \LaTeX\ float. In particular, I cannot put a
+``Table'' beside a ``Figure''. Nor can the average \LaTeX\ user. Let
+us hope that the \LaTeX3 team will give us this flexibility.
+
+\end{article}
+