2

How can I set the margins around all tabulars to zero by default?

The margins around a single tabular can be removed using @{}, see below, but I have dozens of tables and would like to have a single switch for all of them.

\begin{tabular}{@{}ll@{}}

Source: How can the margins around a table set to 0pt?

  • @PhelypeOleinik unfortunately not, that removes the space between columns in the table. – Konrad Höffner Jan 16 '18 at 11:08
  • 4
    One way would be to define your own environment which adds the @{}. \newenvironment{mytabular}[1]{\tabular{@{}#1@{}}}{\endtabular}. By renaming tabular to e.g. origtabular first (\let\origtabular\tabular \let\endorigtabular\endtabular) you can even patch the environment and keeping the orginal name. – Martin Scharrer Jan 16 '18 at 11:13
3

Just for fun. This trims off the edge using a \makebox. The \fbox is just to show the actual dimensions.

\documentclass{standalone}

\let\oldtabular=\tabular
\let\oldendtabular=\endtabular
\def\tabular{\bgroup\sbox0\bgroup\oldtabular}
\def\endtabular{\oldendtabular\egroup
  \makebox[\dimexpr\wd0-2\tabcolsep][c]{\usebox0}%
\egroup}

\begin{document}
\fboxsep=0pt
\fbox{\begin{tabular}{lr}
  this&is\\
  why&I\\
  hate&making\\
  My&own MWE
\end{tabular}}
\end{document}

demo

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.