0

Seems a stupid problem, but I can't find solutions on previously answered questions here on tex.stackexchange. I have the following table (pretty simple):

\begin{table}[h]
  \centering
  \begin{center}
  \begin{tabular}{ | p{2.5cm} | p{2.5cm} | p{1.5cm} | p{2cm} | p{1.2cm} | p{3cm} | p{1cm} |}

    \hline
    Id\_String &    Date &  E\_prod & MaxPm & FragPm & Tmax & Tprod \\ \hline
    blah & 
    blah &  
    blah &  
    blah &
    blah &
    blah &
    blah \\
    \hline
   \end{tabular}
  \caption{Blah blah blah.}
  \label{table:blah}
  \end{center}
 \end{table}

Which results in the following:

Table not centered

So as you can see the table is not in the center of the sheet (which is as wide as the screenshot), but it "overflows" on the right. I'd like it to start a little bit on the left in order to be perfectly centered in the pdf.

tex.stackexchange, what to do?

EDIT: The solution proposed in here does not solve the issue. The result I obtain by applying such solution is exactly the same as shown here.

Masiar
  • 535

1 Answers1

1

This is certainly a duplicate, but since you say you couldn't make it work, here is a way.

Put the table inside a box:

\documentclass{article}
\usepackage{showframe}  %% just for demo
\begin{document}
  \begin{table}[h]
  \centering
  \makebox[\textwidth]{%
  \begin{tabular}{ | p{2.5cm} | p{2.5cm} | p{1.5cm} | p{2cm} | p{1.2cm} | p{3cm} | p{1cm} |}
    \hline
    Id\_String &    Date &  E\_prod & MaxPm & FragPm & Tmax & Tprod \\ \hline
    blah &
    blah &
    blah &
    blah &
    blah &
    blah &
    blah \\
    \hline
   \end{tabular}
   }
  \caption{Blah blah blah.}
  \label{table:blah}
 \end{table}
\end{document}

enter image description here

You can also use adjustbox package:

\documentclass{article}
\usepackage{showframe}
\usepackage{adjustbox}
\begin{document}
  \begin{table}[h]
  \begin{adjustbox}{center}
  \begin{tabular}{ | p{2.5cm} | p{2.5cm} | p{1.5cm} | p{2cm} | p{1.2cm} | p{3cm} | p{1cm} |}
    \hline
    Id\_String &    Date &  E\_prod & MaxPm & FragPm & Tmax & Tprod \\ \hline
    blah &
    blah &
    blah &
    blah &
    blah &
    blah &
    blah \\
    \hline
   \end{tabular}
   \end{adjustbox}
  \caption{Blah blah blah.}
  \label{table:blah}
 \end{table}
\end{document}