# jupyter-notebook - Wrap text inside align-environment

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


Which renders as follows: 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).

• 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. 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
• 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
• 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