前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >LaTeX代码环境配置:使用LaTeX展

LaTeX代码环境配置:使用LaTeX展

作者头像
py3study
发布2020-01-09 15:51:03
1.3K0
发布2020-01-09 15:51:03
举报
文章被收录于专栏:python3python3

翻译 https://stackoverflow.com/questions/3175105/writing-code-in-latex-document 内的内容。 其实就是使用Listings包,一个例子如下: 在正文前(\begin{document}之前)使用如下代码设置参数:

代码语言:javascript
复制
\usepackage{listings}
\usepackage{color}

\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}

\lstset{frame=tb,
  language=Python,
  aboveskip=3mm,
  belowskip=3mm,
  showstringspaces=false,
  columns=flexible,
  basicstyle={\small\ttfamily},
  numbers=none,
  numberstyle=\tiny\color{gray},
  keywordstyle=\color{blue},
  commentstyle=\color{dkgreen},
  stringstyle=\color{mauve},
  breaklines=true,
  breakatwhitespace=true,
  tabsize=3
}

在正文里面的时候在lstlisting环境内放置代码即可,例子如下:

代码语言:javascript
复制
\begin{lstlisting}
import numpy as np
if __name__ == '__main__':
	print(np.arange(10))
\end{lstlisting}

结果如下:

result
result
本文参与?腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019-08-26 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客?前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与?腾讯云自媒体同步曝光计划? ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档
http://www.vxiaotou.com