\begin{lstlisting} inline int gcd(int a, int b) { // 如果a<b,则递归得gcd(b,a%b)即gcd...
用 XeLaTeX 编译,fontspec选字体,直接在 listings 的设置里面改。比如:%!TEX program = xelatex\docu...
\definecolor{mygreen}{rgb}{0,0.6,0}\definecolor{mygray}{rgb}{0.5,0.5,0.5}\definecolor{mymauve}{rgb}{0.58,0,0.82}\lstset{backgroundcolor=\color{white},%choose the background color basicstyle=\footnotesize\monaco,%size of fonts usedforthe code或改成\small\monaco稍大 numbers=left,%设置...
\usepackage{xeCJK} \setmonofont[Mapping={}]{Monaco} %英文引号之类的正常显示,相当于设置英文字体 \setsansfont{Monaco}%设置英文字体 Monaco, Consolas, Fantasque Sans Mono \setmainfont{Monaco}%设置英文字体 \setCJKmainfont{微软雅黑}%中文字体设置%\setCJKsansfont{楷体} %设置中文字体%\setCJKmonofont...
在lstset或lstlisting中设置basicstyle = \ttfamily \usepackage{fontspec}\setmonofont{Source Code Pro}\begin{lstlisting}[basicstyle =\ttfamily] codes\being{lstlisting} Overleaf内置字体名称 Overleaf自定义字体 参考资料 [1] LaTeX listings 宏包使用说明(一), 知乎,地址...
Options to customize code listing styles backgroundcolor- colour for the background. Externalcolororxcolorpackage needed. commentstyle- style of comments in source language. basicstyle- font size/family/etc. for source (e.g.basicstyle=\ttfamily\small) ...
basicstyle=\footnotesize\ttfamily, % size of fonts used for the code columns=fullflexible, breaklines=true, % automatic line breaking only at whitespace captionpos=b, % sets the caption-position to bottom tabsize=4, commentstyle=\color{mygreen}, % comment style ...
\documentclass[svgnames]{book}\usepackage{ctex}\usepackage{tikz}\usetikzlibrary{positioning}\usepackage{listings}\lstset{%frame=tb,%draw frame at top and bottomofcode block tabsize=1,%tab space width numbers=left,%display line numbers on the left ...
\end{lstlisting} 1. 2. 3. 4. 5. 6. 7. 8. 9. 效果如下: 三、使用 mcode 工具包 1. 下载mcode包 此包不存在于CTeX环境中,需要我们自行下载: 官网:https://cn.mathworks.com/matlabcentral/fileexchange/8015-m-code-latex-package 下载后我们会得到mcode.sty文件。
宏包atbeginend.sty 提供了 \BeforeBegin{environment}{code-to-execute}, \AfterEnd 等等命令。这些命令可去掉环境外面和内部的空间。例如 \AfterBegin{itemize}{\addtolength{\itemsep}{-\baselineskip}} 就在环境内以重新设置 \itemsep 来压缩items之间的距离 。