MathJax icon indicating copy to clipboard operation
MathJax copied to clipboard

bordermatrix in MathJaX

Open DayuanJiang opened this issue 6 years ago • 8 comments

It would be nice to have the option to use bordermatrix in MathJaX. Like below.

img @ #

DayuanJiang avatar Jul 16 '18 14:07 DayuanJiang

Cf. #1127

pkra avatar Jul 16 '18 14:07 pkra

@DayuanJiang, I ended up just nesting a whole bunch of matrices:

$$\begin{matrix}
 & \begin{matrix}A&C&G&T\end{matrix} \\\\
\begin{matrix}A\\\\C\\\\G\\\\T\end{matrix} & 
  \begin{pmatrix}1&2&3&4\\\\3&4&5&6\\\\3&4&5&6\\\\3&4&5&6\end{pmatrix}\\\\
\end{matrix}$$

which yields: bordermatrix

It's not perfect but hopefully close enough..

ArtPoon avatar Feb 08 '19 01:02 ArtPoon

@ArtPoon Too many backslashes hahaha
Anyway, thanks for the solution.

DayuanJiang avatar Feb 08 '19 10:02 DayuanJiang

@DayuanJiang, you may already know this but the extra backslashes are a workaround for displaying MathJax in HTML (see http://docs.mathjax.org/en/latest/tex.html#tex-and-latex-in-html-documents).

ArtPoon avatar Feb 08 '19 15:02 ArtPoon

extra backslashes are a workaround for displaying MathJax in HTML

I'm guessing you mean markdown (though some markdown processors have specialized TeX handling and do not require escaping).

For HTML, you'd primarily need to escape &, <, >.

pkra avatar Feb 08 '19 16:02 pkra

Yes I'm using revealJS with Markdown. I was going to elaborate but then figured it was too much info :)

ArtPoon avatar Feb 08 '19 16:02 ArtPoon

As a reference I have this macro:

        bordermatrix: ['\\newcommand\\bordermatrix[3]{ \\begin{matrix} & \\begin{matrix}#1\\end{matrix} \\\\ \\begin{matrix}#2\\end{matrix} \\hspace{-1em} & #3 \\end{matrix}}', 3]

Usage \bordermatrix{top labels}{left labels}{content}:

\bordermatrix{A&C&G&T}{A\\C\\G\\T}{
  \begin{pmatrix}1&2&3&4\\3&4&5&6\\3&4&5&6\\3&4&5&6\end{pmatrix}
}

mauriciopoppe avatar Mar 15 '20 23:03 mauriciopoppe

This is the best for me:

\begin{matrix}
& \\
K_1 = \cfrac{EI_b}{L^3_b} \cdot
    \left ( \vphantom{ \begin{matrix} 12 \\ 12 \\ 12 \\ 12 \end{matrix} } \right .
\end{matrix}
\hspace{-1.2em}
\begin{matrix}
    y_1 & \theta_1 & y_2 & \theta_2 \\ \hline
    12 & 6b & -12 & 6b \\
    6b & 4b^2 & -6b & 2b^2 \\
    -12 & -6b^2 & 12 & -6b \\
    6b & 2b^2 & -6b & 4b^2
\end{matrix}
\hspace{-0.2em}
\begin{matrix}
& \\
\left . \vphantom{ \begin{matrix} 12 \\ 12 \\ 12 \\ 12 \end{matrix} } \right )
    \begin{matrix}
    y_1 \\ \theta_1 \\ y_2 \\ \theta_2
    \end{matrix}
\end{matrix}

Result: image

sindzicat avatar Apr 21 '20 20:04 sindzicat