I'm trying to choose the positions of my tables but I can't figure out the difference between [H]
and [h]
. I've seen both advised over my search. If I use [h]
the row spacing is different than [H]
use.
[Tex/LaTex] Difference between [h] and [H] in float position
floatspositioningtables
Related Solutions
\vspace
and other vertical spacing commands can fix it. A blank line after the figure would cause a paragraph break, which is recommendable there. Here's an example:
\documentclass{article}
\usepackage[demo]{graphicx}
\begin{document}
\begin{table}[ht]
\includegraphics{test}
\vspace{1cm}
\begin{tabular}{l}
Text
\end{tabular}
\end{table}
\end{document}
Update
The subfloatrowsep
, floatrowsep
keys give you control on the horizontal separation between subfloats (floats) when using floatrow; however, simply using something like
\thisfloatsetup{subfloatrowsep=qquad}
in your current code will not produce the desired result since you are using \subfloat
(from the subfig
package). The solution is not to use \subfloat
and use floatrow
's \ffigbox
instead. This makes
\thisfloatsetup{subfloatrowsep=qquad}
behave as expected and also solves a problem with the counters (further discussed in How can I get correct labelling of sub-figures with subfig and floatrow?).
\documentclass{article}
\usepackage{graphicx,subfig}
\usepackage[heightadjust=all,valign=c]{floatrow}
\usepackage{fr-subfig}
\begin{document}
\thisfloatsetup{subfloatrowsep=qquad}
\begin{figure}[!htbp]
\captionsetup[subfigure]{justification=centering}
\ffigbox{%
\begin{subfloatrow}[3]%
\ffigbox[\FBwidth]{\caption{Penguins were here and here and here}\label{fig:a}}{%
\includegraphics[height=.1\textheight]{example-image-a}}
\ffigbox[\FBwidth]{\caption{Penguin}\label{fig:b}}{%
\includegraphics[height=.15\textheight]{example-image-b}}
\ffigbox[\FBwidth]{\caption{Penguin}\label{fig:c}}{%
\includegraphics[height=.125\textheight]{example-image-a}}
\end{subfloatrow}
\begin{subfloatrow}
\ffigbox[\FBwidth]{\caption{Penguin}\label{fig:d}}{%
\includegraphics[height=.15\textheight]{example-image-b}}
\ffigbox[\FBwidth]{\caption{Penguins were here, there and everywhere!}\label{fig:e}}{%
\includegraphics[height=.2\textheight]{example-image-a}}
\end{subfloatrow}%
}{%
\caption{Components of the system: Penguins (\ref{fig:a}), Jumpers (\ref{fig:b}), Thingies (\ref{fig:c}), Cabbages (\ref{fig:d}) and Nuclear Warheads (\ref{fig:e})\label{fig:x}}%
}
\end{figure}
\end{document}
The output:
Initial version
I've also had problems with horizontal positioning of figures using floatrow
and the floatrowsep
, subfloatrowsep
keys seem to not always behave as expected.
One option that I've found to work in problematic cases is to kill the default separation with subfloatrowsep=none
and then use \quad
or any other spacing command to manually control the separation (one would think that subfloatrowsep=quad
would handle this automatically, but this is not always the case). Anyways, my suggestion:
\documentclass{article}
\usepackage{graphicx,subfig}
\usepackage[heightadjust=all,valign=c]{floatrow}
\usepackage{fr-subfig}
\begin{document}
\thisfloatsetup{subfloatrowsep=none}
\begin{figure}[!htbp]
\captionsetup[subfigure]{justification=centering}
\floatbox{figure}{%
\caption{%
Components of the system: Penguins (\ref{fig:a}), Jumpers (\ref{fig:b}), Thingies (\ref{fig:c}), Cabbages (\ref{fig:d}) and Nuclear Warheads (\ref{fig:e})%
}\label{fig:x}%
}{%
\begin{subfloatrow}%
\subfloat[Penguins were here and here and here]{%
\includegraphics[height=.1\textheight]{example-image-a}\label{fig:a}}%
\qquad
\subfloat[Penguin]{%
\includegraphics[height=.15\textheight]{example-image-b}\label{fig:b}}
\qquad
\subfloat[Penguin]{%
\includegraphics[height=.125\textheight]{example-image-a}\label{fig:c}}
\end{subfloatrow}
\begin{subfloatrow}
\subfloat[Penguin]{%
\includegraphics[height=.15\textheight]{example-image-b}\label{fig:d}}
\qquad
\subfloat[Penguins were here, there and everywhere!]{%
\includegraphics[height=.2\textheight]{example-image-a}\label{fig:e}}
\end{subfloatrow}}
\end{figure}
\end{document}
Best Answer
Never use
[h]
on its own, it is basically an error waiting to happen and LaTeX will most likely give a warning and change it to[ht]
.LaTeX has four float areas into which a float may be placed: top of page (
t
), bottom of page (b
),here
where the float appears in the source (h
) and on a float page with only floats and no text (p
).H
makes the environment essentially not a float at all it is more or less the same as usingminipage
except that\caption
works, but you can caption minipages using thecapt-of
package.H
should be used sparingly, like any large box, it is likely to produce bad page breaks with large amounts of white space.If you use the optional argument of a float you are mostly restricting the float areas to which the float may be allocated. If you over-restrict it is likely that the float can not be positioned at all, and will then go to the end of the document. So if you want to allow
h
it is best to allowt
andp
as well so use[tph]
. You should almost always usep
if you use the optional argument.