Row spacing in kbordermatrix

I want to create a matrix with row and column lables (outide matrix delimiters). After a lot of googling, I have found that TeX macro kbordermatrix is best suited for this purpose. Here is my code

\kbordermatrix{    & g_1           & g_2           & g_3           & \cdots & g_k     \cr
g_1    & 1             & IV_{12}       & IV_{13}       & \cdots & IV_{1k} \cr
g_2    & ^1/_{IV_{12}} & 1             & IV_{12}       & \cdots & IV_{2k} \cr
g_3    & ^1/_{IV_{13}} & ^1/_{IV_{23}} & 1             & \cdots & IV_{3k} \cr
\vdots & \vdots        & \vdots        & \vdots        & \ddots & \vdots  \cr
g_k    & ^1/_{IV_{1k}} & ^1/_{IV_{2k}} & ^1/_{IV_{33}} & \cdots & 1 }


As you can notice there are fractions in the matrix. Now I want to use regular fractions \dfrac instead of superscript-subscript notation. But using full sized fractions will almost merge rows. Thats why I need to increase row spacing.

So, how it be done? TIA

-

Package kbordermatrix (doc) supports \arraystretch that can increase all rows. Alternatively an invisible rule can be added to increase the line heights of individual lines.

The example below shows first the matrix with equally stretched lines via \arraystretch. Then, instead of an invisible rule, it uses macro \kdfrac instead of \dfrac that measures the height and depth of the fraction and adds a space above and below. The space can be configured via length \kdsep. This way the second matrix only stretches the lines with the fractions.

\documentclass{article}
\usepackage{amsmath}
\usepackage{kbordermatrix}
\begin{document}

\begingroup
\renewcommand*{\arraystretch}{2}%
\kbordermatrix{
& g_1           & g_2           & g_3           & \cdots & g_k     \cr
g_1    & 1             & IV_{12}       & IV_{13}       & \cdots & IV_{1k} \cr
g_2    & \dfrac{1}{IV_{12}} & 1             & IV_{12}       & \cdots & IV_{2k} \cr
g_3    & \dfrac{1}{IV_{13}} & \dfrac{1}{IV_{23}} & 1             & \cdots & IV_{3k} \cr
\vdots & \vdots        & \vdots        & \vdots        & \ddots & \vdots  \cr
g_k    & \dfrac{1}{IV_{1k}} & \dfrac{1}{IV_{2k}} & \dfrac{1}{IV_{33}} & \cdots & 1
}%
\endgroup

\bigskip

\makeatletter
\newlength{\kdsep}
\setlength{\kdsep}{.5ex}
\newcommand*{\kdfrac}[2]{%
\begingroup
\sbox0{$\m@th\displaystyle\frac{#1}{#2}$}%
\ht0=\dimexpr\ht0 + \kdsep\relax
\dp0=\dimexpr\dp0 + \kdsep\relax
\box0 %
\endgroup
}
\makeatother
\kbordermatrix{
& g_1           & g_2           & g_3           & \cdots & g_k     \cr
g_1    & 1             & IV_{12}       & IV_{13}       & \cdots & IV_{1k} \cr
g_2    & \kdfrac{1}{IV_{12}} & 1             & IV_{12}       & \cdots & IV_{2k} \cr
g_3    & \kdfrac{1}{IV_{13}} & \kdfrac{1}{IV_{23}} & 1             & \cdots & IV_{3k} \cr
\vdots & \vdots        & \vdots        & \vdots        & \ddots & \vdots  \cr
g_k    & \kdfrac{1}{IV_{1k}} & \kdfrac{1}{IV_{2k}} & \kdfrac{1}{IV_{33}} & \cdots & 1
}%
\end{document}


-
Thanks you so much for such a detailed response. I'll opt for the 1st solution because it is easier :) –  Ammar Sep 11 '12 at 16:20