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

x.projekt
  • 101
  • 3
  • Please provide the full code so that it be easier for others to start immediately testing for your solution. – mmr Dec 07 '21 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 07 '21 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? – Willie Wong Dec 07 '21 at 16:46
  • @WillieWong - It seems to be working. I wanted to create a different alignment for a small sub-section of the code. (I have update the code snippet further) – x.projekt Dec 07 '21 at 16:49
  • Don't do that. Markdown by design does not allow you to indent running text. Trying to kludge your way to force text layout is not the way to go. If you just need one layer of indentation, put it as a blockquote. – Willie Wong Dec 07 '21 at 16:54
  • @WillieWong - Are blockquotes created using \begin{quote} ... \end{quote} ? – x.projekt Dec 07 '21 at 16:58
  • 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 $$...$$.) – Willie Wong Dec 07 '21 at 16:59
  • Markdown block quotes are lines that start with >. – Willie Wong Dec 07 '21 at 17:00
  • @WillieWong - Oh, the markdown blockquote! But using > will also adds a special background effect, which I don't want. – x.projekt Dec 07 '21 at 17:02
  • 1
    Well, the alternative is to add your own custom CSS style. Define a new block element div.myindent with left indent margin-left: 30px; and do <div class="myindent">text </div> in your markdown cell. – Willie Wong Dec 07 '21 at 18:37
  • @WillieWong - Yeah, embedding HTML into the markdown along with LaTeX might work, but it would make the whole thing (in-terms of formatting) too brittle. Anyway, MathJax is proving to be too limited for my needs, and I was thinking of using separate .tex files for the purpose. – x.projekt Dec 07 '21 at 19:11

0 Answers0