0

I'm having troubles in drawing an horizontal line inside a matrix. As from this MWE code, the line isn't well balanced relative to the equal sign (it should be aligned, vertically), and there's a pesky white hole below the middle:

\documentclass[11pt,letterpaper,twoside]{book}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
\usepackage{microtype}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{mathtools}
\usepackage{tensor}

\begin{document}

%\setlength{\abovedisplayskip}{1em} \setlength{\abovedisplayshortskip}{0pt} \setlength{\belowdisplayskip}{\abovedisplayskip} \setlength{\belowdisplayshortskip}{\belowdisplayskip} \setlength{\jot}{3ex}

\begin{equation}
    R = \left[ \begin{array}{ccc|ccc}
    \tensor{R}{_{0101}} & \tensor{R}{_{0102}} & \tensor{R}{_{0103}} & \tensor{R}{_{0123}} & \tensor{R}{_{0131}} & \tensor{R}{_{0112}} \\[2ex]
    \tensor{R}{_{0102}} & \tensor{R}{_{0202}} & \tensor{R}{_{0203}} & \tensor{R}{_{0223}} & \tensor{R}{_{0231}} & \tensor{R}{_{0212}} \\[2ex]
    \tensor{R}{_{0103}} & \tensor{R}{_{0203}} & \tensor{R}{_{0303}} & \tensor{R}{_{0323}} & \tensor{R}{_{0331}} & \tensor{R}{_{0312}}
    \\[\dimexpr 1ex+2\arrayrulewidth] \hline \\[\dimexpr 1ex-2\arrayrulewidth-\jot]
    \tensor{R}{_{0123}} & \tensor{R}{_{0223}} & \tensor{R}{_{0323}} & \tensor{R}{_{2323}} & \tensor{R}{_{2331}} & \tensor{R}{_{2312}} \\[2ex]
    \tensor{R}{_{0131}} & \tensor{R}{_{0231}} & \tensor{R}{_{0331}} & \tensor{R}{_{2331}} & \tensor{R}{_{3131}} & \tensor{R}{_{3112}} \\[2ex]
    \tensor{R}{_{0112}} & \tensor{R}{_{0212}} & \tensor{R}{_{0312}} & \tensor{R}{_{2312}} & \tensor{R}{_{3112}} & \tensor{R}{_{1212}}
\end{array} \right]\!.
\end{equation}

\end{document}

Preview:

enter image description here

So how can I modify that code so the horizontal line is well balanced vertically in the matrix, without that whiloe hole under it?

Cham
  • 2,304
  • https://tex.stackexchange.com/questions/240859/dividing-line-in-a-matrix – js bibra Jul 22 '20 at 16:37
  • @jsbibra, none of the solutions from your link give a proper result. There are still white gaps, and the line isn't well balanced. – Cham Jul 22 '20 at 16:41
  • My line is drawn from an answer found there: https://tex.stackexchange.com/questions/540022/how-to-adjust-vertical-spacing-in-a-matrix-with-an-horizontal-line?noredirect=1#comment1364288_540022 – Cham Jul 22 '20 at 16:46
  • Why do you use superfluous tensor package for the subscripts? – Sebastiano Aug 10 '20 at 11:54

2 Answers2

1

from --https://tex.stackexchange.com/questions/240859/dividing-line-in-a-matrix

enter image description here

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
\usepackage{microtype}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{mathtools}
\usepackage{booktabs}
\usepackage{tensor}
\begin{document}
    \[
    M = 
    \left( \begin{array}{c|c}
    A & B \\
    \midrule
    C & D \\
    \end{array}\right)
    \]
    \[
     R = \left[ \begin{array}{ccc|ccc}
        \tensor{R}{_{0101}} & \tensor{R}{_{0102}} & \tensor{R}{_{0103}} & \tensor{R}{_{0123}} & \tensor{R}{_{0131}} & \tensor{R}{_{0112}} \\[2ex]
        \tensor{R}{_{0102}} & \tensor{R}{_{0202}} & \tensor{R}{_{0203}} & \tensor{R}{_{0223}} & \tensor{R}{_{0231}} & \tensor{R}{_{0212}} \\[2ex]
        \tensor{R}{_{0103}} & \tensor{R}{_{0203}} & \tensor{R}{_{0303}} & \tensor{R}{_{0323}} & \tensor{R}{_{0331}} & \tensor{R}{_{0312}}
        \\ \midrule
        \tensor{R}{_{0123}} & \tensor{R}{_{0223}} & \tensor{R}{_{0323}} & \tensor{R}{_{2323}} & \tensor{R}{_{2331}} & \tensor{R}{_{2312}} \\[2ex]
        \tensor{R}{_{0131}} & \tensor{R}{_{0231}} & \tensor{R}{_{0331}} & \tensor{R}{_{2331}} & \tensor{R}{_{3131}} & \tensor{R}{_{3112}} \\[2ex]
        \tensor{R}{_{0112}} & \tensor{R}{_{0212}} & \tensor{R}{_{0312}} & \tensor{R}{_{2312}} & \tensor{R}{_{3112}} & \tensor{R}{_{1212}}
    \end{array} \right]\!.
    \]
\end{document}

edit -- with intersection no hole aligned to = sign

 R = \left[ \begin{array}{@{\,}ccc|ccc@{\,}}
        \tensor{R}{_{0101}} & \tensor{R}{_{0102}} & \tensor{R}{_{0103}} & \tensor{R}{_{0123}} & \tensor{R}{_{0131}} & \tensor{R}{_{0112}} \\
        \tensor{R}{_{0102}} & \tensor{R}{_{0202}} & \tensor{R}{_{0203}} & \tensor{R}{_{0223}} & \tensor{R}{_{0231}} & \tensor{R}{_{0212}} \\
        \tensor{R}{_{0103}} & \tensor{R}{_{0203}} & \tensor{R}{_{0303}} & \tensor{R}{_{0323}} & \tensor{R}{_{0331}} & \tensor{R}{_{0312}}
        \\ \hline
        \tensor{R}{_{0123}} & \tensor{R}{_{0223}} & \tensor{R}{_{0323}} & \tensor{R}{_{2323}} & \tensor{R}{_{2331}} & \tensor{R}{_{2312}} \\
        \tensor{R}{_{0131}} & \tensor{R}{_{0231}} & \tensor{R}{_{0331}} & \tensor{R}{_{2331}} & \tensor{R}{_{3131}} & \tensor{R}{_{3112}} \\
        \tensor{R}{_{0112}} & \tensor{R}{_{0212}} & \tensor{R}{_{0312}} & \tensor{R}{_{2312}} & \tensor{R}{_{3112}} & \tensor{R}{_{1212}}
    \end{array} \right]\!.

enter image description here

js bibra
  • 21,280
  • That line still have gaps in the middle. And the elements don't have a proper spacing around the line, compared with other elements in the matrix. – Cham Jul 22 '20 at 16:48
  • See the solution from that answer (which strangely doesn't work well here): https://tex.stackexchange.com/questions/540022/how-to-adjust-vertical-spacing-in-a-matrix-with-an-horizontal-line?noredirect=1#comment1364288_540022 – Cham Jul 22 '20 at 16:49
  • Addendum: If you need a bit of extra vertical separation between the rows, you could load the array package and issue the instruction \setlength\extrarowheight{1pt} in the preamble. This may be particularly useful if the submatrices have diacritics (such as \bar{...}) that would otherwise come too close to the \hline – js bibra Jul 22 '20 at 16:53
  • By the way: Sat Sri Akaal ! – Cham Jul 22 '20 at 16:53
  • https://tex.stackexchange.com/questions/246844/matrix-hline-is-cut-by-cmidrule – js bibra Jul 22 '20 at 16:54
1

With the latest version of nicematrix (v 5.1 of 2020-07-31), the vertical rules specified by | in the preamble of {NiceArray} (similar to {array} of array) are never broken (because they are drawn in fact by PGF/Tikz).

So, you can write directly without broken vertical rule:

\documentclass[11pt,letterpaper,twoside]{book}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[total={6in,10in},left=1.5in,top=0.5in,includehead,includefoot]{geometry}
\usepackage{amsfonts}
\usepackage{mathtools}
\usepackage{tensor}
\usepackage{nicematrix}

\begin{document}

\setlength{\abovedisplayshortskip}{0pt} \setlength{\belowdisplayskip}{\abovedisplayskip} \setlength{\belowdisplayshortskip}{\belowdisplayskip} \setlength{\jot}{3ex}

\begin{equation} R = \left[ \begin{NiceArray}{ccc|ccc} \tensor{R}{{0101}} & \tensor{R}{{0102}} & \tensor{R}{{0103}} & \tensor{R}{{0123}} & \tensor{R}{{0131}} & \tensor{R}{{0112}} \[2ex] \tensor{R}{{0102}} & \tensor{R}{{0202}} & \tensor{R}{{0203}} & \tensor{R}{{0223}} & \tensor{R}{{0231}} & \tensor{R}{{0212}} \[2ex] \tensor{R}{{0103}} & \tensor{R}{{0203}} & \tensor{R}{{0303}} & \tensor{R}{{0323}} & \tensor{R}{{0331}} & \tensor{R}{{0312}} \[\dimexpr 1ex+2\arrayrulewidth] \hline \[\dimexpr 1ex-2\arrayrulewidth-\jot] \tensor{R}{{0123}} & \tensor{R}{{0223}} & \tensor{R}{{0323}} & \tensor{R}{{2323}} & \tensor{R}{{2331}} & \tensor{R}{{2312}} \[2ex] \tensor{R}{{0131}} & \tensor{R}{{0231}} & \tensor{R}{{0331}} & \tensor{R}{{2331}} & \tensor{R}{{3131}} & \tensor{R}{{3112}} \[2ex] \tensor{R}{{0112}} & \tensor{R}{{0212}} & \tensor{R}{{0312}} & \tensor{R}{{2312}} & \tensor{R}{{3112}} & \tensor{R}{{1212}} \end{NiceArray} \right]!. \end{equation}

\end{document}

Output of the above code

F. Pantigny
  • 40,250