Latex:使用单空格字体的列表
这就是代码在Xcode中的外观。 这是我用texlive创建的列表 是的,我使用了basicstyle=\ttfamily。看过清单手册后,我还没有找到任何关于fixed with或monospace字体的内容 复制示例Latex:使用单空格字体的列表,latex,Latex,这就是代码在Xcode中的外观。 这是我用texlive创建的列表 是的,我使用了basicstyle=\ttfamily。看过清单手册后,我还没有找到任何关于fixed with或monospace字体的内容 复制示例 \documentclass[ article, a4paper, a4wide, %draft, smallheadings ]{book} % Packages below \usepackage{graphicx} \usepackage{ve
\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}
当您删除
\usepackage{microtype}
时会发生什么?它会干扰紧排等操作,可能是问题的原因,我认为这是由于对齐不良。问题在于columns=flexible
选项。移除它,它看起来就像您希望它看起来一样。至少,如果你没有实际的理由使用它。如果有的话,就没有办法让代码片段的单空间性在Xcode中看起来像:)。这不是很明显吗?我希望它使用单空间字体,这样它看起来就像Xcode(使用单空间字体)。这不应该是问题,microtype手册在第9章:提示和注意事项中指出,它与fancyvrb
和清单
配合得很好。当他展示一个lstset
时,我想他使用了以下代码的列表:)。那么这可能是制表符与空格的问题吗?缩进行上的前导空格似乎确实是问题所在。文本的其余部分似乎是所需的单一空间。这些是空格还是制表符?文本只是空格,没有使用制表符。我检查了两次。。而滴加微型则没有效果。但是感谢thx到目前为止的帮助。你能提供一个简单的工作示例吗?也就是说,只有你的清单
环境和复制错误代码所需的包。嘿,尼尔斯,我认为你的代码很棒,我甚至用Fortran 90编写了它。你介意我用它写论文吗请记住使用basicstyle=\ttfamily
,否则columns=fixed
不起作用。(我的案例)使用basicstyle=\ttfamily
时,只要使用keepspaces=true
选项,就可以保留columns=flexible
。这将提供一个更“拥挤”的外观。类似于逐字记录。