2

I have a custom papersize and margins set with geometry package. Now I want a table to reach over the complete page (not the margins)

\begin{tabularx}{\textwidth}{ |X|X|X|X| }
   \hline
   label 1 & label 2 & label 3 & label 4 \\
   \hline 
   item 1  & item 2  & item 3  & item 4  \\
   \hline
\end{tabularx}

now the table has the wished width but is shifted a bit to the right (I used \usepackage{showframe} so you can see where the tabular should start and end)

pic

What am I doing wrong?

0
3

tabularx simply inserts a table at the point where the environment is called. In your case, you do it at the beginning of line where usually an indent is inserted as well. You can simply suppress the indentation with \noindent:

\documentclass[10pt]{article}

\usepackage[showframe]{geometry}
\usepackage{tabularx}

\begin{document}

\begin{tabularx}{\textwidth}{ |X|X|X|X| }
  \hline
  label 1 & label 2 & label 3 & label 4 \\
  \hline 
  item 1  & item 2  & item 3  & item 4  \\
  \hline
\end{tabularx}

\vspace{3ex}

\noindent
\begin{tabularx}{\textwidth}{ |X|X|X|X| }
  \hline
  label 1 & label 2 & label 3 & label 4 \\
  \hline 
  item 1  & item 2  & item 3  & item 4  \\
  \hline
\end{tabularx}

\end{document}

enter image description here

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.