0

The following is a snippet from a jupyter-notebooks' markdown cell.

$$
\begin{aligned}
\mathrm{d}J & = \mathrm{tr}(\frac{\mathrm{d}J}{\mathrm{d}\mathbf{A}^{[3]}} \frac{\mathrm{d}\mathbf{A}^{[3]}}{\mathrm{d}\mathbf{Z}^{[3]}} \mathrm{d}\mathbf{Z}^{[3]})\\
&\begin{aligned}
& \text{Here, $\frac{\mathrm{d}\mathbf{A}^{[3]}}{\mathrm{d}\mathbf{Z}^{[3]}}$ should be a rank-4 tensor. But, the derivatives corresponding to a single training-example, i.e. $\frac{\mathrm{d}\mathbf{A}^{[3](i)}}{\mathrm{d}\mathbf{Z}^{[3](i)}}$, is a rank-2 tensor (more specifically, a 2D diagnonal-matrix), computed as follows: } \\
\frac{\mathrm{d}\mathbf{A}^{[3](i)}}{\mathrm{d}\mathbf{Z}^{[3](i)}} & = 
\biggl[\frac{\partial}{\partial{z}^{[3](i)}_1}, \frac{\partial}{\partial{z}^{[3](i)}_2}, \dots, \frac{\partial}{\partial{z}^{[3](i)}_{n^{[3]}}}\biggr]\otimes
\begin{bmatrix}
{a}^{[3](i)}_1\\
{a}^{[3](i)}_2\\
\vdots\\
{a}^{[3](i)}_{n^{[3]}}\\
\end{bmatrix} \\
& = \begin{bmatrix}
\frac{\partial {a}^{[3](i)}_1}{\partial{z}^{[3](i)}_1} & 0 & \dots & 0\\
0 & \frac{\partial {a}^{[3](i)}_2}{\partial{z}^{[3](i)}_2} & \dots & 0\\
\vdots & \vdots & \ddots & \vdots \\
0 & 0 & \dots & \frac{\partial {a}^{[3](i)}_{n^{[3]}}}{\partial{z}^{[3](i)}_{n^{[3]}}}\\
\end{bmatrix}
\end{aligned}
\end{aligned}
$$

Which renders as follows: latex-rendering

How do I make the text inside the \text{} to wrap?

PS: There are other posts (see below) that ask the same question. However, the solutions they offer (like using \parbox, \minipage, \intertext, etc.) are not working within Jupyter-notebook's markdown cell (which uses MathJax - see here).

11
  • Please provide the full code so that it be easier for others to start immediately testing for your solution.
    – topu
    Dec 7, 2021 at 16:20
  • @mmr - The complete code is too-big (around 200 lines); So, I have updated the code snippet in this post - which can be copied into a jupyter-notebooks' markdown cell to reproduce the issue.
    – x.projekt
    Dec 7, 2021 at 16:45
  • Why are you using nested align* environments? That shouldn't be legal. What exactly are you hoping to achieve with this construction? Dec 7, 2021 at 16:46
  • 1
    In any case: while MathJax may be forgiving, for the inner environment you should use aligned and not align*. (For that matter, the outer one too, since you are wrapping in $$...$$.) Dec 7, 2021 at 16:59
  • 1
    Well, the alternative is to [add your own custom CSS style]( stackoverflow.com/questions/32156248/…). Define a new block element div.myindent with left indent margin-left: 30px; and do <div class="myindent">text </div> in your markdown cell. Dec 7, 2021 at 18:37

0

Your Answer

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

Browse other questions tagged or ask your own question.