2

Block matrix

I want to add a certain spacing s.t. the the partial derivative symbols don't touch the line. Here is the code I have so far.

\begin{align*}
\mathrm{D}_{}F(\textbf{x}_{0}, \textbf{y}_{0}) = 
\left[\begin{array}{c|c}
        \textbf{I} 
  & 0 \\
\hline
        \displaystyle  \frac{\partial f}{\partial \textbf{x}} (\textbf{x}_{0}, \textbf{y}_{0}) &
       \displaystyle \frac{\partial f}{\partial \textbf{y}} (\textbf{x}_{0}, \textbf{y}_{0})
  \end{array}\right]
.\end{align*}
Mico
  • 506,678
Descrates
  • 243

4 Answers4

3

I'd like to suggest that you insert a (typographic) strut in a superscript position next to one of the two \partial f expressions.

I would also replace all nine instances of \textbf with \mathbf.

enter image description here

\documentclass{article} 
\usepackage{amsmath} % for '\dfrac' macro
% Define a "tall" typographic strut with no width:
\newcommand\mystrut{{}^{\mathstrut}\kern-\scriptspace} 
\begin{document} 
\[
\mathrm{D}_{}F(\mathbf{x}_{0}, \mathbf{y}_{0}) = 
\left[\begin{array}{@{} c|c @{}}
  \mathbf{I} & 
  0 \\
  \hline
  \dfrac{\partial f\mystrut}{\partial\mathbf{x}} (\mathbf{x}_{0}, \mathbf{y}_{0}) &
  \dfrac{\partial f}{\partial\mathbf{y}} (\mathbf{x}_{0}, \mathbf{y}_{0})
\end{array}\right]
\]
\end{document}
Mico
  • 506,678
  • 1
    A superscript, even if empty, adds a \scriptspace; admittedly, it's 0.5pt, so I can see it only at 1600% magnification on my screen, but there might be situations where this leads to unexpected behaviour. But +1 anyway... – campa Dec 02 '21 at 16:48
  • @campa - Thanks for this observation. I'll happily append \kern-\scriptspace to the definition of \mystrut. :-) – Mico Dec 02 '21 at 16:53
  • 1
    thanks a lot, from now on I will use \mathbf as you recommended! – Descrates Dec 02 '21 at 16:54
3

Here is a solution with cellspace, with adds a minimal vertical spacing at the top & bottom of cells in columns with specifier prefixed with the letter S by default. I took the liberty to remove the align* environment, since nothing is aligned in this formula, and to replace \textbf with the more appropriate ``\mathbf`.

\documentclass{article}

\usepackage{amsmath} \usepackage[math]{cellspace} \setlength{\cellspacetoplimit}{3pt} \setlength{\cellspacebottomlimit}{3pt}

\begin{document}

[ \mathrm{D}{}F(\textbf{x}{0}, \textbf{y}{0}) = \left[\begin{array}{>{$ \displaystyle}Sc<{$}|>{$ \displaystyle}Sc<{$}} \textbf{I} & 0 \ \hline \frac{\partial f}{\partial \mathbf{x}} (\mathbf{x}{0}, \mathbf{y}{0}) & \frac{\partial f}{\partial \mathbf{y}} (\mathbf{x}{0}, \mathbf{y}_{0}) \end{array}\right] ]

\end{document}

enter image description here

Bernard
  • 271,350
2

Add a \\[-2ex] after \hline

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{align*}
\mathrm{D}_{}F(\textbf{x}_{0}, \textbf{y}_{0}) = 
\left[\begin{array}{c|c}
        \textbf{I} 
  & 0 \\
\hline\\[-2ex]%<--
        \displaystyle  \frac{\partial f}{\partial \textbf{x}} (\textbf{x}_{0}, \textbf{y}_{0}) & 
        \displaystyle \frac{\partial f}{\partial \textbf{y}} (\textbf{x}_{0}, \textbf{y}_{0})\\
  \end{array}\right]
.\end{align*}
\end{document}

enter image description here

Dan
  • 3,699
2

enter image description here

You need to define a command to add padding below and above its argument as follows

\newcommand{\addstackgapmath}[2][\Sstackgap]{\addstackgap[#1]{$\displaystyle #2$}}

Fot matrices containing horizontal and vertical lines, it is good practice to use bNiceArray

Off-Topic: it is better to enter bold math using \mathbf instead of \textbf

MWE

\documentclass{book}

\usepackage{amsmath}

\usepackage{nicematrix}

\usepackage{stackengine}

\newcommand{\addstackgapmath}[2][\Sstackgap]{\addstackgap[#1]{$\displaystyle #2$}}

\begin{document}

\begin{equation} \mathrm{D}{}F(\mathbf{x}{0}, \mathbf{y}{0}) = \left[\begin{array}{c|c} \mathbf{I} & 0 \ \hline \addstackgapmath{\frac{\partial f}{\partial \mathbf{x}} (\mathbf{x}{0}, \mathbf{y}{0})} & \addstackgapmath{\frac{\partial f}{\partial \mathbf{y}} (\mathbf{x}{0}, \mathbf{y}_{0})} \end{array}\right] .\end{equation}

\begin{equation} \mathrm{D}{}F(\mathbf{x}{0}, \mathbf{y}{0}) = \begin{bNiceArray}[hvlines-except-borders,margin]{c c} \mathbf{I} & 0 \ \addstackgapmath{\frac{\partial f}{\partial \mathbf{x}} (\mathbf{x}{0}, \mathbf{y}{0})} & \addstackgapmath{\frac{\partial f}{\partial \mathbf{y}} (\mathbf{x}{0}, \mathbf{y}_{0})} \end{bNiceArray}. \end{equation}

\end{document}