TeXnik - Tips TeX and LaTeX

Welcome to the TeXnik website (under construction)

Floats
 Main page Index UK FAQ Documentation Software CTAN Search CTAN: Statistics Google c.t.t. Google d.c.t.t.
 A Absolute Position in a Page | C Caption beside Figure/Table  |  Captions  |  Caption as Margin  |  Caption width  |  Centering all Floats  |  Compress eps-files  |  Continuing Counting  |  Counter  | D Doublepage Floats  | E Endfloats  |  eps-figures | F Figure side by side |  Float as part of the Margin |  Float beside caption |  Floatflt |  Float placement |  Floats in Twocolumn mode |  Floats other than figure/table/algorithm |  "Floats" over more than one page | H Height/Width not greater than textwidth or textheight | I Image over the full page |  Images side by side | M Multicols and Floats |  Multiple graphics side by side |  Marginnotes inside Floats |  Max Width/Height not greater than textwidth or textheight |  Multiple graphics side by side | N New Floats |  Nonfloats inside Floats  |  Numbering |  Number of Unprocessed floats | P Parameter |  Placement |  Position in a page | R Ref on Subfigure |  Rotating Tables/Images | S Slides and Floats |  Space between floats and text |  Subfigures inside Floats  | T Table and figure side by side |  Tables side by side |  Text flows around figure |  Text beside figure float |  Twocolumn mode and floats | U Unprocessed floats | V Vertical Text beside figure float  | W Width as textwidth and marginwidth floats  |  Width not greater than textwidth or textheight  |  Width of the caption  |  wrapfig package  |
Packages

Important
a figure-, table-, algorithm- or another float is only possible on one page! Therefore a pagebreak in a float is not possible! look at this page for a "nonFloat inside floats".
Read the epslatex documentation for all information around floats, figures and tables.
hvfloat, a useful package for rotating of captions and float objects.

Slides and Floats
Slides have by default no floats! If you want to use them as usual write in preamble:
\usepackage{float}
\newfloat{figure}{H}{lof}
\newfloat{table}{H}{lot}
\providecommand{\figurename}{Figure}
\providecommand{\tablename}{Table}
\floatname{figure}{\figurename}
\floatname{table}{\tablename}

Image/Tabular beside Tabular
For an image beside a tabular inside a float with own captions:

For a tabular beside a tabular inside a float with own captions:

Floats in Twocolumn mode
They are handled as usual. Only for wide floats (\begin{figure*} ... \end{figure*}) which span both column are some restrictions. They are placed by default on the top of each page. With the package stfloats you have addtional the b-option (bottom).

Doublepage Float
If you like your "float" on the left page and the caption on the right one in a twosided document, then load

Image over the full Page
To get something like this:

which is a demo for two a4-pages side by side.

Some of the stuff is only for demonstration and not needed for regular use. The image is available too: lyx1.eps

Captions as Margin Notes
this should also work with more than one line. You need package textpos:
\usepackage{textpos}
\newcommand{\floatmargin}[1]{%
\ifodd\value{page}%
\begin{textblock}{2}(9.5,0)#1\end{textblock}%
\else
\begin{textblock}{2}(-2.5,0)#1\end{textblock}%
\fi%
}
and in the float write before the image in tex (red):
\floatmargin{%
\caption{<... any text ...>}\label{<any label>}
}

Unprocessed Floats
latex lets all floats unprocessed until one page is filled with text or a new chapter/section begins. the number of these unprocessed floats is set to 18! Therefore you'll get an error, when you have more than 18 floats with less text in one chapter/section. There are two ways to prevent this error:
- do a \clearpage behind the th float, where a pagebreak makes sense
- write in latex preamble \usepackage{morefloats}. This package is availabe at CTAN but may also be part of your local tex installation.

Centering all floats
If you want to center for example all of your uncentered figures, you can do this with
\makeatletter
\renewenvironment{figure}[1][]{%
\@float{figure}%
\centering
}{%
\end@float
}
\makeatother

If you like a special placement then write f.ex.:

\makeatletter
\def\fps@figure{pb}
\makeatother

Text around a figure (floatflt or wrapfig)
With these packages you can let the text flow around "floating" figures and "floating" tables

Floating Figure

Floating Table The floatingtable environment is different to the floatingfigure one:

also have a look at http://www.tex.ac.uk/cgi-bin/texfaq2html?label=textflow

Numbering of Floats/Equations
All classes have their own style of numbering floats and equations. You can change this style as for example:

in LaTeX preamble:

\renewcommand{\thefigure}{\thechapter-\arabic{figure}}
\renewcommand{\thetable}{\arabic{chapter}.\roman{table}.}
\renewcommand{\theequation}{\thechapter-\arabic{equation}}
Now the figures and equations are numbered like 2-5, means "chapter-number". This works only for book classes, because artice classes do not have chapters. The tables are numbered like 2.IV.

Figure side by side in a float
With the subfigure-environment it's no problem to put two figures side by side with one main-caption and two optional sub-captions.

If you want the figure side by side but aligned to the top of both you can't use the parameters for minipages/parboxes because we have only one line and these position-parameters are only valid when we have more than one. A table or a figure iss for LaTeX only a character. To get both aligned to the top write in preamble:

\newcommand\myTwoFig[2]{%
\raisebox{-\height}{#1}%
\raisebox{-\height}{#2}%
}
And in text in tex(red) \myTwoFig{}{} the images can be insert with the menu button. If you want this as a float put the preanble stuff into the environment  \begin{figure} ... \end{figure} and add a third parameter for the caption.

For another solution have a look here.

Position in page
Sometimes a single float is positioned on a page without any text. The standard LaTeX definitions are:
\makeatletter
\setlength\@fptop{0\p@ \@plus 1fil}% float at the top
\setlength\@fpsep{8\p@ \@plus 2fil}% space between two floats on one page
\setlength\@fpbot{0\p@ \@plus 1fil}% float at the bottom
\makeatother
If you want this float to be positioned on the top instead of a vertical centering, write in latex preamble the first line, for positioning on the bottom the second one:
\makeatletter
\setlength\@fptop{0\p@}% float at the top
\setlength\@fpbot{0\p@}% float at the bottom
\makeatother

Space between Floats and Text
in text as tex (red) or in the latex-preamble
\setlength{\textfloatsep}{0.5cm}   % as an example
\setlength{\dbltextfloatsep}{0.5cm}   % same for twocolumn-mode

Endfloats - Float Placement

• if you want all floats and the end of your doc use package endfloats, available at CTAN.