# Text with upward arrow indicator in equation

I want to have text as above an equation with arrows as pointer. I get this to working but not as pretty. There is a lot of wasted space. Here is what I got

The vertical space between the lines is too much. If I try to reduce the the arrows merge in next line.

Here is how I want

\documentclass{article}
\usepackage{amsmath,amssymb,amsfonts,amsthm}
\begin{document}
\begin{equation*}
\begin{array}{ccc}
\text{partial derivative} & &\text{partial derivative} \\
\text{w.r.t } x & & \text{w.r.t } t \\
\downarrow & & \downarrow \\
\pd{f}{x} & & \pd{f}{t}
\end{array}
\end{equation*}

\end{document}

• You can add a negative space after the \\  before the down arrows: \$-6pt] – barbara beeton Jun 29 '19 at 15:23 • @barbarabeeton Thanks It worked. Although I am looking for doing this entirely differently – Kumarm Jun 29 '19 at 15:38 ## 3 Answers With tikz-cd: \documentclass[11pt,a4paper]{report} \usepackage{amsmath} \usepackage{tikz-cd} \begin{document} \[ \begin{tikzcd}[row sep=2em] \begin{array}{c} \text{word or phrase} \\ \text{word or phrase} \end{array} \arrow[d] & \text{word or phrase} \arrow[d] \\ \dfrac{\partial f}{\partial x} & \dfrac{\partial f}{\partial t} \end{tikzcd}$
\end{document}


Edit: another two options, changing the aligment of the arrays.

\documentclass[11pt,a4paper]{report}
\usepackage{amsmath}
\usepackage{tikz-cd}

\begin{document}
$\begin{tikzcd}[row sep=2em] \begin{array}[t]{c} % <--- [t] \text{word or phrase} \\ \text{word or phrase} \end{array} \arrow[d] & \text{word or phrase} \arrow[d] \\ \dfrac{\partial f}{\partial x} & \dfrac{\partial f}{\partial t} \end{tikzcd}$

\medskip

$\begin{tikzcd}[row sep=2em] \begin{array}[b]{c} % <--- [b] \text{word or phrase} \\ \text{word or phrase} \end{array} \arrow[d] & \text{word or phrase} \arrow[d] \\ \dfrac{\partial f}{\partial x} & \dfrac{\partial f}{\partial t} \end{tikzcd}$
\end{document}

• Thanks.. How can I add multiline word or phrase? – Kumarm Jun 29 '19 at 15:36
• @Kumarm, see edited. – Sigur Jun 29 '19 at 15:39

A simple solution with stackengine:

\documentclass{article}
\usepackage{amsmath, amssymb, amsthm}
\newcommand{\pd}[2]{\dfrac{\partial#1}{\partial#2}}
\usepackage[usestackEOL]{stackengine}

\begin{document}

’Twas brillig, and the slithy toves did gyre and gimble in the wabe; all mimsy were the borogoves, and the mome raths outgrabe.

\begin{equation*}
\stackMath \Shortstack{\text{partial derivative} \\ \text{w.r.t }x\\\downarrow \\\\\pd{f}{x}} \qquad
\Shortstack{\text{partial derivative} \\ \text{w.r.t }t\\\downarrow\\\\\pd{f}{t}}
\end{equation*}

\end{document}


You could with a little creativity create a lot of codes for what you ask for. I suggest these two, one of which uses a beautiful macro of the best user @egreg that you can see in this link: How to elongate down arrow?. This type of macro is useful to increase the length of the vertical arrow.

## First proposal using xy package

\documentclass[a4paper,12pt]{article}
\usepackage[all]{xy}
\usepackage{amsmath,amssymb}
\usepackage{newtxtext,newtxmath}
\begin{document}
\xymatrix@R=3pc@C=3pc{
*\txt{partial derivative\\w.r.t\,\textit{x}} \ar[d]  & *\txt{partial derivative\\w.r.t\,\textit{t}} \ar[d] \\
\dfrac{\partial f}{\partial x}  & \dfrac{\partial f}{\partial t}}
\end{document}


## Second proposal using some packages

\documentclass[a4paper,12pt]{article}
\usepackage[all]{xy}
\usepackage{amsmath,amssymb}
\usepackage{relsize}
\usepackage{newtxtext,newtxmath}
\newcommand{\xdownarrow}[1]{%
{\left\downarrow\vbox to #1{}\right.\kern-\nulldelimiterspace}
}

\begin{document}

$\underset{\mkern70mu\text{and}\mkern10mu\dfrac{\partial f}{\partial x}+ \dfrac{\partial f}{\partial t}\mathlarger{=3x+2y}}{\underset{\begin{matrix} \xdownarrow{.5cm}&\xdownarrow{.5cm}\end{matrix}}{\substack{\text{an ODE can contain more}\\ \text{than one dependent variable}}}}$

\end{document}


After newtxtext and newtxmath are clones of mathematical and textual fonts from Times New Roman.