【问题标题】:Listings adds whitespaces, how to remove it?列表添加空格,如何删除它?
【发布时间】:2010-11-25 09:23:38
【问题描述】:

大家好, 在我的 PDF 中使用列表显示代码时,它会在某些字符后添加空格。 This is how it looks in the pdf(由于名誉问题,我不允许发布图片,因此请在网址中添加“.png”,抱歉)。

我正在使用以下代码添加列表。

\newcommand{\lstchange}[2]{
  \lstset{breaklines=true,
  frame=single,
  captionpos=b,
  basicstyle={\ttfamily\footnotesize},
  showspaces=false,
  showstringspaces=false,
  showtabs=false,
  numberstyle={\ttfamily\footnotesize},
  keywordstyle={\bfseries\color{blue}},
  stringstyle=\color{darkorange}\ttfamily,
  commentstyle=\color{OliveGreen},
  language=#1,
  morekeywords={#2} }
}

% ...

\lstchange{bash}{svn , cd, gnome-open}
\begin{lstlisting}[caption=someCaption, label=someLabel]
#!/bin/bash

svn checkout http://opendecisionrepository.googlecode.com/svn/trunk/sources/web-interface/src/main/webapp odr-appetizer-2 -r 621

cd odr-appetizer-2

#open drawing.xhtml
gnome-open drawing.xhtml
\end{lstlisting}

你们中有人知道为什么会发生这种情况吗?即使我使用latex wikibook 中的标准示例,也会发生这种情况。

也许这对你也很重要,配置文件:

\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage[left=2.5cm, right=2.5cm, top=2.5cm, bottom=3cm, a4paper]{geometry}
\usepackage[pdftex]{graphics}
\usepackage{fancyhdr}


\usepackage{%
  array,
  booktabs,
  dcolumn,
  rotating,
  shortvrb,
  tabularx,
  units,
  url,
  xcolor,
  lastpage,
  longtable,
  lscape,
  multirow,
  amssymb,
  amsmath,
  float,
  chngpage,
  colortbl,
  helvet,
  listings
}

提前致谢!

干杯,

【问题讨论】:

  • 您可以在TeX StackExchange 站点上找到整个社区,这里没有任何与TeX 相关的问题太小。

标签: latex whitespace listings


【解决方案1】:

无法在此处重现(使用\documentclass{article}),它看起来不错。我只需要注释掉“OliveGreen”,因为它是未知的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-05-26
    • 2016-05-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多