每当我需要写“at”符号时,我都会使用\usepackage{marvosym}
命令( )\MVAt
@
但令人惊讶的是,它在列表环境中不起作用
例如:
\begin{lstlisting}[framexleftmargin=0mm,basicstyle=\ttfamily\small,breaklines,columns=fullflexible]
' having 1=1--
' or 1 in (select @@version)--
' union all select @@version--
' OR 'unusual' = 'unusual'
' OR 'something' = 'some'+'thing'
\end{lstlisting}
我也ttfamily\verb
有同样的问题:
\begin{ttfamily}\verb|declare @s varchar(8000) select @s = db_name() if (ascii(substring(@s,|\end{ttfamily}
这个问题有解决办法吗?
答案1
您必须告诉listings
并将\verb
改为:@
\MVAt
\documentclass{article}
\usepackage{marvosym,listings,etoolbox}
\lstset{literate={@}{\MVAt}1}
\patchcmd{\verb}{\dospecials}{\dospecials\atspecial}{}{}
\def\atspecial{\begingroup\lccode`~=`@
\lowercase{\endgroup\let~}\MVAt
\catcode`@=\active}
\begin{document}
\begin{lstlisting}[framexleftmargin=0mm,
basicstyle=\ttfamily\small,
breaklines,
columns=fullflexible]
' having 1=1--
' or 1 in (select @@version)--
' union all select @@version--
' OR 'unusual' = 'unusual'
' OR 'something' = 'some'+'thing'
\end{lstlisting}
\verb|declare @s varchar(8000)|
\end{document}
没有必要使用\ttfamily
around \verb
。