Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm trying to add a little bit of space before and after the \hline in this matrix:

\documentclass[a4paper,journal]{IEEEtran}
\usepackage[cmex10]{amsmath}
\interdisplaylinepenalty=2500


\usepackage{array}
\begin{document}
\begin{multline}
    \boldsymbol{J^{-1}} = \\   \left[ \begin{array}{ccc|ccc}
    \frac{\partial \delta_2}{\partial P_2} & \hdots & \frac{\partial \delta_n}{\partial P_2} &
    \frac{\partial \delta_2}{\partial Q_2} & \hdots & \frac{\partial \delta_n}{\partial Q_2} \\
    \vdots & \boldsymbol{J_{11}^\prime} & \vdots & \vdots & \boldsymbol{J_{21}^\prime} & \vdots \\
    \frac{\partial \delta_2}{\partial P_n} & \hdots & \frac{\partial \delta_n}{\partial P_n} &
    \frac{\partial \delta_2}{\partial Q_n} & \hdots & \frac{\partial \delta_n}{\partial Q_n} \\
    \hline
    \frac{1}{|V_2|}\frac{\partial |V_2|}{\partial P_2} & \hdots & \frac{1}{|V_n|}\frac{\partial |V_n|}{\partial P_2} &
    \frac{1}{|V_2|}\frac{\partial |V_2|}{\partial Q_2} & \hdots & \frac{1}{|V_n|}\frac{\partial |V_n|}{\partial Q_2} \\
     \vdots & \boldsymbol{J_{12}^\prime} & \vdots& \vdots & \boldsymbol{J_{22}^\prime} & \vdots \\
    \frac{1}{|V_2|}\frac{\partial |V_2|}{\partial P_n} & \hdots & \frac{1}{|V_n|}\frac{\partial |V_n|}{\partial P_n} &
     \frac{1}{|V_2|}\frac{\partial |V_2|}{\partial Q_n} & \hdots & \frac{1}{|V_n|}\frac{\partial |V_n|}{\partial Q_n} \\ 
    \end{array} \right]
    \\\label{eq:Jinv}
\end{multline}
\end{document}

Output:

Before

At the moment, I've done this:

... \\[0.5em]
\hline
&&&&&\\[-0.8em]
...

Which works:

Hack

but is a bit messy. Is there a cleaner way to do this?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

You could define a couple of new commands. I'm not sure whether this is better than your own solution, but it is an alternative approach.

The two of the new commands are \bottomstrut and \topstrut. The third command combines these two with a new line and an hline for your multiline environment. The following two are examples:

\documentclass[a4paper,journal]{IEEEtran}
\usepackage[cmex10]{amsmath}
\interdisplaylinepenalty=2500

\newcommand{\bottomstrut}[1]{\rule[-#1]{0pt}{#1}}
\newcommand{\topstrut}[1]{\rule{0pt}{#1}}
\newcommand{\dividerline}[2]{\bottomstrut{#1}\\\hline\topstrut{#2}}


\usepackage{array}
\begin{document}

Example with \verb=\bottomstrut{2ex}\\\hline\topstrut{3ex}=

\begin{multline}
    \boldsymbol{J^{-1}} = \\   \left[ \begin{array}{ccc|ccc}
    \frac{\partial \delta_2}{\partial P_2} & \hdots & \frac{\partial \delta_n}{\partial P_2} &
    \frac{\partial \delta_2}{\partial Q_2} & \hdots & \frac{\partial \delta_n}{\partial Q_2} \\
    \vdots & \boldsymbol{J_{11}^\prime} & \vdots & \vdots & \boldsymbol{J_{21}^\prime} & \vdots \\
    \frac{\partial \delta_2}{\partial P_n} & \hdots & \frac{\partial \delta_n}{\partial P_n} &
    \frac{\partial \delta_2}{\partial Q_n} & \hdots & \frac{\partial \delta_n}{\partial Q_n} 
    \bottomstrut{2ex}\\\hline\topstrut{3ex}
    \frac{1}{|V_2|}\frac{\partial |V_2|}{\partial P_2} & \hdots & \frac{1}{|V_n|}\frac{\partial |V_n|}{\partial P_2} &
    \frac{1}{|V_2|}\frac{\partial |V_2|}{\partial Q_2} & \hdots & \frac{1}{|V_n|}\frac{\partial |V_n|}{\partial Q_2} \\
     \vdots & \boldsymbol{J_{12}^\prime} & \vdots& \vdots & \boldsymbol{J_{22}^\prime} & \vdots \\
    \frac{1}{|V_2|}\frac{\partial |V_2|}{\partial P_n} & \hdots & \frac{1}{|V_n|}\frac{\partial |V_n|}{\partial P_n} &
     \frac{1}{|V_2|}\frac{\partial |V_2|}{\partial Q_n} & \hdots & \frac{1}{|V_n|}\frac{\partial |V_n|}{\partial Q_n} \\ 
    \end{array} \right]
    \\\label{eq:Jinv:1}
\end{multline}

Example with \verb=\dividerline{2ex}{3ex}=

\begin{multline}
    \boldsymbol{J^{-1}} = \\   \left[ \begin{array}{ccc|ccc}
    \frac{\partial \delta_2}{\partial P_2} & \hdots & \frac{\partial \delta_n}{\partial P_2} &
    \frac{\partial \delta_2}{\partial Q_2} & \hdots & \frac{\partial \delta_n}{\partial Q_2} \\
    \vdots & \boldsymbol{J_{11}^\prime} & \vdots & \vdots & \boldsymbol{J_{21}^\prime} & \vdots \\
    \frac{\partial \delta_2}{\partial P_n} & \hdots & \frac{\partial \delta_n}{\partial P_n} &
    \frac{\partial \delta_2}{\partial Q_n} & \hdots & \frac{\partial \delta_n}{\partial Q_n} 
    \dividerline{2ex}{3ex}
    \frac{1}{|V_2|}\frac{\partial |V_2|}{\partial P_2} & \hdots & \frac{1}{|V_n|}\frac{\partial |V_n|}{\partial P_2} &
    \frac{1}{|V_2|}\frac{\partial |V_2|}{\partial Q_2} & \hdots & \frac{1}{|V_n|}\frac{\partial |V_n|}{\partial Q_2} \\
     \vdots & \boldsymbol{J_{12}^\prime} & \vdots& \vdots & \boldsymbol{J_{22}^\prime} & \vdots \\
    \frac{1}{|V_2|}\frac{\partial |V_2|}{\partial P_n} & \hdots & \frac{1}{|V_n|}\frac{\partial |V_n|}{\partial P_n} &
     \frac{1}{|V_2|}\frac{\partial |V_2|}{\partial Q_n} & \hdots & \frac{1}{|V_n|}\frac{\partial |V_n|}{\partial Q_n} \\ 
    \end{array} \right]
    \\\label{eq:Jinv:2}
\end{multline}
\end{document}

enter image description here

share|improve this answer
    
Thanks. I'd read about "struts" but didn't know how to use them, or that they worked in this situation. –  Fabian Tamp Nov 28 '12 at 2:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.