2
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{makeidx}
\usepackage{graphicx}
   
\begin{document}
    \begin{center}
        \[
        P=\left[
        \begin{array}{cccc|cccccccccccc}
        1      & 1 & \dots    &1            & 1 & 1&  \dots       & 1 \\
        1      &   &                      &                       &   &             &   \\
        \vdots &   &        \textbf{\Huge{C}}               & &&&  \textbf{\Huge{0}}  &    \\
        1      &   &                      &                       &   &             &   \\
        \cline{2-8}
        1      &   &                      &                       &   &             &   \\
        \cdots &   &     \textbf{\Huge{0}}     &                       &   &&\textbf{\Huge{D}} \\
        1      &   &                      &                       &   &             &
        \end{array}
        \right]
        \]
    \end{center}
\end{document}

I have written the following code. The problem I am facing is I want the line to appear after the first row. Please find the picture attached of the matrix I want to have. How do I remove the line from the first row? Please help

enter image description here

I would be happy and grateful if it be done by just doing some manipulations to my given code. I want to do it without using any packages

1

By adapting the code of the OP:

\documentclass{article}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
   
\begin{document}
\begin{center}
    \[
    P= 
    \left[
    \begin{matrix}
    1      & 1 & \dots                & 1 & 1                     & 1 & \dots             & 1  \\
    1      &   &                      &   & \multicolumn{1}{c|}{}  &                       &    \\
    \vdots &   & \textbf{\Huge{C}}    &   & \multicolumn{1}{c|}{}  &   & \textbf{\Huge{0}} &    \\
    1      &   &                      &   & \multicolumn{1}{c|}{}  &   &                        \\
    \cline{2-8}
    1      &   &                      &   & \multicolumn{1}{c|}{}  &   &                        \\
    \vdots &   & \textbf{\Huge{0}}    &   & \multicolumn{1}{c|}{}  &   &\textbf{\Huge{D}}       \\
    1      &   &                      &   & \multicolumn{1}{c|}{}  &   &
    \end{matrix} \;
    \right]
    \]
\end{center}
\end{document}

Result of the above code

| improve this answer | |
  • The display structure \[ ... \] automatically centers the display, so there's no need for \begin{center} ... \end{enter}. Otherwise, very effective. – barbara beeton Jun 11 at 1:03
  • Yes perfect!! Thank you very much!! You are awesome Panti!! – Math_Freak Jun 11 at 3:15
  • Hi, can you give, please, tex.stackexchange.com/questions/554659/… an answer using nicematrix package into this question? Thank you very much. – Sebastiano Jul 24 at 11:59
2

A proposition with nicematrix:

\documentclass{article}
\usepackage{nicematrix}
\usepackage{tikz}
   
\begin{document}

$\begin{pNiceArray}{ccccr}[columns-width=4mm,right-margin,nullify-dots]
1       & \Cdots & &                        & 1 \\
\Vdots  & \Block{2-2}<\Large>{C} & & \Block{2-2}<\Large>{0} &   \\
\\
  & \Block{2-2}<\Large>{0} & & \Block{2-2}<\Large>{D} &   \\
1 
\CodeAfter
\tikz \draw (row-4-|col-2) -- (row-4-|col-6) 
            (row-2-|col-4) -- (row-6-|col-4) ;   
\end{pNiceArray}$


\end{document}

Result of the above code

| improve this answer | |
  • can you give any way to do it without nicematrix – Math_Freak Jun 10 at 16:35
  • can't it be done by just doing some manipulations to my given code, i want to do it without using complicated packages – Math_Freak Jun 10 at 16:37
1

With array and some nesting:

\documentclass{article}
\usepackage{amsmath,array}

\newcommand{\bigentry}[2][\huge]{\begin{tabular}{@{}c@{}}#1$#2$\end{tabular}}

\begin{document}

\[
\newcommand{\ones}{\begin{matrix} 1 \\[-1ex] \vdots \\ 1 \end{matrix}}
\left[\begin{array}{ c @{} c | c @{} }
\noalign{\vspace{0.5ex}}
\begin{matrix} 1 \end{matrix} &
\multicolumn{1}{c@{}}{\begin{matrix} 1 & \dots & 1 \end{matrix}} &
\begin{matrix} 1 & \dots & 1 \end{matrix} \\
\ones & \bigentry{\mathbf{C}} & \bigentry{\mathbf{0}} \\
\cline{2-3}
\ones & \bigentry{\mathbf{0}} & \bigentry{\mathbf{D}} \\
\noalign{\vspace{0.5ex}}
\end{array}\right]
\]

\end{document}

enter image description here

We need a couple of tricks because of \vdots not being really suitable for the purpose, so some vertical space has to be added at the top and the bottom.

Avoid \textbf for math objects in formulas, it should be \mathbf.

The nested tabular for \bigentry ensures vertical centering and can accommodate a size changing command, which would otherwise be illegal in math mode.

The command \ones is just a local shorthand for reducing code clutter.

| improve this answer | |
  • Okay I will keep mathbf in mind, thanks a lot for suggesting – Math_Freak Jun 10 at 16:44
  • But can you do it without using any package and without using newcommand – Math_Freak Jun 10 at 16:44
  • @Math_Freak array is not essential; why would you do without amsmath? – egreg Jun 10 at 16:45
  • Since i dont understand use of #@,is it possible to get rid of this \newcommand{\bigentry}[2][\huge]{\begin{tabular}{@{}c@{}}#1$#2$\end{tabular}} and do it? – Math_Freak Jun 10 at 16:46
  • @Math_Freak If your aim is to use it in MathJax, please tell it so, but in this case the question would be closed as off-topic. And no, I don't know how to make it work in MathJax and don't bother. – egreg Jun 10 at 16:47
0

Like this? I use nicematrix package to redraw the matrix, the key point is first-row option.

\documentclass{article}
\usepackage{nicematrix}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}

\begin{document}
\[
p=\left[
\begin{NiceArray}{*4{C}|*3{C}}[first-row, extra-margin=2mm]
  1 & 1 & \Cdots & 1 & 1 & \Cdots & 1 \\
  1 & \Block{3-3}<\Huge>{\mathbf{C}} & & & \Block{3-3}<\Huge>{\mathbf{0}} & & \\
  \Vdots & & & & & & \\
  1 & & & & & & \\
\cline{2-7}
  1 & \Block{3-3}<\Huge>{\mathbf{0}} & & & \Block{3-3}<\Huge>{\mathbf{D}} & & \\
  \Vdots & & & & & & \\
  1 & & & & & & \\
\end{NiceArray}\right]
\]
\end{document}

enter image description here

| improve this answer | |
  • Thanks but the dots are going through 1 in 1st row – Math_Freak Jun 10 at 16:42
  • @Math_Freak answer changed – ZhiyuanLck Jun 10 at 16:45
  • can u please do it without \newcommand{\Hugeeq}[1]{\text{\Huge $\mathbf{#1}$}}, i dont understand use of #1 – Math_Freak Jun 10 at 16:49
  • @Math_Freak it is just a format command, if you don't like it, replace the command with what you want to display. – ZhiyuanLck Jun 10 at 17:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.