3

When = is used, the content of \multirow command is adjusted to automatically be equal to the column in which \multirow appears. But this does not seem to be the case with me. I am trying to use array environment to build detailed matrices with columns and rows separators for illustration purposes. I get the following output

enter image description here

I got the output by adjusting the width of \multirow manually. If I adjust it to be =, the output stretches beyond margins

enter image description here

My source code

\documentclass[11pt, a4paper]{book}

\usepackage{amsmath}
\usepackage{amssymb, amsfonts}

\usepackage{makecell}
\usepackage{multirow}


\newlength{\arraycolsepdefaultl}
\setlength{\arraycolsepdefaultl}{2.12mm}
\newcommand{\arraycolsepdefault}{ \setlength{\arraycolsep}{\arraycolsepdefaultl} }
\arraycolsepdefault

\newcommand {\arraystretchdefaultl} {1.3}
\newcommand{\arraystretchdefault}{ \renewcommand {\arraystretch} {\arraystretchdefaultl} }
\arraystretchdefault


\usepackage{bm}

\begin{document}

\begin{equation}
\setlength{\arraycolsep}{1.06mm}
\left[
    \begin{array}{c}
        V_{1}
        \\
        \vdots
        \\
        V_{k}
        \\
        \vdots
        \\
        V_{p}
        \\
        \vdots
        \\ \Xhline{0.25mm}
        0
    \end{array}
\right]
%
=
%
\renewcommand{\arraystretch}{1.7}
\left[
    \begin{array}{c >{\medspace}c !{\vrule width 0.25mm}>{\medspace}c}
        \multirow{5}{=}{\centering \LARGE $\bm{Z}_{orig}$} & &  \multirow{5}{=}{\centering $col. \thinspace k - col. \thinspace p$} 
        \\
        & &
        \\
        & &
        \\
        & &
        \\
        & &
        \\
        \Xhline{0.25mm}
        row. \thinspace k - row. \thinspace p & & Z_{th, \thinspace kp} + Z_{b}
    \end{array}
\right]
\arraystretchdefault
\left[
    \begin{array}{c}
        I_{1}
        \\
        \vdots
        \\
        I_{k}
        \\
        \vdots
        \\
        I_{p}
        \\
        \vdots
        \\
        \Xhline{0.25mm}
        I_{q}
    \end{array}
\right]
\arraycolsepdefault
\end{equation}

\end{document}
  • You are changing \arraystretch in the middle of your set of array constructions, and that affects how the number of rows for \multirow{<rows>} is interpreted. Why do you need to change it? – Werner Jul 20 '18 at 23:57
  • No, I am changing it before array environment is initiated. I change the array stretch so that elements are vertically separated and become more readable. – Al-Motasem Aldaoudeyeh Jul 20 '18 at 23:59
3

The following example avoids multirow but instead uses \vphantoms to ensure that the matrix constructs match each other (vertically). The centred element is raise 1/2 a baseline to put it in the middle of the line (since there are an even number of rows above the \Xhline).

enter image description here

\documentclass{article}

\usepackage{bm,makecell,amsmath}

\begin{document}

\[
  \renewcommand{\arraystretch}{1.3}
  \left[\begin{array}{ c }
    V_1    \\
    \vdots \\
    V_k    \\
    \vdots \\
    V_p    \\
    \vdots \\
    \Xhline{0.25mm}
    0
  \end{array}\right]
  =
  \left[\begin{array}{ c !{\vrule width 0.25mm} c }
    \vphantom{V_1} & \\
    \vphantom{\vdots} & \\
    \vphantom{V_k} & \\
    \vphantom{\vdots}\raisebox{.5\normalbaselineskip}[0pt][0pt]{$\bm{Z}_{\text{orig}}$} & 
      \raisebox{.5\normalbaselineskip}[0pt][0pt]{\text{col.\ k - col.\ p}} \\
    \vphantom{V_p} & \\
    \vphantom{\vdots} \\
    \Xhline{0.25mm}
    \text{row.\ k - row.\ p} & Z_{\text{th, kp}} + Z_b
  \end{array}\right]
  \left[\begin{array}{ c }
      I_1    \\
      \vdots \\
      I_k    \\
      \vdots \\
      I_p    \\
      \vdots \\
      \Xhline{0.25mm}
      I_q
  \end{array}\right]
\]

\end{document}
| improve this answer | |
  • That is a desired result since the column widths are determined automatically depending on the contents. The use of \vphantom over and over again seems to be redundant. I wonder if someone can create a package to automatically force brackets surrounding array environment equal – Al-Motasem Aldaoudeyeh Jul 21 '18 at 2:09
  • You can use bmatrix from amsmath. The horizontal spacing will have to be adjusted. – Werner Jul 21 '18 at 2:13
  • will bmatrix provide the ability to customize the matrix similarly to what we get with array environment? – Al-Motasem Aldaoudeyeh Jul 21 '18 at 2:30
  • bmatrix will provide the ability to bracket a matrix without the column specifications. – Werner Jul 21 '18 at 2:38
1
  • \multirow{5}{=}{...} consider used column width
  • since in your case it is not defined in advance (as at columns as are p{<width>}), it for it consider \linewidth, consequently result which you obtained
  • a cure: use \multirow{5}{*}{...} instead:

    \documentclass[11pt, a4paper]{book}
    
    \usepackage{amsmath}
    \usepackage{amssymb}
    
    \usepackage{makecell}
    \usepackage{multirow}
    
    \newlength{\arraycolsepdefaultl}
    \setlength{\arraycolsepdefaultl}{2.12mm}
    \newcommand{\arraycolsepdefault}{ \setlength{\arraycolsep}{\arraycolsepdefaultl} }
    \arraycolsepdefault
    
    \newcommand {\arraystretchdefaultl} {1.3}
    \newcommand{\arraystretchdefault}{ \renewcommand {\arraystretch} {\arraystretchdefaultl} }
    
    \usepackage{bm}
    
    \begin{document}
        \begin{equation}
    \setlength{\arraycolsep}{1.06mm}
    \arraystretchdefault
    \left[
        \begin{array}{c}
            V_{1}   \\
            \vdots  \\
            V_{k}   \\
            \vdots  \\
            V_{p}   \\
            \vdots  \\
        \Xhline{0.25mm}
            0\rule{0pt}{3.5ex}
        \end{array}
    \right]
    =
    \renewcommand{\arraystretch}{1.7}
    \left[
        \begin{array}{c >{\medspace}c !{\vrule width 0.25mm}>{\medspace}c}
            \multirow{5}{*}{\centering \LARGE $\bm{Z}_{orig}$}
                &   &   \multirow{5}{*}{$\text{col. } k - \text{col. } p$} \\
                &   &   \\
                &   &   \\
                &   &   \\
                &   &   \\
            \Xhline{0.25mm}
            $\text{col. } k - \text{col. } p$
                &   &   Z_{th,\, kp} + Z_{b}
        \end{array}
    \right]
    \arraystretchdefault
    \left[
        \begin{array}{c}
            I_{1}   \\
            \vdots  \\
            I_{k}   \\
            \vdots  \\
            I_{p}   \\
            \vdots  \\
            \Xhline{0.25mm}
            I_{q}\rule{0pt}{3.5ex}
        \end{array}
    \right]
        \end{equation}
    \end{document}
    

which fives:

enter image description here

however, approach showed in Werner answer is common in similar cases.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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