\documentclass[]{article}
\usepackage{amsmath,graphicx,supertabular,hyperref,tabularx,ifthen}
\title{TIP \#21: Asymmetric Padding in the Pack and Grid Geometry Managers}
\date{January 14, 2001}
\author{D. Richard Hipp}
\urlstyle{sf}
\setlength{\parskip}{1ex}
\setlength{\parindent}{0pt}
\def\tipversion$#1${\texttt{\$#1\$}}
\def\tiplangle#1{\ensuremath{<}}
\def\tiprangle#1{\ensuremath{>}}
\def\tipbar#1{\ensuremath{|}}
\def\tipmail#1#2{\(\langle\){\small\expandafter\url{#1@#2}}\(\rangle\)}
\ifx\pdfoutput\undefined
\newcommand{\tipimage}[2]{\typeout{Make sure you download #1.eps}\ifthenelse{\lengthtest{0.8\textwidth>#2}\and\lengthtest{0pt<#2}}{\includegraphics{#1.eps}}{\includegraphics[width=0.8\textwidth]{#1.eps}}}
\newcommand{\tipxref}[1]{}
\newcommand{\tipxrefend}{}
\else
\newcommand{\tipimage}[2]{\typeout{Make sure you create #1.pdf}\ifthenelse{\lengthtest{0.8\textwidth>#2}\and\lengthtest{0pt<#2}}{\includegraphics{#1.pdf}}{\includegraphics[width=0.8\textwidth]{#1.pdf}}}
\pdfcatalog{/PageMode /UseOutlines}
\newcommand{\tipxref}[1]{\pdfannotlink attr {/C [0.5 0.5 1.0] /Border [0 0 1]} goto name {#1}}
\newcommand{\tipxrefend}{\pdfendlink}
\fi
\newenvironment{tipabstract}{\begin{abstract}}{\end{abstract}}
\begin{document}\maketitle
\begin{center}\begin{tabularx}{\linewidth}{|r@{: }X|}\hline
\textbf{TIP \#21}&\textbf{Asymmetric Padding in the Pack and Grid Geometry Managers}\\\hline
Author&

D. Richard Hipp \tipmail{drh}{hwaci.com}
\\
Created&Sunday, \(\text{14}^{\text{th}}\) January 2001\\
Type&Project\\
Tcl Version&\(8.4\)\\
State&Final\\
Vote&Done\\
Version&\tipversion$Revision: 1.6 $\\
Post History&\\
\hline\end{tabularx}\end{center}
\thispagestyle{empty}\pagestyle{empty}
\begin{tipabstract}

Proposes modifying the \textit{pack} and \textit{grid} geometry managers to support asymmetric padding.
\end{tipabstract}
\tableofcontents\setcounter{page}{0}\clearpage\pagestyle{plain}

\section{Rationale}

The \textit{pack} and \textit{grid} geometry managers allow for adding extra space to the left and right of a widget using the -padx option, and above and below the widget using -pady. But there is currently no way to add different amounts of space on opposite sides of the widget. When a layout requires differing amounts of space on opposite sides of the same widget, the usual solution is to introduce extra \textit{frame} widgets to act as spacers. But that both complicates the code unnecessarily and obscures the intent of the programmer.

\section{Proposed Enhancement}

This TIP proposes to modify the -padx and -pady of both the \textit{pack} and \textit{grid} geometry managers as follows: If the argument to -padx or -pady is a screen distance, that distance is added to both sides of the widget. (This is the current behavior.) If the argument is a list of two screen distances, then the first screen distance is the extra space to add to the left or top and the second screen distance is the extra space to add to the right or bottom.

The changes to -padx and -pady occur in \textit{pack} only if the pack geometry manager is used according to the new syntax. The older deprecated syntax (that dates from Tk3.3) will not support asymmetric padding.

\section{Copyright}

This document has been placed in the public domain.

\section{Patch}

Patches to implement asymmetric padding in the pack and grid geometry managers, as described above, are available at \url{http://www.hwaci.com/sw/asym_pad_patch_2.txt}

\section{Colophon}

\textit{TIP AutoGenerator --- written by Donal K. Fellows}
\end{document}
