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.

3 Answers 3

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}
5
  • no its not working , i want to put $A,B,C,D$ in bold
    – Charlotte
    Aug 16, 2019 at 5:12
  • how to use textbf
    – Charlotte
    Aug 16, 2019 at 5:14
  • 1
    @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
    – Charlotte
    Aug 16, 2019 at 5:20
  • @Math_Freak: See Column and row padding in tables
    – Werner
    Aug 16, 2019 at 5:34
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}
2
  • Its still not working
    – Charlotte
    Aug 16, 2019 at 5:03
  • not working ,there are errors
    – Charlotte
    Aug 16, 2019 at 5:16
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}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .