
我在論文中使用 minted 套件來突出顯示程式碼。我創建的命令如下所示:
\newminted[ps]{js}{frame=lines,style=manni,fontfamily=courier,linenos=true}
我這樣使用它
\begin{listing}[H]
\caption{Syntax of function declaration}
\begin{ps}
// My code is here
\end{ps}
\end{listing}
我想在鑄造的程式碼中使用下標和上標(我也將它用於偽代碼和語法規則,這就是我想要下標的原因..)
我試過這個來設置mathescape
按照此處所述進行設置lstlisting 中的下標和上標?但\lstset
給了我未定義的控制序列錯誤(我想我沒有使用列表包......?)
謝謝你的時間。
答案1
該命令\lstset
是 for listings
,這與minted
.
您可以使用escapeinside
:
\documentclass{article}
\usepackage{minted}
\newminted[ps]{js}{
frame=lines,
style=manni,
fontfamily=courier,
linenos=true,
escapeinside=@@,
}
\begin{document}
\begin{ps}
... code@$_1$@ ... code@$^2$@ ... code@$_1^2$@ ...
\end{ps}
\end{document}
相反,@@
您可以使用環境中未使用的其他角色ps
。