6

I am trying to use Google Colab with LaTex to make a matrix with column and row labels. Outside of Colab, the code that I would need is

\documentclass[12pt]{report}
\usepackage{blkarray}
\usepackage{amsmath}

\begin{document}

[ \begin{blockarray}{cccccc} a & b & c & d & e \ \begin{block}{(ccccc)c} 1 & 1 & 1 & 1 & 1 & f \ 0 & 1 & 0 & 0 & 1 & g \ 0 & 0 & 1 & 0 & 1 & h \ 0 & 0 & 0 & 1 & 1 & i \ 0 & 0 & 0 & 0 & 1 & j \ \end{block} \end{blockarray} ]

\end{document}

5 by 5 matrix with columns labeled a-e, and rows labeled f-j1

as was posted by user Gonzalo Medina here. The Issue I am facing is importing the required packages to run this, as Google Colab will not run this as is when wrapped by either $'s or $$'s. How does one use \usepackage inside on Google Colab?

  • 2
    I fear that's a question for Google, not for us... – campa Feb 24 '21 at 17:15
  • 3
    I think that Google Colab uses MathJaX so if you can figure out how to do it from MathJaX's syntax you might make some progress. But MathJaX questions are off-topic here as it doesn't use TeX underneath but just simulates some of the LaTeX math input. – Andrew Stacey Feb 24 '21 at 17:48
  • Realistically, Google is unlikely to reply (or provide support for a free product), but perhaps this TeX community has a solution, which will attract more readers to this good question/post. Solutions and workarounds are welcome. – Oleg Melnikov Nov 13 '21 at 21:03

1 Answers1

2

For matrices specifically, this is what you do in Google Colab. You don't even need to \usepackage for this.

$$\begin{matrix}a & b\\ c & d\end{matrix}$$ $$\begin{bmatrix}a & b\\ c & d\end{bmatrix}$$ $$\begin{pmatrix}a & b\\ c & d\end{pmatrix}$$

This is what each of those look like, in order, depending on the style of brackets. This is a screenshot in Google Colab.

Matrices

If it's not included by default, then you can still get it. You don't want to use \usepackage{something}. Rather, you want to use something that works with MathJax specifically that goes along the lines of \require{something}.

For example, I was trying to use actuarial notation on Google Colab. What eventually worked for me, making things much more aesthetically pleasing, was \require{enclose}. This allowed me to then use \enclose{actuarial}{somethingelse}. I'm mainly saying this here because it took me a while to finally figure this out.