How to write a block matrix in Latex in the given way

How to write a block matrix in Latex in the following way:

I wrote the following code:

$Q=\left[ \begin{array}{c c c c} \textbf{nI}& \vline & \textbf{J}\\ \hline \textbf{J^T} &\vline &\textbf{K} \end{array} \right]$


I am getting the following error:

! Extra }, or forgotten $.\textdef@ ...th {#1}\let \f@size #2\selectfont #3}} \textbf{J^T} and many more errors which are difficult to put here. Can someone kindly help. 3 Answers You can use a vertical line | within the column specification together with an \hline and only need 2 columns: \documentclass{article} \begin{document} $X = \left[\begin{array}{ c | c } A & B \\ \hline C & D \end{array}\right]$ \end{document}  • no its not working , i want to put$A,B,C,D\$ in bold Aug 16, 2019 at 5:12
• how to use textbf Aug 16, 2019 at 5:14
• @Math_Freak: Use \mathbf{A}.
– Werner
Aug 16, 2019 at 5:15
• The output looks very clumsy ,there is no space in the entries of the block marix Aug 16, 2019 at 5:20
• @Math_Freak: See Column and row padding in tables
– Werner
Aug 16, 2019 at 5:34

It doesn't like the fact that you had the superscript inside the \textbf command.

\documentclass[10pt]{article}
\begin{document}
$$Q=\left[ \begin{array}{c c c c} \textbf{nI}& \vline & \textbf{J}\\ \hline \textbf{J}^\textbf{T} &\vline &\textbf{K} \end{array} \right]$$
\end{document}

• Its still not working Aug 16, 2019 at 5:03
• not working ,there are errors Aug 16, 2019 at 5:16

My proposal contains two examples. Obviously you can change the size of the characters inside the matrix using the usual commands that increase or decrease the size of a letter of text.

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

$\renewcommand\arraystretch{1.5} \left[\begin{array}{@{}c|c@{}} \mbox{\Large A} & \mbox{\Large B} \\ \hline \mbox{\Large C} & \mbox{\Large D} \end{array}\right], \quad \left[\begin{array}{@{}c|c@{}} \mbox{\Large A} & \mbox{\Large B} \\ \hline \mbox{\Large C} & \mbox{\Large D} \end{array}\right]$

\end{document}