这就是代码在Xcode中的样子. xcode http://img94.imageshack.us/img94/972/xcode.png
这在我用texlive创建的列表中.
替代文字http://img25.imageshack.us/img25/1245/latexn.png
是的,我使用了basicstyle =\ttfamily.看过列表手册后,我还没有找到任何关于fixed-with或monospace字体的信息.
重现的例子
\documentclass[
article,
a4paper,
a4wide,
%draft,
smallheadings
]{book}
% Packages below
\usepackage{graphicx}
\usepackage{verbatim} % used to display code
\usepackage{hyperref}
\usepackage{fullpage}
\usepackage[ansinew]{inputenc} % german umlauts
\usepackage[usenames,dvipsnames]{color}
\usepackage{float}
\usepackage{subfig}
\usepackage{tikz}
\usetikzlibrary{calc,through,backgrounds}
\usepackage{fancyvrb}
\usepackage{acronym}
\usepackage{amsthm} % Uuhhh yet another package
\VerbatimFootnotes % Required, otherwise verbatim does not work in footnotes!
\usepackage{listings}
\definecolor{Brown}{cmyk}{0,0.81,1,0.60}
\definecolor{OliveGreen}{cmyk}{0.64,0,0.95,0.40}
\definecolor{CadetBlue}{cmyk}{0.62,0.57,0.23,0}
\definecolor{lightlightgray}{gray}{0.9}
\begin{document}
\lstset{
language=C, % Code langugage
basicstyle=\ttfamily, % Code font, Examples: \footnotesize, \ttfamily
keywordstyle=\color{OliveGreen}, % Keywords font ('*' = uppercase)
commentstyle=\color{gray}, % Comments font
numbers=left, % Line nums position
numberstyle=\tiny, % Line-numbers fonts
stepnumber=1, % Step between two line-numbers
numbersep=5pt, % How far are line-numbers from code
backgroundcolor=\color{lightlightgray}, % Choose background color
frame=none, % A frame around the code
tabsize=2, % Default tab size
captionpos=b, % Caption-position = bottom
breaklines=true, % Automatic line breaking?
breakatwhitespace=false, % Automatic breaks only at whitespace?
showspaces=false, % Dont make spaces visible
showtabs=false, % Dont make tabls visible
columns=flexible, % Column format
morekeywords={__global__, __device__}, % CUDA specific keywords
}
\begin{lstlisting}
As[threadRow][threadCol] = A[
threadCol + threadRow * Awidth // Adress of the thread in the current block
+ i * BLOCK_SIZE // Pick a block further left for i+1
+ blockRow * BLOCK_SIZE * Awidth // for blockRow +1 go one blockRow down
];
\end{lstlisting}
\end{document}
Run Code Online (Sandbox Code Playgroud)
Pie*_*ter 35
问题是columns=flexible选择.删除它,它看起来像你想要它看起来.至少,如果你没有实际的理由使用它.如果有的话,就没有办法让你的代码片段的等宽度在Xcode中看起来像:).
| 归档时间: |
|
| 查看次数: |
39358 次 |
| 最近记录: |