Katex Boxed Equations


To render a bordered box with multiple equations.


My previous article about dot products contains some boxed math expressions: some are inline and some take up the whole line.

For inline math, that’s simple: either $\fbox{text}$ or $\boxed{a=1}$ will do. For displayed math, these two KaTeX commands will ignore the newline command \\.


A simple Google search ‘“katex” AND “box”’ saved the day. It led me to this relevant Stack Overflow question, whose accepted answer suggested the use of custom CSS. I copied the CSS class name boxedmath for my blog.

/* boxed math expressions */
.boxedmath {
  border: 0.0625em solid currentcolor;
  padding: 0.5em;

I appended the above section into static/css/custom.css.


No comment

Your email address will not be published. Required fields are marked *.