如何以給定的方式在 Latex 中編寫塊矩陣

如何以給定的方式在 Latex 中編寫塊矩陣

如何在 Latex 中以以下方式編寫分塊矩陣: 在此輸入影像描述

我寫了以下程式碼:

\[

Q=\left[

\begin{array}{c c c c}

\textbf{nI}& \vline & \textbf{J}\\

\hline

\textbf{J^T} &\vline &\textbf{K}

\end{array}

\right]

\]

我收到以下錯誤:

!額外 },或忘記 $.\textdef@ ...th {#1}\let \f@size #2\selectfont #3}} \textbf{J^T}

還有更多的錯誤很難放在這裡。

有人可以幫忙嗎?

答案1

|您可以在列規格中使用垂直線和 ,\hline並且只需要 2 列:

在此輸入影像描述

\documentclass{article}

\begin{document}

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

\end{document}

答案2

它不喜歡 \textbf 命令中包含上標這一事實。

\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}

答案3

我的建議包含兩個例子。顯然,您可以使用增加或減少文字字母大小的常用命令來更改矩陣內字元的大小。

在此輸入影像描述

\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}

相關內容