How can one control the inside margins (also known as padding) of a
parbox[t] in tabular, i.e. p{}? I would like to change the inside
maring on the left and right side, on the top and at the bottom,
independently.
Since I use \textcolor[gray]{1}{...} inside some of the cells, it is
not possible to change the left and right inside margin, because the
background color will stick out on both sides and have to set these
margins on the parbox itself.
Thanks,
Pander
I'm assuming you mean \columncolor. \textcolor won't affect the background.
\documentclass{article}
\usepackage{array,colortbl,lipsum}
\usepackage[svgnames]{xcolor}
\begin{document}
Stuff
\begin{tabular}{l>{\cellcolor{gray}\centering\arraybackslash}p{8cm}l}
Stuff&
\vbox to8cm{\null\vfill
\begin{minipage}{6cm}
\textcolor{red}{6cm-worth of} \lipsum[22]
\end{minipage}\par\vfill}\par
&
Stuff\\
\end{tabular}
More stuff
\end{document}
///Peter
\documentclass{article}
\usepackage{colortbl,hhline}
\begin{document}
How to independently control all four inner margins between text and
outline, without under or over shooting with background color? Below
are some very interesting effects, especially on the horizontal lines.
The desired effect is in the third tabular below, but only in the left
cell. How to fix the right cell?
\strut\\\strut\\
\begin{tabular}{|m{3cm}|c|%
m{3cm}|}\hhline{|-|~|-|}
Sic surgens, dux, zelotypos quam karus haberis.&%
~~~~~default~~~~~&%
\cellcolor[gray]{0.85}Sic surgens, dux, zelotypos quam karus haberis.\
\
\hhline{|-|~|-|}
\end{tabular}
\strut\\\strut\\
\begin{tabular}{|@{}m{3cm}@{}|c|%
@{}m{3cm}@{}|}\hhline{|-|~|-|}
Sic surgens, dux, zelotypos quam karus haberis.&%
~~~~~@\{\}~~~~~&%
\cellcolor[gray]{0.85}Sic surgens, dux, zelotypos quam karus haberis.\
\
\hhline{|-|~|-|}
\end{tabular}
\strut\\\strut\\
\begin{tabular}{|@{\hspace{.05cm}}m{3cm}@{\hspace{.05cm}}|c|%
@{\hspace{.05cm}}m{3cm}@{\hspace{.05cm}}|}\hhline{|-|~|-|}
Sic surgens, dux, zelotypos quam karus haberis.&%
~~~~~@\{\textbackslash hspace\{.05cm\}\}~~~~~&%
\cellcolor[gray]{0.85}Sic surgens, dux, zelotypos quam karus haberis.\
\
\hhline{|-|~|-|}
\end{tabular}
\strut\\\strut\\
\begin{tabular}{|@{\hspace{.5cm}}m{3cm}@{\hspace{.5cm}}|c|%
@{\hspace{.5cm}}m{3cm}@{\hspace{.5cm}}|}\hhline{|-|~|-|}
Sic surgens, dux, zelotypos quam karus haberis.&%
~~~~~@\{\textbackslash hspace\{.5cm\}\}~~~~~&%
\cellcolor[gray]{0.85}Sic surgens, dux, zelotypos quam karus haberis.\
\
\hhline{|-|~|-|}
\end{tabular}
\strut\\\strut\\
\begin{tabular}{|@{\hspace{-.05cm}}m{3cm}@{\hspace{-.05cm}}|c|%
@{\hspace{-.05cm}}m{3cm}@{\hspace{-.05cm}}|}\hhline{|-|~|-|}
Sic surgens, dux, zelotypos quam karus haberis.&%
~~~~~@\{\textbackslash hspace\{-.05cm\}\}~~~~~&%
\cellcolor[gray]{0.85}Sic surgens, dux, zelotypos quam karus haberis.\
\
\hhline{|-|~|-|}
\end{tabular}
\strut\\\strut\\
\begin{tabular}{|@{\hspace{-.5cm}}m{3cm}@{\hspace{-.5cm}}|c|%
@{\hspace{-.5cm}}m{3cm}@{\hspace{-.5cm}}|}\hhline{|-|~|-|}
Sic surgens, dux, zelotypos quam karus haberis.&%
~~~~~@\{\textbackslash hspace\{-.5cm\}\}~~~~~&%
\cellcolor[gray]{0.85}Sic surgens, dux, zelotypos quam karus haberis.\
\
\hhline{|-|~|-|}
\end{tabular}
\end{document}
The following ought to work, using the overhang parameter to
columncolor, but for some reason (a) the LH cell rule of the RH cell is
being partly occluded by the cell colour, and (b) the horizontal rules
do not start at the LH vertical rule boundary but appear to be ignoring
the cell colour LH overhang.
But I may have misunderstood something in the documentation for
colortbl...perhaps David C can spot this faster than anyone else...
\documentclass{article}
\usepackage{colortbl,hhline}
\begin{document}
\begin{tabular}{|
@{\hspace{.05cm}}m{3cm}@{\hspace{.05cm}}
|>{\quad}c<{\quad}|
@{\hspace{.05cm}}
>{\columncolor[gray]{0.85}[.05cm]\vrule height1.1em width0pt}
m{3cm}
<{\vrule depth.5ex width0pt}
@{\hspace{.05cm}}|}\hhline{|-|~|-|}
Sic surgens, dux, zelotypos quam karus haberis.&
\verb+@{\hspace{.05cm}}+&
Sic surgens, dux, zelotypos quam karus
haberis.\\\hhline{|-|~|-|}
\end{tabular}
\end{document}
> How to independently control all four inner margins between text and
> outline
So far you have only given the extra spacing on left and right. The "m"
column type centres the cell with respect to its neighbours: I don't
think it does anything about vertical centering of the cell *content*
because there is no way to specify cell height.
To add extra height above and below, the easiest way is to provide the
invisible \vrules I have used above. You need to adjust their height so
that it matches the 0.05cm used for the horizontal space.
Actually slightly less for optical adjustment, because the top line has
mostly lowercase characters, so there appears to be more white-space
present than there really is; and in the last line the implicit \strut
means that clearance for absent descenders creates the same effect.
///Peter