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.

1
  • a simple solution is provided in the link, which you provide (see third answer). – Zarko Sep 24 '15 at 12:03
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}
1
  • Thanks a lot! Adjustbox was exactly what I was looking for! – Masiar Sep 24 '15 at 14:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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