I need to put a table inside another table, and would like to set the outside margins of the inner table to 0pt. How can I do this (in particular for tabularx, but hopefully this would be the same for any table environment)?
[Tex/LaTex] How to the margins around a table set to 0pt
nestingspacingtables
Related Solutions
The space above and below the listing can be set using aboveskip
and belowskip
. The default value is \medskipamount
.
\documentclass{article}
\usepackage{tikz}
\usepackage{listings}
\begin{document}
\tikz \node[inner sep=1mm, text width=6cm, draw=green, line width=2pt, rounded corners]
{%
\lstinputlisting[basicstyle=\tiny\ttfamily, columns=fullflexible, breaklines=true,aboveskip=0pt,belowskip=0pt]{data.txt}
};
\end{document}
This is one option that abuses multirow
. Generally this shouldn't be done. But for this case it works.
\documentclass[12pt]{article}
\usepackage[left=2.54cm,right=2.54cm,top=2.54cm,bottom=2.54cm]{geometry}
%\usepackage[margin=1in]{geometry} %% this is short.
\usepackage{tabularx,multirow}
\begin{document}
\begin{center}
\begin{tabularx}{\textwidth}{>{\bfseries}lX}
\hline
\multirow{2}{*}{Operating Systems} & Windows XP, Windows 7, Windows 8, Ubuntu, Debian, Fedora \\
\hline
Programming Languages & C, C++, Core Java, Core Python, Basic C\# \\
\hline
\multirow{2}{*}{Web Technologies} & HTML5, CSS3, XML, Javascript, Node.js, PHP, JSP, ASP.NET \\
\hline
Databases & Oracle 10g, MySQL 5 \\
\hline
\multirow{2}{*}{Packages} & Netbeans 8.0, Microsoft Visual Studio 2008/2010/2012, Eclipse 5 \\
\hline
Linux & Bash Shell Scripting
\end{tabularx}
\end{center}
\end{document}
This is another version without abusing anything.
\documentclass[12pt]{article}
\usepackage[left=2.54cm,right=2.54cm,top=2.54cm,bottom=2.54cm]{geometry}
%\usepackage[margin=1in]{geometry} %% this is short.
\usepackage{array,calc}
\newlength{\mylen}
\setlength{\mylen}{\widthof{\textbf{Programming Languages}}}
\newcolumntype{L}{p{\dimexpr\textwidth-\mylen-4\tabcolsep\relax}}
\newcommand{\col}[1]{% %% code stolen from egreg
\begin{tabular}{@{}>{\raggedright}L@{}}
\strut #1\strut
\end{tabular}%
}
\begin{document}
\begin{center}
\begin{tabular}{>{\bfseries}ll}
\hline
Operating Systems & \col{Windows XP, Windows 7, Windows 8, Ubuntu, Debian, Fedora} \\
\hline
Programming Languages & \col{C, C++, Core Java, Core Python, Basic C\#} \\
\hline
Web Technologies & \col{HTML5, CSS3, XML, Javascript, Node.js, PHP, JSP, ASP.NET} \\
\hline
Databases & \col{Oracle 10g, MySQL 5} \\
\hline
Packages & \col{Netbeans 8.0, Microsoft Visual Studio 2008/2010/2012, Eclipse 5} \\
\hline
Linux & \col{Bash Shell Scripting}
\end{tabular}
\end{center}
\end{document}
But, you will be better off using a list instead of tabular
.
Best Answer
If you are talking about the left and right margins of a
tabular
(be careful with the term 'table'), they can be removed using@{}
as the first and last element in the column definition:This replace the normal skip with the content inside the
{}
, which is empty in this case. This also works fortabularx
,array
etc.