MathJax icon indicating copy to clipboard operation
MathJax copied to clipboard

Support for \parbox[position]{width}{text}

Open brichwin opened this issue 3 years ago • 2 comments

Is your feature request related to a problem? Please describe. Multi-line text comments in aligned equations are common in math textbooks. Typically they are generated by chunking up the text across multiple lines with blank columns; or, worse, instead of blank columns they instead have the next equation.

Either way, the line spacing in the multi-line comment ends up the same as the line spacing between each separate comment.
The resulting speech text for the comment is either interrupted with "1st Column blank 2nd Column blank...." or interlaced with math inappropriately.

Describe the solution you'd like Support LaTeX's \parbox[position]{width}{text} so the multi-line comment can render as a single text chunk.

Describe alternatives you've considered I'd be happy to learn of alternatives.

Additional context Example of using blank lines in aligned equations followed by resulting output:

\begin{align*}
\int \left( \frac{x+3}{2}\right) \, dx
=& \int \frac{1}{2}(x+3) \, dx && \text{Factoring out a constant} \\
=& \frac{1}{2} \int (x+3) \, dx && \text{Factoring the constant outside the integral} \\
=& \frac{1}{2}\left[\frac{1}{2}x^2+3x\right]+C && \text{Applying the power rule and }\\ 
 &  && \text{adding the constant of integration} \\
=& \frac{1}{4}x^2+\frac{3}{2}x+C && \text{Distributing the } \frac{1}{2} \\
=& \frac{x^2+6x}{4}+C && \text{Finding a common denominator} \\
=& \frac{x(x+6)}{4}+C && \text{Factoring out an }
\end{align*}

image

Here is an extract from the speech text generated (note how the multi-line comment is broken up):

... Applying the power rule and 4th Row 1st Column Blank 2nd Column Blank 3rd Column Blank 4th Column adding the constant of integration ...

Compare to what would be possible with \parbox (note the difference in line spacing):

\begin{align*}
\int \left( \frac{x+3}{2}\right) \, dx
=& \int \frac{1}{2}(x+3) \, dx && \text{Factoring out a constant} \\
=& \frac{1}{2} \int (x+3) \, dx && \text{Factoring the constant outside the integral} \\
=& \frac{1}{2} \left[ \frac{1}{2}x^2+3x \right]+C && \parbox{5.5cm}{Applying the power rule and 
                                                             adding the constant of integration} \\
=& \frac{1}{4}x^2+\frac{3}{2}x+C && \text{Distributing the } \frac{1}{2} \\
=& \frac{x^2+6x}{4}+C && \text{Finding a common denominator} \\
=& \frac{x(x+6)}{4}+C && \text{Factoring out an }
\end{align*}

image

Hopefully the speech text could render the text in the \parbox command as one continuous chunk of text.

brichwin avatar Aug 19 '22 21:08 brichwin

The next version of MathJax will include linebreaking, and should handle breaking of tables better. It will include more TeX macros for handling this situation, and I can add \parbox. There are already several others (like \vtop, \vcenter, and \vbox) included in the new release, along with the ability to set \hsize within these boxes.

In the meantime, you could use something like

\begin{align*}
\int \left( \frac{x+3}{2}\right) \, dx
=& \int \frac{1}{2}(x+3) \, dx && \text{Factoring out a constant} \\[5px]
=& \frac{1}{2} \int (x+3) \, dx && \text{Factoring the constant outside the integral} \\[5px]
=& \frac{1}{2} \left[ \frac{1}{2}x^2+3x \right]+C && 
\begin{array}{@{}l}
\text{Applying the power rule and}\\[-2px]
\text{adding the constant of integration}
\end{array} \\[5px]
=& \frac{1}{4}x^2+\frac{3}{2}x+C && \text{Distributing the } \frac{1}{2} \\[5px]
=& \frac{x^2+6x}{4}+C && \text{Finding a common denominator} \\[5px]
=& \frac{x(x+6)}{4}+C && \text{Factoring out an $x$}
\end{align*}

to get

$$ \begin{align*} \int \left( \frac{x+3}{2}\right) \, dx =& \int \frac{1}{2}(x+3) \, dx && \text{Factoring out a constant} \\[5px] =& \frac{1}{2} \int (x+3) \, dx && \text{Factoring the constant outside the integral} \\[5px] =& \frac{1}{2} \left[ \frac{1}{2}x^2+3x \right]+C && \begin{array}{@{}l} \text{Applying the power rule and} \\[-2px] \text{adding the constant of integration} \end{array} \\[5px] =& \frac{1}{4}x^2+\frac{3}{2}x+C && \text{Distributing the } \frac{1}{2} \\[5px] =& \frac{x^2+6x}{4}+C && \text{Finding a common denominator} \\[5px] =& \frac{x(x+6)}{4}+C && \text{Factoring out an $x$} \end{align*} $$

dpvc avatar Aug 22 '22 14:08 dpvc

Thanks for the examples!

brichwin avatar Sep 03 '22 20:09 brichwin