Recently a fellow student asked me how to make a table over the entire width of the page. I don't know why he wanted to do that but I thought it should be easy and wrote the following example:
\documentclass{article}
\usepackage{booktabs}
\usepackage{tabularx}
\newcolumntype{R}{>{\raggedleft\arraybackslash}X}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\begin{document}
\noindent
\makebox[\linewidth][c]{%
\begin{tabularx}{\paperwidth}{XCR}
\toprule
x & x & x \\
xx & xx & xx \\
xxx & xxx & xxx \\
\bottomrule
\end{tabularx}%
}
\end{document}
However, the table was too wide (the grey part is the background of my pdf viewer):

I have printed the value of \paperwidth using a \convertto macro taken from another answer:
\makeatletter
\def\convertto#1#2{\strip@pt\dimexpr #2*65536/\number\dimexpr 1#1}
\makeatother
\convertto{mm}{\paperwidth}mm
It says the value of \paperwidth is 215.90114mm.
But the size of the resulting pdf is according to my viewer A4, Portrait (210 × 297 mm) -- as it should be.
I am using pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2015/dev/Debian) (preloaded format=pdflatex 2017.4.22) and Evince Document Viewer 3.14.1.
How can it be that \paperwidth and the width of the resulting document do not match?
\paperwidthdefaults to USletter size unless you use[a4paper]option – David Carlisle Dec 05 '17 at 10:21article,report,book) letter paper. Therefore, class optiona4paperis needed. – Heiko Oberdiek Dec 05 '17 at 10:22a4paperclass option the table fits as expected. So\paperwidthis independent of the size of the output document? That seems counterintuitive... – jakun Dec 05 '17 at 11:18\paperwidthand friends, AFAIK. Maybe your viewer displays it as A4? – Martin Scharrer Dec 05 '17 at 11:39\papersizeis used to set various tex lengths but it is not used to set the media box in the resulting pdf, that is your system default (a4 or us letter normally) If you add\usepackage{graphics}then the driver specials or pdftex primitives are used to force the pdf media box to match, then your document would have fitted on the page, but the page in your preview would have been us letter sized. – David Carlisle Dec 05 '17 at 12:07