Table padding in LyX

You may want to change the value of \tabcolsep, a length variable that equals (half) the width of the whitespace that separates columns. You use the command \setlength to change the value of this length variable. The default value of this variable is 6pt (if the main text's font size is 10pt); a value of 3pt will give you a rather tightly-set group of columns.

Separately, you may also want to consider eliminating the vertical rules between columns entirely. When one has a lot of columns, the vertical rules tend to take up a lot of space while not adding appreciably to the table's readability.

The following code and the associated image illustrate the effects that reducing the value of \tabcolsep from 6pt to 4, 3, and 2pt has. In all cases, I've eliminated all vertical rules.

\documentclass{article}
\usepackage{booktabs} % for well-spaced horizontal rules
\newcommand{\quicktabular}{%  this construct will be used several times
\begin{tabular}{*{10}{c}}
\toprule
A & B & C & D & E & F & G & H & I & J \\
A & B & C & D & E & F & G & H & I & J \\
\bottomrule
\end{tabular}}
\begin{document}
\begin{itemize}
\item Default value of \texttt{\textbackslash tabcolsep} (6pt)

 \quicktabular

\item \texttt{\textbackslash tabcolsep} = 4pt
 \setlength\tabcolsep{4pt}

 \quicktabular

\item \texttt{\textbackslash tabcolsep} = 3pt
 \setlength\tabcolsep{3pt}

 \quicktabular

\item \texttt{\textbackslash tabcolsep} = 2pt
 \setlength\tabcolsep{2pt}

 \quicktabular

\end{itemize}
\end{document}

enter image description here


Insert before the table with Ctrl-L for "Evil Red Text" and write \begingroup\tabcolsep=0pt\def\arraystretch{0}. After the table do the same, hit CTRL-L and write \endgroup. Then you do not have any space left and right of your entry


I don't know how to place code in LyX, but the following should do what you want.

\documentclass{article}

\usepackage{array}
\newlength{\mystrutht}
\newcommand{\mystrut}{\rule{0pt}{\mystrutht}\rule[-1pt]{0pt}{1pt}}
\newcolumntype{C}{>{\hbox to 1em\bgroup\mystrut\hfil}c<{\hfil\egroup}}
\newenvironment{zerotabular}
  {\settoheight{\mystrutht}{A}\addtolength{\mystrutht}{1pt}%
   \setlength{\tabcolsep}{0pt}%
   \renewcommand{\arraystretch}{0}%
   \begin{tabular}}
  {\end{tabular}}

\begin{document}
\begin{zerotabular}{|C|C|C|C|}
\hline
A&A&C&G\\
\hline
C&A&A&C\\
\hline
A&C&A&A\\
\hline
\end{zerotabular}
\end{document}

The first part (between the \documentclass and \begin{document} lines) should go in the preamble code.

Each cell is typeset in a box as wide as to accommodate a capital M; interline spacing is suppressed and substituted by a hand made strut that's 1pt higher and deeper than a capital letter.

enter image description here