是否有簡單的方法讓lstlisting
環境中的完整代碼加下劃線? 我目前的解決方案看起來像這樣,但我並不滿意。LaTeX列表帶下劃線
\begin{lstlisting}[mathescape]
$\ul{if(gt(x1, 0)) then} $
...
\end{lstlisting}
感謝您的任何提示。
是否有簡單的方法讓lstlisting
環境中的完整代碼加下劃線? 我目前的解決方案看起來像這樣,但我並不滿意。LaTeX列表帶下劃線
\begin{lstlisting}[mathescape]
$\ul{if(gt(x1, 0)) then} $
...
\end{lstlisting}
感謝您的任何提示。
根據5頁的用戶指南(found here):
\lstset{keywordstyle=\underbar}
那隻適用於關鍵字。但我沒有使用任何特殊的語法,所以我沒有關鍵字。我想要完整的代碼加下劃線。 我試過\ lstset {basicstyle = \ underbar},但那也不起作用。 – Masala 2010-05-02 18:55:10
如果你想強調的整條生產線(而不僅僅是關鍵字),最好的解決辦法,我能想出是做東西沿着下面的線:
\usepackage{listings}
\newcommand{\lstul}[1]{\underline{\mbox{\tt #1}}}
\begin{document}
\begin{lstlisting}[mathescape]
$\lstul{if condition}$
$\lstul{statement 1}$
$\lstul{statement 2}$
...
\end{lstlisting}
\end{document}
你的意思是你不想\下劃線上市的每一行? – aioobe 2010-05-02 18:42:09
是的,我不想在每一行上使用數學env,並分別爲每行加下劃線。 – Masala 2010-05-02 18:45:07