QQ群:91940767/145316219/141877998/80300084/194770436
淘宝店:http://latexstudio.taobao.com
技巧续篇:http://latexstudio.net/
常见数学公式问题集下载
minted宏包是高亮显示源代码不错的包,比较麻烦的是需要python的pygmentize的支持,需要些系统配置工作。
但是我们支持minted提供了一个环境\begin{minted}
\end{minted}
却没有一个单用在行内的命令。
如下便是一个网友自己定义了一个行内的mint命令,选自这里
注意编译用:latex /pdflatex -shell-escape
filename 哦!
【源代码】:
\documentclass{minimal}
\usepackage{ifplatform}
\ifwindows\else
\newcommand*{\TestAppExists}[1]{% there is no `which -s` on
Linux
\immediate\write18{which -- '#1'
> /dev/null && touch
-- '\jobname.aex'}%
\IfFileExists{\jobname.aex}{%
\AppExiststrue
\DeleteFile{\jobname.aex}%
}{%
\AppExistsfalse
}
}
\fi
\usepackage{minted}
\makeatletter
% avoid space tokens since we're in horizontal mode
\renewcommand\mint[3][]{%
\DefineShortVerb{#3}%
\minted@resetoptions
\setkeys{minted@opt}{#1}%
\SaveVerb[aftersave={%
\UndefineShortVerb{#3}%
\minted@savecode{\FV@SV@minted@verb}%
\minted@pygmentize{#2}%
\DeleteFile{\jobname.pyg}}]{minted@verb}#3}
\renewcommand\minted@savecode[1]{%
\immediate\openout\minted@code\jobname.pyg\relax
\immediate\write\minted@code{#1}%
\immediate\closeout\minted@code}
\renewcommand\minted@pygmentize[2][\jobname.pyg]{%
\def\minted@cmd{pygmentize -l #2 -f latex -F
tokenmerge
\minted@opt{gobble} \minted@opt{texcl}
\minted@opt{mathescape}
\minted@opt{linenos} -P "verboptions=\minted@opt{extra}"
-o
\jobname.out.pyg #1}%
\immediate\write18{\minted@cmd}%
\ifthenelse{\equal{\minted@opt@bgcolor}{}}%
{}%
{\begin{minted@colorbg}{\minted@opt@bgcolor}}%
\input{\jobname.out.pyg}%
\ifthenelse{\equal{\minted@opt@bgcolor}{}}%
{}%
{\end{minted@colorbg}}%
\DeleteFile{\jobname.out.pyg}}
\makeatother
\RecustomVerbatimEnvironment{Verbatim}{BVerbatim}{}
\begin{document}
This is some inline code \mint{c++}|for
i=1;i<20;i++| and more \ldots
\end{document}
【演示效果图】
发表评论 取消回复