由于某种原因,morekeywords 不将=>
、<=
和check-sat
作为以下示例中的关键字。是否有解决方法或更合适的方法来做到这一点?
\documentclass[a4paper,12pt]{article}
\usepackage{listings}
\lstset
{
numbers =left,
numberstyle =\color{gray},
keywordstyle =\bfseries,
morekeywords ={
forall, exists,
assert, check-sat,
=>, <=,
and, or
},
breaklines =true,
frame =tlrb
}
\begin{document}
\begin{lstlisting}
(assert(
forall ((x Int) (y Int) (z Int) (t Int))
(=>
(and
(<= 0 (+ y z))
(<= (+ y z) 1))
(=>
(= 1 (+ x t y z))
(=>
(distinct 0 (+ y z))
(= 0 (+ x t)))))
))
(check-sat)
\end{lstlisting}
\end{document}
答案1
添加\usepackage{listingsutf8}
和
\usepackage{lmodern}
并将符号添加为字母alsoletters
似乎有效
\documentclass[a4paper,12pt]{article}
\usepackage{listings}
\usepackage{listingsutf8}
\usepackage{lmodern}
\lstset
{
numbers =left,
numberstyle =\color{gray},
alsoletter ={<=, =>, +, -, =},
morekeywords ={
forall,exists,
assert,check-sat,distinct,
=>, <=, =, +,
and,or},
keywordstyle =\bfseries\boldmath,
breaklines =true,
frame =tlrb
}
\begin{document}
\begin{lstlisting}
(assert(
forall ((x Int) (y Int) (z Int) (t Int))
(=>
(and
(<= 0 (+ y z))
(<= (+ y z) 1))
(=>
(= 1 (+ x t y z))
(=>
(distinct 0 (+ y z))
(= 0 (+ x t)))))
))
(check-sat)
\end{lstlisting}
\end{document}