# Changing margins so a table fits in current page

I'm trying to fit a table in a specific a4paper page without success. The problem seems quite trivial to solve but i'm not getting the table in place. Saw on the web that newgeometry affects the whole page so maybe that's why is floating to a new page, but i dont know any other solution to locally change margins of a single page multiple times. The following page illustrates the problem.

Any ideas? Thank you.

• Hi, welcome. \newgeometry always starts a new page I think, but you can use adjustbox or a \makebox, see e.g. tex.stackexchange.com/questions/39435/… Aug 29, 2017 at 11:14
• Welcome to TeX SX! You have the adjustwidth environment from changepage. Before using this environment, check whether you can play with the value of \tabcolsep (very efficient in case of many columns) and the table font size. Aug 29, 2017 at 11:43

Here I use a \makebox[\textwidth]{} into which I place something wider than \textwidth. While I show it inside of a table, that is not necessary to employ this technique.

\documentclass{article}
\usepackage{lipsum,tabularx}
\begin{document}
\lipsum[1]
\begin{table}[ht]
\makebox[\textwidth]{\begin{tabularx}{1.2\textwidth}{|c|c|X|}
\hline
This & is & a test\\
\hline
\end{tabularx}}
\end{table}
\lipsum[2]
\end{document}


• I there. I actually get the solution using makebox but in a different way alongside with resizebox to resize the table. \begin{table}[H] \makebox[1 \textwidth][c]{ %to center table \resizebox{1.2 \textwidth}{!}{ %to resize table \begin{tabular}{|l|c|c|l|} ....... \end{tabular} } %close table } %close resize \end{table} Aug 29, 2017 at 11:32
• @CarlosSá I did not resize the tabular content, but yes you should be able to combine the margin relaxation of a \makebox[\textwidth]{} with the rescale feature of a \resizebox. Aug 29, 2017 at 11:37

Here's how to do it with the adjustwidth environment:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{changepage}
\usepackage{ragged2e, lipsum}
\usepackage{tabularx, caption, booktabs}

\begin{document}

\lipsum[1]

\begin{table}[!htb]
\centering
\captionsetup{singlelinecheck=off, skip =4pt}
\caption{A wide table}\label{tab:wide}
\begin{tabularx}{\linewidth}{@{}>{\RaggedRight}X@{}}
\toprule
Sed feugiat. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.
Ut pellentesque augue sed urna. Vestibulum diam eros, fringilla et, consectetuer eu, nonummy id,
sapien. Nullam at lectus. In sagittis ultrices mauris. Curabitur malesuada erat sit amet massa. Fusce
blandit. Aliquam erat volutpat. Aliquam euismod. Aenean vel lectus. Nunc imperdiet justo nec do-
lor. \\
\bottomrule
\end{tabularx}
\end{table}
\lipsum[2]

\end{document}


We will want to keep it simple and put the tabular inside a \makebox of \textwidth. The actual tabular material gets centered nicely.

\documentclass{article}

\pagenumbering{gobble}

\usepackage{lipsum}

\usepackage[showframe,a4paper]{geometry}

\begin{document}
\lipsum[1]

\begin{table}[!tb]
\makebox[\textwidth][c]{%
\begin{tabular}{p{0.4\textwidth}p{0.4\textwidth}p{0.4\textwidth}}
\hline
\lipsum[1]&\lipsum[1]&\lipsum[1]\\
\hline
\end{tabular}}
\caption{This table is wider than the page.}
\label{tab:toowide}
\end{table}

\lipsum[2]

\end{document}