2

I have the following issue; I want to implement an 8x8 table into my Latex document. The code is

\begin{center}
   \begin{table}
       \begin{tabular}{llllllll}
           4  & 6  & 7  & 8  & -2  & -4  & -5  & -6  \\
           5  & 7  & 8  & 9  & -1  & -3  & -4  & -5  \\
           7  & 9  & 10 & 11 & 1   & -1  & -2  & -3  \\
           11 & 13 & 14 & 15 & 5   & 3   & 2   & 1   \\
           2  & 4  & 5  & 6  & -4  & -6  & -7  & -8  \\
           1  & 3  & 4  & 5  & -5  & -7  & -8  & -9  \\
           -1 & 1  & 2  & 3  & -7  & -9  & -10 & -11 \\
           -5 & -3 & -2 & -1 & -11 & -13 & -14 & -15
       \end{tabular}
   \end{table}
\end{center}

However, the result is the following

The table should appear at the very bottom of the image, not at the left corner. I simply don't know what is wrong with this presentation. I have seen other questions on this site that hint the table may just be too large to be contained in the document as it is.

Thanks in advance for your help. What could be a solution?

1
  • 7
    Remove the center environment, and instead use \centering after \begin{table}
    – hesham
    Mar 18, 2020 at 1:18

4 Answers 4

5
  • float environmenta as are table and figure never enclose in any other environment
  • your table actually resembling an matrix, so I suggest to wrote as such with matrix* environment defined in mathtools package
  • it is not clear why you enclose it in float environment if it not contain caption and label for referencing it,
  • i suspect, that it can be written as unnumbered equation and inserted in document on place where you like to have it:
\documentclass{article}
\usepackage{mathtools}
\usepackage{lipsum} % package for dummy text

\begin{document}
\lipsum[1]%dummy text
\[
\begin{matrix*}[r]
4  & 6  & 7  & 8  & -2  & -4  & -5  & -6  \\
5  & 7  & 8  & 9  & -1  & -3  & -4  & -5  \\
7  & 9  & 10 & 11 & 1   & -1  & -2  & -3  \\
11 & 13 & 14 & 15 & 5   & 3   & 2   & 1   \\
2  & 4  & 5  & 6  & -4  & -6  & -7  & -8  \\
1  & 3  & 4  & 5  & -5  & -7  & -8  & -9  \\
-1 & 1  & 2  & 3  & -7  & -9  & -10 & -11 \\
-5 & -3 & -2 & -1 & -11 & -13 & -14 & -15
\end{matrix*}
\]
\lipsum[2]%dummy text
\end{document}

enter image description here

  • In the case, that you like that this table float in document and for example appear at bottom of page (this is not vclear from your question), than you can enclose it in float environment as follows:
\documentclass{article}
\usepackage{mathtools}
\usepackage{lipsum} % package for dummy text

\begin{document}
\lipsum[1] See Table \ref{My table}. %dummy text

\begin{table}[!b]
\caption{My table}
\label{tab:matix}
\[
\begin{matrix*}[r]
4  & 6  & 7  & 8  & -2  & -4  & -5  & -6  \\
5  & 7  & 8  & 9  & -1  & -3  & -4  & -5  \\
7  & 9  & 10 & 11 & 1   & -1  & -2  & -3  \\
11 & 13 & 14 & 15 & 5   & 3   & 2   & 1   \\
2  & 4  & 5  & 6  & -4  & -6  & -7  & -8  \\
1  & 3  & 4  & 5  & -5  & -7  & -8  & -9  \\
-1 & 1  & 2  & 3  & -7  & -9  & -10 & -11 \\
-5 & -3 & -2 & -1 & -11 & -13 & -14 & -15
\end{matrix*}
\]
\end{table}
\lipsum[2]%dummy text
\end{document}

enter image description here

1
  • Yeah, that worked out well. Thanks!
    – Akerbeltz
    Mar 18, 2020 at 10:55
3

A table environment should never be enclosed in a center environment.

There is also no need to enclose a tabular in a table environment: this denotes a floating object, which LaTeX is allowed to place differently than where typed in order to accomodate it and don't ruin the typesetting.

You have a rather big object, which can be treated in various ways.

The codes below are typeset with the common preamble

\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[spanish,es-noquoting,es-nodecimaldot]{babel}
\usepackage{amsmath}

First case: the typesetting poses no real problem in pagination.

Just use a display.

\section{No typesetting problems}

Para encontrar $\gamma\gamma'$ tenemos que hacer una larga computación.
Multiplicando cada término de $\gamma'$ por cada término de $\gamma$,
obtenemos la suma de $\zeta$ elevado a cada una de las potencias que
aparecen en la siguiente tabla
\[
\begin{matrix}
           4  & 6  & 7  & 8  & -2  & -4  & -5  & -6  \\
           5  & 7  & 8  & 9  & -1  & -3  & -4  & -5  \\
           7  & 9  & 10 & 11 & 1   & -1  & -2  & -3  \\
           11 & 13 & 14 & 15 & 5   & 3   & 2   & 1   \\
           2  & 4  & 5  & 6  & -4  & -6  & -7  & -8  \\
           1  & 3  & 4  & 5  & -5  & -7  & -8  & -9  \\
           -1 & 1  & 2  & 3  & -7  & -9  & -10 & -11 \\
           -5 & -3 & -2 & -1 & -11 & -13 & -14 & -15
\end{matrix}
\]

enter image description here

Second case: the table doesn't really fit

You can use a display in a table environment, but also the wording needs to be changed, because you don't know where the table will actually be printed.

\section{Typesetting problems}

Para encontrar $\gamma\gamma'$ tenemos que hacer una larga computación.
Multiplicando cada término de $\gamma'$ por cada término de $\gamma$,
obtenemos la suma de $\zeta$ elevado a cada una de las potencias que
aparecen en el cuadro~\ref{exponents}.

\begin{table}[htp]

\caption{Tabla de potencias}\label{exponents}
\[
\begin{matrix}
           4  & 6  & 7  & 8  & -2  & -4  & -5  & -6  \\
           5  & 7  & 8  & 9  & -1  & -3  & -4  & -5  \\
           7  & 9  & 10 & 11 & 1   & -1  & -2  & -3  \\
           11 & 13 & 14 & 15 & 5   & 3   & 2   & 1   \\
           2  & 4  & 5  & 6  & -4  & -6  & -7  & -8  \\
           1  & 3  & 4  & 5  & -5  & -7  & -8  & -9  \\
           -1 & 1  & 2  & 3  & -7  & -9  & -10 & -11 \\
           -5 & -3 & -2 & -1 & -11 & -13 & -14 & -15
\end{matrix}
\]
\end{table}

In the picture it happens to be at the spot, in your real document it may not.

enter image description here

1

The following code works for me. I put some dummy text to show that it works as you want. The b inside the brackets stays for bottom. You can control the placement of your table with it.

\documentclass{article}
\usepackage{lipsum}%package for dummy text

\begin{document}

\begin{table}[b]
\centering
\begin{tabular}{llllllll}
4  & 6  & 7  & 8  & -2  & -4  & -5  & -6  \\
5  & 7  & 8  & 9  & -1  & -3  & -4  & -5  \\
7  & 9  & 10 & 11 & 1   & -1  & -2  & -3  \\
11 & 13 & 14 & 15 & 5   & 3   & 2   & 1   \\
2  & 4  & 5  & 6  & -4  & -6  & -7  & -8  \\
1  & 3  & 4  & 5  & -5  & -7  & -8  & -9  \\
-1 & 1  & 2  & 3  & -7  & -9  & -10 & -11 \\
-5 & -3 & -2 & -1 & -11 & -13 & -14 & -15
\end{tabular}
\end{table}

\lipsum[1-5]%dummy text

\end{document}

Example

You could also put your \begin{center} after your \begin{table}[b] to reproduce what you want, but I think that is easier and more comfortable to put \centering.

¡Que tengas un buen día!

0

Like this with alignment of the negative prefix and right-aligned on the digits

enter image description here

\documentclass{article}
\usepackage{booktabs,siunitx}

\begin{document}    
 \begin{center}

       \begin{tabular}{  r *{8}{S[table-format=-2.0]}}
           4  & 6  & 7  & 8  & -2  & -4  & -5  & -6  \\
           5  & 7  & 8  & 9  & -1  & -3  & -4  & -5  \\
           7  & 9  & 10 & 11 & 1   & -1  & -2  & -3  \\
           11 & 13 & 14 & 15 & 5   & 3   & 2   & 1   \\
           2  & 4  & 5  & 6  & -4  & -6  & -7  & -8  \\
           1  & 3  & 4  & 5  & -5  & -7  & -8  & -9  \\
           -1 & 1  & 2  & 3  & -7  & -9  & -10 & -11 \\
           -5 & -3 & -2 & -1 & -11 & -13 & -14 & -15
       \end{tabular}

\end{center}
\end{document}

EDIT

Forgot the text part -- added lipsum package -- and update

enter image description here

\documentclass{article}
\usepackage{booktabs,siunitx}
\usepackage{lipsum}

\begin{document}    
\lipsum[2]
\begin{center}

       \begin{tabular}{  r *{8}{S[table-format=-2.0]}}
           4  & 6  & 7  & 8  & -2  & -4  & -5  & -6  \\
           5  & 7  & 8  & 9  & -1  & -3  & -4  & -5  \\
           7  & 9  & 10 & 11 & 1   & -1  & -2  & -3  \\
           11 & 13 & 14 & 15 & 5   & 3   & 2   & 1   \\
           2  & 4  & 5  & 6  & -4  & -6  & -7  & -8  \\
           1  & 3  & 4  & 5  & -5  & -7  & -8  & -9  \\
           -1 & 1  & 2  & 3  & -7  & -9  & -10 & -11 \\
           -5 & -3 & -2 & -1 & -11 & -13 & -14 & -15
       \end{tabular}

\end{center}

\end{document}

EDIT

For bottoming the table on the page simply add \vfill

\begin{document}    
\lipsum[1] 
\vfill
[--]
\end{document

enter image description here

5
  • It doesn't place your table to the bottom of the page. Mar 18, 2020 at 1:35
  • If you put more dummy text, at a certain point, it will create a new page and it will push to the bottom the table with some blank space again. Try my code and see what happens :D Mar 18, 2020 at 1:46
  • depends on what the OP wants -- if bottom is a must even with one line then \vfill --else \vspace* can be used with dimension
    – js bibra
    Mar 18, 2020 at 2:06
  • Oddly, the first column isn't rendered in math mode.
    – Mico
    Mar 18, 2020 at 9:57
  • Why did you chose to use an r type column for the first column? Wouldn't \begin{tabular}{ *{9}{S[table-format=-2.0]}} give a more uniform output? (Take a look at the - signs in the first and escond column to see the difference.)
    – leandriis
    Mar 24, 2020 at 9:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .