4

I would like to indent a tabular environment so that it is to the left than usual. This is because my table doesn't quite fit the page. (Don't worry that it is not the "right" thing to do; this is just an informal document.)

\documentclass[fontsize=11pt]{scrartcl}
\usepackage{amsmath,amssymb,amsfonts,amsthm,url,hyperref}

\begin{document}

\begin{tabular}{ | p{3cm} | p{3cm} | p{3cm} | p{2cm} | p{2cm} | p{2cm} | }
\hline
abcdabcd abcd & abcdabcd abcd & abcdabcd abcd & abcdabcd & abcdabcd & abcdabcd \\ \hline
abcdabcd & abcdabcd & abcdabcd & abcdabcd & abcdabcd & abcdabcd \\ \hline
abcdabcd & abcdabcd & abcdabcd & abcdabcd & abcdabcd & abcdabcd \\ \hline
\end{tabular}

\end{document}

You can see that the table overflows to the right of the document. So it would be nice to move the whole table a little to the left, so the two sides balance out.

I don't want to use \setlength{\parindent}, because that would set the indent globally. It doesn't make sense to use \indent or \noindent either, because that would only make it stay the same or move it to the right. How can I do it?

  • Welcome to TeX.SX!. When asking questions it is better to provide a full minimal working example (MWE) both in order to demonstrate what you are trying to do and to help others help you. The MWE should look like \documentclass...\begin{document}...\end{document}, it should compile and contain close to the minimal amount of code needed to explain/demonstrate what you are asking. This saves everyone time:) – Andrew Nov 21 '14 at 4:39
  • This question is very similar in nature to Centre an image, ignoring margins, even though it's for a tabular. – Werner Nov 21 '14 at 5:47
3

Use of adjustwidth from changepage package. Within an adjustwidth environment the left and right margins can be adjusted. The environment takes two required length arguments:

\begin{adjustwidth}{<leftmargin>}{<rightmargin>} ... \end{adjustwidth}

A positive length value will increase the relevant margin (shortening the text lines) while a negative length value will decrease the margin (lengthening text lines). An empty length argument means no change to the margin. At the end of the environment the margins revert to their original values

enter image description here

Code

\documentclass[fontsize=11pt]{scrartcl}
\usepackage{amsmath,amssymb,amsfonts,amsthm,url,hyperref}
\usepackage{changepage}
\usepackage[showframe]{geometry}
\begin{document}


\begin{adjustwidth}{0cm}{0cm}
\begin{tabular}{ | p{3cm} | p{3cm} | p{3cm} | p{2cm} | p{2cm} | p{2cm} | }
\hline
abcdabcd abcd & abcdabcd abcd & abcdabcd abcd & abcdabcd & abcdabcd & abcdabcd \\ \hline
abcdabcd & abcdabcd & abcdabcd & abcdabcd & abcdabcd & abcdabcd \\ \hline
abcdabcd & abcdabcd & abcdabcd & abcdabcd & abcdabcd & abcdabcd \\ \hline
\end{tabular}
\end{adjustwidth}

\bigskip

\begin{adjustwidth}{-1cm}{0cm}
\begin{tabular}{ | p{3cm} | p{3cm} | p{3cm} | p{2cm} | p{2cm} | p{2cm} | }
\hline
abcdabcd abcd & abcdabcd abcd & abcdabcd abcd & abcdabcd & abcdabcd & abcdabcd \\ \hline
abcdabcd & abcdabcd & abcdabcd & abcdabcd & abcdabcd & abcdabcd \\ \hline
abcdabcd & abcdabcd & abcdabcd & abcdabcd & abcdabcd & abcdabcd \\ \hline
\end{tabular}
\end{adjustwidth}

\bigskip

\begin{adjustwidth}{-2cm}{0cm}
\begin{tabular}{ | p{3cm} | p{3cm} | p{3cm} | p{2cm} | p{2cm} | p{2cm} | }
\hline
abcdabcd abcd & abcdabcd abcd & abcdabcd abcd & abcdabcd & abcdabcd & abcdabcd \\ \hline
abcdabcd & abcdabcd & abcdabcd & abcdabcd & abcdabcd & abcdabcd \\ \hline
abcdabcd & abcdabcd & abcdabcd & abcdabcd & abcdabcd & abcdabcd \\ \hline
\end{tabular}
\end{adjustwidth}

\end{document}
| improve this answer | |
3

You can apply a \hspace*{<length>} with a negative length value:

enter image description here

Notes:

  • The showframe package was used just to show the page margins. It is not needed in your actual use case.

Code:

\documentclass[fontsize=11pt]{scrartcl}
\usepackage{amsmath,amssymb,amsfonts,amsthm,url,hyperref}
\usepackage{showframe}

\begin{document}
\hspace*{-2.0cm}%
\begin{tabular}{ | p{3cm} | p{3cm} | p{3cm} | p{2cm} | p{2cm} | p{2cm} | }
\hline
abcdabcd abcd & abcdabcd abcd & abcdabcd abcd & abcdabcd & abcdabcd & abcdabcd \\ \hline
abcdabcd & abcdabcd & abcdabcd & abcdabcd & abcdabcd & abcdabcd \\ \hline
abcdabcd & abcdabcd & abcdabcd & abcdabcd & abcdabcd & abcdabcd \\ \hline
\end{tabular}

\end{document}
| improve this answer | |
1

I am not entirely sure what you want since you say "It doesn't make sense to use \indent or \noindent either, because that would only make it stay the same or move it to the right."

If you just want to move the tablular environment to the left then the easiest way is probably to use kern:

\documentclass{article}
\usepackage[showframe]{geometry}
\begin{document}

\noindent
\kern-20mm
\begin{tabular}{lll}
  1&2&3 and this one is really really really really really really  really really really really  really really really really long
\end{tabular}

\end{document}

This produces:

enter image description here

| improve this answer | |
  • Adding \kern-20mm before my tabular doesn't seem to have any effect. – Dexter Nov 21 '14 at 5:02
  • @Dexeter You also need the \noindent. This said, Peter Gill's suggestion of using \hspace* is probably the "official" way to do this using LaTeX -- and it also has the advantage of not needing the \noindent. – Andrew Nov 21 '14 at 5:42
1

You can use a box:

\documentclass{scrartcl}
\usepackage{lipsum,showframe}

\begin{document}

\lipsum[1]

\noindent
\makebox[\textwidth][c]{%   %<-------------
\begin{tabular}{ | p{3cm} | p{3cm} | p{3cm} | p{2cm} | p{2cm} | p{2cm} | }
\hline
abcdabcd abcd & abcdabcd abcd & abcdabcd abcd & abcdabcd & abcdabcd & abcdabcd \\ \hline
abcdabcd & abcdabcd & abcdabcd & abcdabcd & abcdabcd & abcdabcd \\ \hline
abcdabcd & abcdabcd & abcdabcd & abcdabcd & abcdabcd & abcdabcd \\ \hline
\end{tabular}
}%                           %<------------

\end{document}

enter image description here

Or use goodies from adjustbox package:

\documentclass{scrartcl}
\usepackage{lipsum,showframe}
\usepackage{adjustbox}
\begin{document}

\lipsum[1]
\noindent
\begin{adjustbox}{center}
\begin{tabular}{ | p{3cm} | p{3cm} | p{3cm} | p{2cm} | p{2cm} | p{2cm} | }
\hline
abcdabcd abcd & abcdabcd abcd & abcdabcd abcd & abcdabcd & abcdabcd & abcdabcd \\ \hline
abcdabcd & abcdabcd & abcdabcd & abcdabcd & abcdabcd & abcdabcd \\ \hline
abcdabcd & abcdabcd & abcdabcd & abcdabcd & abcdabcd & abcdabcd \\ \hline
\end{tabular}
\end{adjustbox}

\end{document}

There are some more facilities provided by adjustbox package, which, can be found by executing texdoc adjustbox from terminal.

| improve this answer | |

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.