Latex 中插入 Matlab 代码

2023-11-11

这篇文章将介绍如何在 Latex 排版过程中添加 Matlab 代码

功能效果
主要有如下排版功能:

  • 语法高亮
  • 自动添加边框
  • 自动添加行号

先上图,大家感受一下效果:
在这里插入图片描述
而实现这些只需要一行代码加一个包!

  1. 插入代码块
\usepackage{listings}
\usepackage[framed,numbered,autolinebreaks,useliterate]{mcode}

\begin{lstlisting}
	% Plot function f(x) = 2*x^3 - x - 2
	ezplot('2*x^3-x-2',[0, 2])
	hold on
	plot([0,2],[0,0],'r')
\end{lstlisting}

我们来看一下效果:
在这里插入图片描述
比较发现只是简单的加入了如下一句代码:

\usepackage[framed,numbered,autolinebreaks,useliterate]{mcode}
  1. 段落中插入 Matlab 语句
    只需在段落或页脚编辑中插入如下语句:
\mcode{for i=1:3, disp('cool'); end;}
\footnote{Works also in footnotes: \mcodefn{for i=1:3, disp('cool'); end;}}

即使用 \mcode{}
效果如下:
在这里插入图片描述

而要实现这些需要在main.tex的目录下加一个mcode.sty文件

具体内容如下:(可以新建文件然后复制过去直接使用)记得改文件名为mcode.sty
也可以去下载:传送门https://www.mathworks.com/matlabcentral/fileexchange/8015-m-code-latex-package

%%
%%   This is file `mcode.sty'
%%
%%   It is supposed to help you easily include MATLAB source code
%%   into LaTeX document,  but have it nicely highlighted, using
%%   the great listings package.
%%
%%   PLEASE NOTE that this package does nothing but save you from
%%   figuring out some configurations  in setting up the LISTINGS
%%   package. ALL the work is done by that package!  Thus, please
%%   refer your questions to the listings package documentation.
%%
%%   Usage: You have three ways of including your MATLAB code. As
%%   environment,  as inline object and directly from an external
%%   file.
%%
%%   1) Environment:
%%
%%          \begin{lstlisting}
%%             YOUR CODE HERE
%%          \end{lstlisting}
%%
%%
%%   2) Inline object*:
%%
%%          Bla bla \mcode{CODEFRAGMENT} bla bla.
%%
%%
%%   3) Include external file (in environment form)
%%
%%          \lstinputlisting{YOUR-FILE.m}
%%
%%
%%   For your convenience this package has the following options:
%%
%%   - bw  if you intend to print the document (highlighting done
%%         via text formatting (bold, italic) and shades of gray)
%%   
%%   - numbered  if you want line numbers
%%
%%   - autolinebreaks  if you want  the package to  automatically
%%          wrap your  code.  This is buggy as it  may well break
%%          break syntax and it  doesn't work well with comments.
%%          You REALLY should wrap your code manually.
%%
%%   - useliterate   if you want  some characters / relations  in
%%          your code to be replace with something more readable.
%%          Example: ~= becomes $\neq$, >= becomes $\geq$,  delta
%%          becomes $\delta$ and so on.
%%
%%   - framed  if you want a frame  around the source code blocks
%%
%%   - final  if you have  ``gloablly'' set the draft option, the
%%         listings package will  not output the code at all.  to
%%         force it to  do so anyway,  load this package with the
%%         final option (passes the ``final'' on to listings).
%%
%%   For example, you may use \usepackage[numbered,framed]{mcode}
%%   in your document preamble.
%%   
%%   * If you want to place  some inline code in a footnote,  use
%%   \mcodefn{} instead (this will reduce the font size a bit).
%%
%%   Note:  Inside code blocks you  can escape to LaTeX text mode
%%   using §...§.  For ex. §text and some math: $x^2$§,  which is
%%   especially  useful  in comments  for putting  nicely typeset
%%   equations etc.  To get the same  colour/style as in the rest
%%   of the comment use \mcommentfont, i.e. §\mcommentfont $x^2$§
%%
%%   To change the font used,  edit the first line in the "custo-
%%   mise below" section.  And feel free to  edit other things as
%%   well.  Refer to the documentation of the listings package to
%%   see what  else you could do.  If an extra small font  is re-
%%   quired,  use  {\fontfamily{pcr}\fontsize{3}{4.6}\selectfont}
%%   in the definition of \lstbasicfont.
%%
%%   Author:
%%      Florian Knorn | florian@knorn.org | www.florian-knorn.com
%%
%%   Version history:
%%      2.7  --  Bugfixes + keywords (thanks Hildo Guillardi Jr.)
%%      2.6  --  Add support for µ, fix for math-minus problem
%%      2.5  --  Renamed internal variables (thx S. Kranenbarg!)
%%      2.4  --  Added \mcodefn{} command (thx Tony Almeida!)
%%      2.3  --  More keywords (thx Dominik Wild!)
%%      2.2  --  Bugfix (thx Willi Gerbig!)
%%      2.1  --  Finally automatic detection between end and end
%%      2.0  --  New options for line breaking and literate prog.
%%      1.8  --  Fixed typo in documentation regarding §...§
%%      1.7  --  Added MATLAB block comment syntax %{ ...... %}
%%      1.6  --  Added some infos, dealing with keyword ``end''
%%      1.5  --  Tweaked check to see wether textcomp is loaded
%%      1.4  --  Fixed misconfig (mathescape now set to false)
%%      1.3  --  Purely cosmetic (tabs replaced by spaces)
%%      1.2  --  Added \lstset{showstringspaces=false}
%%      1.1  --  Added \mcode command and [final] option
%%      1.0  --  Release


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%              D O N ' T    T O U C H    T H I S                %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\fileversion{2.7}
\def\filedate{2015/11/11}

\typeout{-- Package: `mcode' \fileversion\space <\filedate> --}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{mcode}[\filedate\space\fileversion]

% for bw-option
\newif\ifmcode@bw
\DeclareOption{bw}{\mcode@bwtrue}

% numbered option
\newif\ifmcode@numbered
\DeclareOption{numbered}{\mcode@numberedtrue}

% final option
\newif\ifmcode@final
\DeclareOption{final}{\mcode@finaltrue}

% autolinebreaks option
\newif\ifmcode@autolinebreaks
\DeclareOption{autolinebreaks}{\mcode@autolinebreakstrue}

% literate programming (replace certain characters/relations
\newif\ifmcode@useliterate
\DeclareOption{useliterate}{\mcode@useliteratetrue}

% framed option
\newif\ifmcode@framed
\DeclareOption{framed}{\mcode@framedtrue}

\DeclareOption*{% default
  \PackageWarning{mcode}{Unknown option `\CurrentOption' !}%
}
\ProcessOptions

\ifmcode@bw\typeout{ - settings optimized for printing (bw formating)}
\else\typeout{ - settings optimized for display (colour formating)}\fi
\ifmcode@numbered\typeout{ - line numbering enabled}\else\fi
\ifmcode@useliterate\typeout{ - literate programming (character replacements) enabled}\else\fi
\ifmcode@autolinebreaks\typeout{ - automatic line breaking enabled (careful, buggy!)}\else\fi
\ifmcode@framed\typeout{ - framed listings}\else\fi

% This command allows you to typeset syntax highlighted Matlab
% code ``inline''.  The font size \small seems to look best...
\newcommand{\mcode}[1]{\lstinline[basicstyle=\lstbasicfont\small]|#1|}

% Same, but for footnotes
\newcommand{\mcodefn}[1]{\lstinline[basicstyle=\lstbasicfont\footnotesize]|#1|}

% check if color command exists
\ifx\color\undefined%
  \RequirePackage{xcolor}%
\fi

% check if listings has been loaded
\ifx\lstset\undefined%
  \ifmcode@final
    \RequirePackage[final]{listings}
  \else
    \RequirePackage{listings}
  \fi
\fi

% Check if textcomp has been loaded (this package is needed for
% upright quotes '' (instead of typographic ones `´)...
\ifx\textquotesingle\undefined% 
  \RequirePackage{textcomp}%
\fi

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                C U S T O M I S E   B E L O W                  %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% ---------------------------------------------------------------------------------
% default font
\def\lstbasicfont{\fontfamily{pcr}\selectfont\footnotesize}

% ---------------------------------------------------------------------------------
% matlat languate definition
\lstdefinelanguage{matlabfloz}{%
  alsoletter={...},%
  morekeywords={%                             % keywords
		break,case,catch,classdef,continue,else,
		elseif,end,for,function,global,if,
		otherwise,parfor,persistent,
		return,spmd,switch,try,while,...},        % Use the matlab "iskeyword" command to get those
  comment=[l]\%,                              % comments
  morecomment=[l]...,                         % comments
  morecomment=[s]{\%\{}{\%\}},                % block comments
  morestring=[m]'                             % strings 
}[keywords,comments,strings]%

% ---------------------------------------------------------------------------------
% general definitions
\lstset{%
  basicstyle={\lstbasicfont},                 % set font
  showstringspaces=false,                     % do not emphasize spaces in strings
  tabsize=4,                                  % number of spaces of a TAB
  mathescape=false,escapechar=§,              % escape to latex with §..upquote=true,                               % upright quotes
  aboveskip={1.5\baselineskip},               % a bit of space above listings
  columns=fixed                               % nice spacing
}

% ---------------------------------------------------------------------------------
% define colours and styles
\ifmcode@bw % use font formating and gray 'colors'
	\def\mcommentfont{\color[gray]{.75}\itshape} %comments light gray and italic
  \lstset{language=matlabfloz,                % use our version of highlighting
    keywordstyle=\bfseries,                   % keywords in bold
    commentstyle=\mcommentfont,               % comments 
    stringstyle=\color[gray]{0.5}             % strings darker gray
  }
\else% notbw => use colors : )
	\def\mcommentfont{\color[rgb]{.133,.545,.133}} %comments in green
  \lstset{language=matlabfloz,                % use our version of highlighting
    keywordstyle=\color[rgb]{0,0,1},          % keywords in blue
    commentstyle=\mcommentfont,               % comments
    stringstyle=\color[rgb]{.627,.126,.941}   % strings in purple
  } 
\fi%bw

% ---------------------------------------------------------------------------------
% automatic line breaking --- warning, this is buggy and
% doesn't break comments correctly!
\ifmcode@autolinebreaks
	\newsavebox{\lbreakdots}\sbox{\lbreakdots}{\lstbasicfont\mcommentfont...}
	\lstset{breaklines=true,breakatwhitespace=true,prebreak=\usebox{\lbreakdots}}
\fi

% ---------------------------------------------------------------------------------
% literate replacements
% the following is for replacing some matlab relations like >= or ~=
% by the corresponding LaTeX symbols, which are much easier to read ...
\ifmcode@useliterate
	\lstset{%
		literate=%
			{~}{{$\neg$}}1 %               \neg, logical not
			{<=}{{\tiny$\leq$}}1 %         \leq
			{>=}{{\tiny$\geq$}}1 %         \geq
			{~=}{{\tiny$\neq$}}1 %         \neq, not equal
			{delta}{{\tiny$\Delta$}}1 %    \Delta
			{µ}{{$\mu$}}1 %                \mu
			{(end)}{\lstbasicfont (end)}{5} % black ``end'' when indexing last vector element
			{({ }end)}{\lstbasicfont ({ }end)}{6}
			{(end{ })}{\lstbasicfont (end{ })}{6}
			{({ }end{ })}{\lstbasicfont ({ }end{ })}{7}
			{:end}{\lstbasicfont :end}{4}
			{:{ }end}{\lstbasicfont :{ }end}{5}
			{end:}{\lstbasicfont end:}{4}
			{end{ }:}{\lstbasicfont end{ }:}{5}
			{,end}{\lstbasicfont ,end}{4}
			{,{ }end}{\lstbasicfont ,{ }end}{5}
	}
\else
	\lstset{%
		literate=%
			{(end)}{\lstbasicfont (end)}{5} % black ``end'' when indexing last vector element
			{({ }end)}{\lstbasicfont ({ }end)}{6}
			{(end{ })}{\lstbasicfont (end{ })}{6}
			{({ }end{ })}{\lstbasicfont ({ }end{ })}{7}
			{:end}{\lstbasicfont :end}{4}
			{:{ }end}{\lstbasicfont :{ }end}{5}
			{end:}{\lstbasicfont end:}{4}
			{end{ }:}{\lstbasicfont end{ }:}{5}
			{,end}{\lstbasicfont ,end}{4}
			{,{ }end}{\lstbasicfont ,{ }end}{5}
			{µ}{$\mu$}1
			{~}{{\fontfamily{ptm}\selectfont\texttildelow}}1 % get a nicer tilde character
	}
\fi%literates

% ---------------------------------------------------------------------------------
% line numbering
\ifmcode@numbered% numbered option
  \lstset{%
    numbersep=3mm, numbers=left, numberstyle=\tiny, % number style
  }
\fi

\ifmcode@framed%   framed option
  \lstset{%
    frame=single,rulecolor=\color{black}            % frame
  }
  \ifmcode@numbered%
    \lstset{%
      framexleftmargin=6mm, xleftmargin=6mm         % tweak margins
    }
  \fi
\fi

% fix for ``minus'' character issue, as suggested by Stefan Karlsson, thanks!
\makeatletter 
\lst@CCPutMacro\lst@ProcessOther {"2D}{\lst@ttfamily{-{}}{-{}}} 
\@empty\z@\@empty 
\makeatother

\endinput
%% End of file `mcode.sty'.

参考链接
仅供学习之用,侵删。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Latex 中插入 Matlab 代码 的相关文章

  • 类方法的自定义代码完成?

    在 MATLAB 中 可以定义代码建议和完成 如标题为 的文档页面中所述 自定义代码建议和完成 https www mathworks com help matlab matlab prog customize code suggestio
  • 整数的十进制表示形式中的分隔数字

    例如 我想将用户输入作为整数输入 45697 并将前两位数字存储在数组 向量或其他内容中 例如 4 5 6 9 7 这样我就可以使用一些函数调用来检查前两个值 4 5 并对它们进行计算 问题 我不知道如何存储恢复前两个值 有没有简单的函数调
  • MATLAB:比较两个不同长度的数组

    我有两个长度不同的数组 由于采样率不同 需要比较 我想对较大的数组进行下采样以匹配较小的数组的长度 但是该因子不是整数而是小数 举个例子 a 1 1 375 1 75 2 125 2 5 2 875 3 25 b 1 2 3 有什么方法可以
  • 在 Matlab 中显示有理数

    我有两个整数 m n 它们一起形成 m n 形式的有理数 现在我只想以这种理性的形式在 Matlab 中显示它们 我可以通过这样做来做到这一点 char sym m n 所以 如果 例如m 1 n 2 Matlab将显示1 2 然而 如果m
  • 频域和空间域的汉明滤波器

    我想通过在 MATLAB 中应用汉明滤波器来消除一维信号中的吉布斯伪影 我所拥有的是k1这是频域中的信号 我可以通过应用 DFT 来获取时域信号k1 s1 ifft ifftshift k1 该信号具有吉布斯伪影 现在 我想通过 A 乘以汉
  • 为什么 mex 文件中的 OpenMP 仅产生 1 个线程?

    我是 OpenMP 新手 我有以下代码 使用配置了 MSVS2010 的 Matlab mex 可以正常编译 计算机有 8 个可用处理器 我也使用 matlabpool 检查过 include mex h include
  • 从筛查乳腺 X 光检查数字数据库 (DDSM) 获取数据

    我正在尝试以可读格式获取 DDSM 数据集 有谁有 DDSM heathusf 程序的工作版本 可以在 Linux 或 Windows 上正常运行吗 我知道 DDSM 的 jpeg 程序有一个适用于 linux 的工作版本 位于http w
  • getappdata 在 MATLAB 中返回空矩阵

    我有一段代码 我在其中使用setappdata然后我使用以下方式调用数据getappdata即使它不为空 它也会返回一个空矩阵 我的一段简化代码如下 function edit1 Callback hObject eventdata han
  • 在Matlab中对字符进行分组并形成矩阵

    我有 26 个字符 A 到 Z 我将 4 个字符组合在一起 并用空格分隔以下 4 个字符 如下所示 abcd efgh ijkl mnop qrst uvwx yz 我的Matlab编码如下 str abcdefghijklmnopqrst
  • 如何在Matlab中绘制网络?

    我有一个矩阵AMatlab中的维数mx2每行包含两个节点的标签 显示网络中的直接链接 例如 如果网络有4矩阵的节点A可能A 1 2 1 3 2 1 2 4 3 2 4 1 4 2 其中第一行表示有一个链接来自1 to 2 第二行表示有一个链
  • 如何在Matlab中打印带有千位分隔符的整数?

    我想使用逗号作为千位分隔符将数字转换为字符串 就像是 x 120501231 21 str sprintf 0 0f x 但随着效果 str 120 501 231 21 如果内置fprintf sprintf做不到 我想可以使用正则表达式
  • Matlab 图像数据的 hist 函数

    我是 Matlab 新手 我想制作自己的函数 与 imhist 显示图像数据的直方图 完成相同的工作 但我对此完全是新手 我不知道如何做开发这样的功能 我开始做一些东西 但它非常不完整 function output args myhist
  • 命令 A(~A) 在 matlab 中的真正作用是什么

    我一直在寻找找到矩阵非零最小值的最有效方法 并在论坛上找到了这个 设数据为矩阵A A A nan minNonZero min A 这是非常短且高效的 至少在代码行数方面 但我不明白当我们这样做时会发生什么 我找不到任何关于此的文档 因为它
  • Matlab的导入函数的范围是什么?

    我正在尝试将一些用 Matlab 编写的代码转换为独立的 编译的 Matlab 应用程序 然而 在出现一些奇怪的错误之后 我意识到代码大量使用了从路径中添加和删除的操作 以避免多次使用多个具有相同名称 但结果 计算不同 的函数这一事实 环顾
  • matlab中无限while嵌套在for循环中

    我想做一个while循环 嵌套在for在 Matlab 中循环以查找数据中不同对之间的距离 我的数据具有以下形式 ID lon lat time 1 33 56 40 89 803 2 32 45 41 03 803 3 35 78 39
  • Matlab:3D 堆积条形图

    我正在尝试创建一个 3D 堆积条形图 如这个问题所示 Matlab 中的 3D 堆叠条形图 https stackoverflow com questions 13156133 3d stacked bars in matlab 5D 然而
  • MATLAB 除法...29/128 应该返回 0 吗?

    我真的不认为这是一个精度问题 答案应该是0 226左右 这是确切的代码 val I i j bucketSize pos val bucketSize I只是我从中获取值的矩阵 以下是 MATLAB 的输出 val 29 bucketSiz
  • 在 MATLAB 中绘图后恢复轴

    从文本文件绘制多种方法的输出后 未显示轴的右侧和上侧 我需要拥有它们并将它们加粗 就像当前的轴一样 绘制的数据来自存储每种方法数据的文件 每个数据文件都是一个 256x2 文件 包含 0 1 之间的值 第一列是精度 第二列是召回率 figu
  • Deploytool for MATLAB R2013b 不起作用,发生了什么变化?

    多年来我一直在使用集成deploytool为我的同事创建易于分发的 exe 文件 我几天前安装了R2013b 但无法使用deploytool不再了 尝试打包时的日志文件给出了以下内容 ant
  • 保存符号方程以供以后使用?

    From here http www mathworks com help releases R2011a toolbox symbolic brvfu8o 1 html brvfxem 1 我正在尝试求解这样的符号方程组 syms x y

随机推荐

  • QTCreator的使用

    用最新的QtCreator选择GUI的应用会产生含有如下文件的工程 下面就简单分析下各部分的功能 pro文件是供qmake使用的文件 不是本文的重点 不过其实也很简单的 在此不多赘述 所以呢 还是从main开始 view plain cop
  • 汉字转换为拼音的JavaScript库

    将JSPinyin剥离mootools这个JavaScript库 可以独立使用 1 一个是将汉字翻译为拼音 其中每一个字的首字母大写 pinyin getFullChars this value 2 一个是可以将每一个字的拼音的首字母提取出
  • MobaXterm学习与使用

    转载地址 MobaXterm学习与使用 首先要弄清几个概念 1 先来看看SSH是什么 定义如下 SSH是一种可以保证用户远程登录到系统的协议 实际上 SSH是一个网络协议 允许通过网络连接到Linux和Unix服务器 SSH使用公钥加密来认
  • 给定一个字符串求出最长重复子串

    主要是使用到了二分的思想 知道字符串就是知道了它的长度 然后可知len max s length 2 然后暴力枚举就可以得出答案 代码如下 include
  • python爬虫 模拟登录_Python爬虫(8):模拟登录方法汇总

    对于很多要先登录的网站来说 模拟登录往往是爬虫的第一道坎 本文介绍 POST 请求登录 获取 Cookies 登录 Seleium 模拟登录三种方法 摘要 在进行爬虫时 除了常见的不用登录就能爬取的网站 还有一类需要先登录的网站 比如豆瓣
  • 破解Photoshop cs6

    怎样安装和破解Photoshop CS6 浏览 152148 更新 2012 10 18 23 46 标签 photoshop 1 2 3 4 5 6 7 分步阅读
  • union struct的内存分配方式及其sizeof大小

    经验 1 int main union zcl double i char k 15 char c struct date int cat 元类型4 zcl cow 元类型8 zcl里面的i double类型 struct dat char
  • 有各组方差怎么算组间平方和_讲讲统计科学里的方差分析

    上一篇讲了假设检验 这一篇讲讲方差分析 1 背景 假如你们现在针对用户提出了三种提高客单价的策略A B C 现在想看一下这三种策略最后对提高客单价的效果有什么不同 那我们怎么才能知道这三种策略效果有什么不同 最简单的方法就是做一个实验 我们
  • react 通过生命周期优化组件性能

    已经对React生命周期有了认识 那如何利用它提高组件的性能那 通过shouldComponentUpdate函数 改善React组件性能的例子 小姐姐组件存在性能问题 是的 小姐姐组件已经写的很熟悉了 但是它有一个性能问题 那就是子组件X
  • MySQL5.6主从复制的配置(CentOS-6.6+MySQL-5.6)(二)

    原文地址 http my oschina net wushuicheng blog 652680 MySQL5 6主从复制的配置 CentOS 6 6 MySQL 5 6 作者 吴水成 出自 龙果学院 基于Dubbo的分布式系统架构视频教程
  • Flume 报出异常org/apache/hadoop/io/SequenceFile$CompressionType

    异常 Failed to start agent because dependencies were not found in classpath Error follows java lang NoClassDefFoundError o
  • sse指令

    mm add ss mm add ps
  • HBase数据模型、RowKey、Column Family(列族)和qualifier(列)、Timestamp时间戳、Cell单元格、读写流程、HLog(WAL log)...

    目录 HBase数据模型 RowKey Column Family 列族 和qualifier 列 Timestamp时间戳 Cell单元格 读写流程 HLog WAL log HBase数据模型 HRegion是HBase中分布式存储和负
  • ADB调试--详细教程(附华为手机无法显示设备解决方法)

    终端打开开发者模式 用数据线连接电脑 然后按照下面的步骤操作 1 开启开发者选项 设置 gt 关于设备 gt 版本号 连续点击5次 2 打开USB调试 在开发者选项中 找到USB调试 将此打开 3 cmd进入命令行 进入含有adb exe的
  • zabbix 5系列之snmp监控详解

    更多精彩Zabbix文章 技术交流 免费技术培训加微号NateIT 免费获取zabbix安装 配置 优化技术培训视频 官网 http ywzs hanyunintel com 首先 谢谢原作者 此文为转载的文章 现将原地址贴出如下zabbi
  • 服务器查看不到集群信息,查看服务器集群资源

    查看服务器集群资源 内容精选 换一换 区块链服务状态为 异常 排查项一 区块链依赖的集群 服务器 存储等资源是否正常 排查项二 云服务器节点资源规格不足 排查项一 区块链依赖的集群 服务器 存储等资源是否正常 CCE集群状态排查 登录CCE
  • 10.4 a.m.小结

    T1 问题 A Prime Distance 题目描述 给定两个整数 L R 求闭区间 L R 中相邻两个质数差值最小的数对与差值最大的数对 当存在多个时 输出靠前的素数对 输入 多组数据 每行两个数 L R 输出 详见输出样例 样例输入
  • ubuntu查看内存占用和查看cpu使用情况的2种方法

    简易方法1 top法 并且摁下数字1 1 使用terminal 输入命令行 top 2 如果希望看到cpu核数 并且知道相关占用率等情况信息 此时按下数字 1 即可 3 摁下 q 退出 快捷方法2 使用htop 2 安装htop sudo
  • 代理IP的高匿名,匿名和透明的区别

    如果从隐藏使用代理用户的级别上划分 代理可以分为三种 即高度匿名代理 普通匿名代理和透明代理 1 高度匿名代理不改变客户机的请求 这样在服务器看来就像有个真正的客户浏览器在访问它 这时客户的真实IP是隐藏的 服务器端不会认为我们使用了代理
  • Latex 中插入 Matlab 代码

    这篇文章将介绍如何在 Latex 排版过程中添加 Matlab 代码 功能效果 主要有如下排版功能 语法高亮 自动添加边框 自动添加行号 先上图 大家感受一下效果 而实现这些只需要一行代码加一个包 插入代码块 usepackage list