minted icon indicating copy to clipboard operation
minted copied to clipboard

`\begin{pmatrix}...\end{pmatrix}` not working as expected inside comments

Open subhophy opened this issue 4 years ago • 2 comments

Consider the following piece of code.

\documentclass[12pt,twoside,a4paper]{scrartcl}
\usepackage[margin=.8in,footskip=0.25in]{geometry}
\usepackage{fontspec}
\usepackage{amsmath}
\usepackage{minted} 
\usepackage{xcolor}
\begin{document}

\title{test}
\maketitle
 \pagecolor{gray!10}

\begin{minted}[linenos=true,numberblanklines=false,obeytabs=true,breaklines=true,style=manni
,mathescape=true,framesep=.8cm]{c}

// this is fine $f=g$

// matrix rendering issue $det=ae-bd$ of the matrix $A = \begin{pmatrix} a & b \\ c & d \end{pmatrix}$

\end{minted}
\end{document}

The output when rendered using lualatex looks like this

Screen Shot 2022-01-07 at 3 06 31 PM

It looks like the & is not being recognized as a LateX command.

Any way to get around this?

subhophy avatar Jan 07 '22 23:01 subhophy

This might be a pygments issue https://github.com/pygments/pygments/issues/1988, and I gave a proof-of-concept workaround in https://tex.stackexchange.com/a/625741.

muzimuzhi avatar Jan 07 '22 23:01 muzimuzhi

I gave a proof-of-concept workaround in https://tex.stackexchange.com/a/625741.

The workaround provided in that TeX-SX answer is updated to be (hopefully) more robust.

muzimuzhi avatar Sep 27 '23 23:09 muzimuzhi