TransWikia.com

How to add extra space between the left-side legend and the left parenthesis of a matrix in the presence of a vertical line?

TeX - LaTeX Asked on May 28, 2021

I have the following example:

documentclass{article}

usepackage[english]{babel}
usepackage{booktabs}
usepackage{array}
usepackage{blkarray}

begin{document}

begin{equation}label{cexA_Rmat}
mathbf{R}=
begin{blockarray}{cccccc}
& lambda_1 & lambda_2 & lambda_3 & lambda_4 
cmidrule{2-6}
begin{block}{c|(ccccc)}
  tau_1 &           -1 & phantom{-}1 & phantom{-}0 & phantom{-}0 
  tau_2 & phantom{-}0 &           -1 & phantom{-}1 & phantom{-}0 
  tau_3 & phantom{-}0 & phantom{-}0 & phantom{-}1 &           -1 
  tau_4 &           -1 & phantom{-}0 & phantom{-}0 & phantom{-}1 
end{block}
end{blockarray}
end{equation}

end{document}

where I would like to add extra space between column $tau_i$ (i=1,2,3,4) and the left-side matrix parenthesis. As you can see in the enclosed image, there the left parenthesis and the vertical line are totally overlapped. How can I increase their distance (as well as the distance between the $tau_i$s and the vertical line)?

enter image description here

2 Answers

Insert a space within the column specification of your blockarray:

enter image description here

documentclass{article}

usepackage{booktabs}
usepackage{blkarray}

begin{document}

[
  mathbf{R} =
  begin{blockarray}{ cccccc }
    & lambda_1 & lambda_2 & lambda_3 & lambda_4 
    cmidrule{2-6}
    begin{block}{@{} c @{hspace{1ex}} | @{quad} (ccccc) }
      tau_1 &           -1 & phantom{-}1 & phantom{-}0 & phantom{-}0 
      tau_2 & phantom{-}0 &           -1 & phantom{-}1 & phantom{-}0 
      tau_3 & phantom{-}0 & phantom{-}0 & phantom{-}1 &           -1 
      tau_4 &           -1 & phantom{-}0 & phantom{-}0 & phantom{-}1 
    end{block}
  end{blockarray}
]

end{document}

Also note the removal of the inter-column space (using @{}) at the beginning of the nested block.

Correct answer by Werner on May 28, 2021

With {pNiceArray} of nicematrix.

documentclass{article}
usepackage{nicematrix,tikz}

begin{document}

[mathbf{R}=
begin{pNiceArray}{cccc}[first-col,first-row]
      & lambda_1 & lambda_2 & lambda_3 & lambda_4 
hline 
noalign{vskip2pt}
  tau_1 &           -1 & phantom{-}1 & phantom{-}0 & phantom{-}0 
  tau_2 & phantom{-}0 &           -1 & phantom{-}1 & phantom{-}0 
  tau_3 & phantom{-}0 & phantom{-}0 & phantom{-}1 &           -1 
  tau_4 &           -1 & phantom{-}0 & phantom{-}0 & phantom{-}1 
CodeAfter
tikz draw ([xshift=-2pt]1-|1) -- ([xshift=-2pt]5-|1) ;
end{pNiceArray}]

end{document}

Output of the above code

Answered by F. Pantigny on May 28, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP