![使用软件包列表时的电子邮件符号](https://linux22.com/image/261923/%E4%BD%BF%E7%94%A8%E8%BD%AF%E4%BB%B6%E5%8C%85%E5%88%97%E8%A1%A8%E6%97%B6%E7%9A%84%E7%94%B5%E5%AD%90%E9%82%AE%E4%BB%B6%E7%AC%A6%E5%8F%B7.png)
每当我需要写“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
。