I have another problem and hope you can help.
I want to set a padding/spacing in my table, but only on the right side of the cells. When I set the \setlength{\tabcolsep}{5pt}%
, the padding is also on both sides.
So, my question, is there any way to set the padding only on one side of the cells?
Here is an example for what I have now, and you can see, that the spacing from the name to the next cell is very small.
\documentclass[10pt,a4paper]{article}
\usepackage[ngerman]{babel}
\usepackage[paper=a4paper,left=20mm,right=20mm,top=15mm,bottom=15mm]{geometry}
\setlength{\parindent}{0pt}
\begin{document}
{\huge Information} \hfill \today \\
\begin{figure}[h]
\sffamily
\begin{minipage}[t]{13cm}
\renewcommand{\arraystretch}{1.4}
\setlength{\tabcolsep}{0pt}%
\begin{tabular}{p{2.5cm}p{4cm}p{2.5cm}p{4cm}}
\textbf{Personalnr.:} &101 &\textbf{Gesch.-St.:} &1 \\
\textbf{Nachname:} &BrahamanenSiddhartha123 &\textbf{Kost.-St.: } &900 \\
\textbf{Vorname:} &Chandrakanta Umashankar &\textbf{Geschlecht:} &männlich \\
\end{tabular}
\end{minipage}
\hfill
\begin{minipage}[t]{3cm}
\vspace{8pt}
%\includegraphics[height=5cm]{personalbild.png}
\end{minipage}
\end{figure}
\end{document}
Best Answer
Each
tabular
column has a space left and right to the real cell content -- the width of this is normally specified with\tabcolsep
, which defaults to6pt
. Together with the cell content those spacings form up the full cell.It's possible to erase this space completely using the
@{}
specifier:For example: (see the images too, please)
\begin{tabular}{llll}
would have8
\tabcolsep
spaces (left and right ofl
)\begin{tabular}{@{}l@{}@{}l@{}@{}l@{}@{}l@{}
would have no such spaces, it's tight. The@{}
right to the specifierl
belongs to that one, not to next specifier!However
@{}
can be used to set another skip, say@{\hskip5pt}
for another spacing.If vertical lines come into action, the width of the table is increased by
\arrayrulewidth
for each vertical line. (I've omitted the lines in the images above -- the shown borders are just for better impression and should not represent the potential vertical lines of the table)I've done this and explicitly introduced vertical lines, just to show the effect, not for a real run!
In addition, I removed the
minipage
and added\usepackage[utf8]{inputenc}
(for the cell vertical spacing\usepackage{cellspace}
might be usefull, but I omitted it)Any further comments on the design of the table → O.P!