Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Latex:使用单空格字体的列表_Latex - Fatal编程技术网

Latex:使用单空格字体的列表

Latex:使用单空格字体的列表,latex,Latex,这就是代码在Xcode中的外观。 这是我用texlive创建的列表 是的,我使用了basicstyle=\ttfamily。看过清单手册后,我还没有找到任何关于fixed with或monospace字体的内容 复制示例 \documentclass[ article, a4paper, a4wide, %draft, smallheadings ]{book} % Packages below \usepackage{graphicx} \usepackage{ve

这就是代码在Xcode中的外观。

这是我用texlive创建的列表

是的,我使用了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}

当您删除
\usepackage{microtype}
时会发生什么?它会干扰紧排等操作,可能是问题的原因,我认为这是由于对齐不良。

问题在于
columns=flexible
选项。移除它,它看起来就像您希望它看起来一样。至少,如果你没有实际的理由使用它。如果有的话,就没有办法让代码片段的单空间性在Xcode中看起来像:)。

这不是很明显吗?我希望它使用单空间字体,这样它看起来就像Xcode(使用单空间字体)。这不应该是问题,microtype手册在第9章:提示和注意事项中指出,它与
fancyvrb
清单
配合得很好。当他展示一个
lstset
时,我想他使用了以下代码的列表:)。那么这可能是制表符与空格的问题吗?缩进行上的前导空格似乎确实是问题所在。文本的其余部分似乎是所需的单一空间。这些是空格还是制表符?文本只是空格,没有使用制表符。我检查了两次。。而滴加微型则没有效果。但是感谢thx到目前为止的帮助。你能提供一个简单的工作示例吗?也就是说,只有你的
清单
环境和复制错误代码所需的包。嘿,尼尔斯,我认为你的代码很棒,我甚至用Fortran 90编写了它。你介意我用它写论文吗请记住使用
basicstyle=\ttfamily
,否则
columns=fixed
不起作用。(我的案例)使用
basicstyle=\ttfamily
时,只要使用
keepspaces=true
选项,就可以保留
columns=flexible
。这将提供一个更“拥挤”的外观。类似于逐字记录。