Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In brief, the [h!] option to override the default float restrictions for tables and figures does not appear to work.

I am trying to insert a table that takes up a whole page. Due to its size, I have had to define it as a sidewaystable as follows:

\begin{sidewaystable}[h!]
  \begin{center}
    \begin{tabular}{p{4cm}|p{4cm}|p{4cm}|p{5cm}|}
      \hline
      Column 1 & Column 2 & Column 3 & Column 4 \\
      \hline
      \hline
        .
        .
        .
      \hline
    \end{tabular}
    \caption{A Caption}
  \end{center}
\end{sidewaystable}

No matter what I try to do, LaTeX always places it at the end of the document, after my bibliography (i.e. references). What's worse is that any table that I define after this, no matter how big or small, is also placed at the end of the document (after the problematic table).

I seem to have a similar problem with figures. While the [h!] option places some figures immediately after the paragraph I have referenced them in (as expected), LaTeX places other figures one or two pages following the referencing paragraph.

If it helps any, I am using the following document class:

\documentclass[JMC]{degruyter-journal}   % Journal of Mathematical Cryptology

I am also using the following packages:

\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{epsfig}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mathdots}
\usepackage{color}
\usepackage{graphicx}
\usepackage{rotating}
\usepackage{epsf}
\usepackage{float}
\usepackage[lined,ruled]{algorithm2e}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
share|improve this question
    
Do you receive any overfull box warnings? How about adding a \clearpage immediately after the the figure environment? Since the figure will be a full page, does using the float specifier p help? Also, since you're loading the float package, you could use the provided H specifier which is more strict than !h. –  Werner Nov 15 '11 at 3:13
    
@Werner - No overfull warnings, however, I do receive underfull warnings for each hbox that is defined (badness 10000). I also seem to get the following warning generated for the table, and each of the figures I have inserted into the document: LaTeX Warning: '!h' specifier changed to '!ht'. –  Bill Nov 15 '11 at 3:22
    
@Werner - P.S. Adding a \clearpage immediately after the figure environment, or using the p specifier places the figure on a separate page. Furthermore, using the H specifier for the problematic table causes it to disappear from the document altogether!!!! –  Bill Nov 15 '11 at 3:31
add comment

1 Answer

up vote 6 down vote accepted

I've found the following set of instructions works well in the circumstances you describe; I use the \afterpage command provided by the afterpage package.

...
\afterpage{\clearpage
\begin{sidewaystable} % no need for the [h] or even [h!] specifier
\centering % better than \begin{center} ... \end{center}
\begin{tabular}...
...
\end{tabular}
\caption{xyz} \label{tab:xyz}
\end{sidewaystable}
\clearpage } % note the "}" to denote the end of the argument of \afterpage
...

The key is the use of \clearpage commands both before and after the sideways{figure/table} environment.

share|improve this answer
    
Thanks! This not only has solved the problem with the large table. It appears to have fixed the problem with other figures/tables in the document. Once again, thank you! –  Bill Nov 15 '11 at 3:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.