列表:点后间距

列表:点后间距

在此处输入图片描述

特克斯代码

\lstset
{
    basicstyle          =\footnotesize,
    numbers             =left,
    language            =Java,
    commentstyle        =\textit{ \color{gray}},
    keywordstyle        =\color{blue},
    identifierstyle     =\texttt{ \color{black}},
    breaklines          =true,
    frame               =tlrb,
    frameround          =rrrr,
    tabsize             =2%
}

\begin{lstlisting}[language=scala, columns=fullflexible,caption=Source code]  % Start your code-block
import akka.actor.Actor
import akka.actor.Props
import akka.event.Logging

class Actor extends Actor {
  val log = Logging(context.system, this)

  def receive = {
    case "test" => log.info("received test")
    case _      => log.info("received unknown message")
  }
}
\end{lstlisting}

简单问题:如何删除点之间的空格,例如:

import akka. actor. Props

应该

import akka.actor.Props

答案1

您必须使用声明,而不是\textit\texttt

\documentclass{article}
\usepackage{listings,xcolor}

\lstset
{
    basicstyle          =\footnotesize,
    numbers             =left,
    language            =Java,
    commentstyle        =\itshape\color{gray},
    keywordstyle        =\color{blue},
    identifierstyle     =\ttfamily\color{black},
    breaklines          =true,
    frame               =tlrb,
    frameround          =rrrr,
    tabsize             =2
}

\begin{document}

\begin{lstlisting}[language=scala, columns=fullflexible,caption=Source code]
import akka.actor.Actor
import akka.actor.Props
import akka.event.Logging // a comment

class Actor extends Actor {
  val log = Logging(context.system, this)

  def receive = {
    case "test" => log.info("received test")
    case _      => log.info("received unknown message")
  }
}
\end{lstlisting}

\end{document}

在此处输入图片描述

相关内容