I need to create a code for the following matrix:
Can you help me to do that?
This seems to quite faithfully reproduce the image (apart from the dots that are centered, but I prefer them low, in this case). I also have improved the output by adding \,
after the square roots.
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\[
\renewcommand{\arraystretch}{1.5} % give some more room
d\varphi_{t}^{\vec{v}}=
\left(\begin{array}{@{}c|c@{}}
h_{ij}+ta_{ij} &
\begin{matrix}
\sqrt{1+t^2}\,h_{n+1\,1} \\
\vdots \\
\sqrt{1+t^2}\,h_{n+1\,n}
\end{matrix}
\\ \hline
\begin{matrix}
h_{n+1\,1}+tv_{1} & \dots & h_{n+1\,n}+tv_{n}
\end{matrix}
& \sqrt{1+t^2}\,h_{n+1\,n+1}
\end{array}\right)
\]
\end{document}
cases
environment does the same.
A slightly simplified egreg nice solution (without nested matrix
):
\documentclass[border=3mm,varwidth]{standalone}
\begin{document}
\[\renewcommand{\arraystretch}{1.5}
\mathrm{d}\phi_t^{\vec{v}}
= \left(\begin{array}{c|c}
& \sqrt{1+t^2} h_{n+1\;1} \\
h_{ij} + t_{a_{ij}} & \vdots \\
& \sqrt{1+t^2} h_{n+1\;n} \\
\hline
h_{n\;11}+ tv_1 \quad\dots\quad h_{n+1\;n}+ tv_n
& \sqrt{1+t^2} h_{n+1\;n+1}
\end{array}\right)
\]
\end{document}
Edit: I increase (horizontal) space around dots that it is more evident that in this row as well as in rows above are $n$ matix cells. This improved matrix layout was inspired by Gustavo Mezzetti comments.
Regardin oprator d
: many people write it on the same way as variables (in italic shape), but also there are many of us, which dor differenciate consider upright shape, which is used for other operators like \sin
, \cos
etc.
To easier distinguish squere roots from other part of math expresion several people insert small space betwee, others use symbol as we learn in elementary school:
For this solution in preqamble of above MWE is added:
\usepackage{letltxmacro}
\makeatletter
\let\oldr@@t\r@@t
\def\r@@t#1#2{%
\setbox0=\hbox{$\oldr@@t#1{#2\,}$}\dimen0=\ht0
\advance\dimen0-0.2\ht0
\setbox2=\hbox{\vrule height\ht0 depth -\dimen0}%
{\box0\lower0.4pt\box2}}
\LetLtxMacro{\oldsqrt}{\sqrt}
\renewcommand*{\sqrt}[2][\ ]{\oldsqrt[#1]{#2}}
\makeatother
\mathrm{d}
… ;-)
t
i mistype q
... (now corrected) this should not be the problem to change (anyway, OP didn't provide anything from code). if OP don't like correct typing of operators, he can omit \mathrm
and type d\phi_t^{\vec{v}}
.
q
, but IMHO there should be some space around the dots. In other words, I think that @egreg’s idea of using submatrices should not be dropped. I repeat, this is just my humble opinion. (And please, do not take the \mathrm{d}
thing personally… ;-)
\dots
. Thank to your comments I increase it now (see edited answer). And indeed, the looks of matrix is now better. Thank you very much.
With {pNiceArray}
of nicematrix
.
\documentclass[border=3mm,varwidth]{standalone}
\usepackage{nicematrix}
\begin{document}
\[\renewcommand{\arraystretch}{1.5}
\mathrm{d} \phi_t^{\vec{v}} =
\begin{pNiceArray}{ccc|c}[margin=1pt]
\Block{3-3}{h_{ij} + t_{a_{ij}}} &&& \sqrt{1+t^2} h_{n+1\;1} \\
&&& \vdots \\
&&& \sqrt{1+t^2} h_{n+1\;n} \\
\hline
h_{n\;11}+ tv_1 & \dots & h_{n+1\;n}+ tv_n & \sqrt{1+t^2} h_{n+1\;n+1}
\end{pNiceArray}
\]
\end{document}