首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Latex:使用等宽字体的列表

Latex:使用等宽字体的列表
EN

Stack Overflow用户
提问于 2010-05-26 21:03:14
回答 2查看 47.3K关注 0票数 43

这就是Xcode中的代码。

这是我用texlive创建的清单中的内容。

是的,我使用了basicstyle=\ttfamily。看过清单手册后,我没有发现任何关于固定字体或等宽字体的内容。

要复制的示例

代码语言:javascript
复制
\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}
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2010-05-27 02:44:58

问题出在columns=flexible选项上。移除它,它看起来像是你想要它看起来。至少,如果你没有实际的理由使用它的话。如果有,那么您的代码片段就不可能像Xcode :)中那样具有单一的特性。

票数 39
EN

Stack Overflow用户

发布于 2010-05-26 21:25:51

当您放弃\usepackage{microtype}时会发生什么?它扰乱了字距调整等等,可能是问题的原因,我认为这是由于对齐不佳。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2913141

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档