1

How to write a block matrix in Latex in the following way: enter image description here

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.

Charlotte
  • 963

3 Answers3

4

You can use a vertical line | within the column specification together with an \hline and only need 2 columns:

enter image description here

\documentclass{article}

\begin{document}

\[
  X = \left[\begin{array}{ c | c }
    A & B \\
    \hline
    C & D
  \end{array}\right]
\]

\end{document}
Werner
  • 603,163
1

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

\documentclass[10pt]{article}  
\begin{document}  
\begin{equation}  
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{equation}  
\end{document}
siracusa
  • 13,411
0

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.

enter image description here

\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}
Sebastiano
  • 54,118