8

I'm trying to get a table centered both vertically and horizontally in a landscape page. I've tried some of the solutions proposed around here but I can't get them to work in my specific case.

Here is my code:

\documentclass{article}
\usepackage{float,lscape}
\begin{document}
\begin{landscape}
\begin{table}[htb!]
    \centering
    \tiny
    \setlength{\tabcolsep}{2pt}
    \begin{tabular}{|ll|*4r|*4r|*4r|*4r|*4r|}
    % ...
    \end{tabular}
    \caption{A very wide table}
    \label{tab:wide_table}
\end{table}
\end{landscape}
\end{document}
wizplum
  • 557

1 Answers1

24

Merely to try and provide a minimal working example, I would like to propose the following, adding to the questioner's input the suggestions in the comments.

\documentclass{article}
\usepackage{float,lscape}
\begin{document}
\begin{landscape}
    \begin{table}[p]
        \centering
        \tiny
        \setlength{\tabcolsep}{2pt}
        \begin{tabular}{|ll|*4r|*4r|*4r|*4r|*4r|}
        % ...
        \end{tabular}
        \caption{A very wide table}
        \label{tab:wide_table}
    \end{table}
\end{landscape}
\end{document}

Here I assumed that package lscape is used for the landscape environment, and float for the [htb!] argument, which is changed to [p] for the vertical alignment as David Carlisle pointed out.

Maybe practical for vertically centering other things than tables and figures (that don't take the [p] argument) is this other example.

\documentclass{article}
\usepackage{float,lscape}
\begin{document}
\begin{landscape}
    \topskip0pt
    \vspace*{\fill}
    \begin{table}[htb!]
        \centering
        \tiny
        \setlength{\tabcolsep}{2pt}
        \begin{tabular}{|ll|*4r|*4r|*4r|*4r|*4r|}
        % ...
        \end{tabular}
        \caption{A very wide table}
        \label{tab:wide_table}
    \end{table}
    \vspace*{\fill}
\end{landscape}
\end{document}

The trick in this case is in the \vspace*{\fill}, as was proposed in this other thread: Vertically center text on a page.

Betohaku
  • 1,637