日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 综合教程 >内容正文

综合教程

ubuntu latex的minted 安装

發(fā)布時(shí)間:2023/12/19 综合教程 28 生活家
生活随笔 收集整理的這篇文章主要介紹了 ubuntu latex的minted 安装 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

提示:minted包有一個(gè)bug,見文末。。

---------

簡(jiǎn)介(轉(zhuǎn)自: http://blog.houqp.me/minted-better-alternative-package-for-lstlisting/ )

------

曾幾何時(shí),我一直在使用lstlisting宏包高亮代碼,鑒于我從來就沒在Word里面享受過這樣的功能,我一直感到很滿意。直到今天我遇到了minted宏包。minted的[項(xiàng)目主頁]托管于Google Code。

使用非常的簡(jiǎn)單,例如:
\begin{minted}{c}
printf("Hello World.");
\end{minted}

minted在后臺(tái)調(diào)用的是pygmentize,所以輸出的結(jié)果非常漂亮,自然也就支持多種主題。minted提供很多可配置的參數(shù),更多選項(xiàng)請(qǐng)參考[官方文檔]。

有一點(diǎn)要注意的是編譯時(shí)需要加上-shell-escape參數(shù)。

------

安裝

minted的project home: http://code.google.com/p/minted/

主要按照上面文檔的介紹安裝就可以了。。 安裝時(shí)會(huì)要求安裝 minted.sty, 這里有一個(gè)簡(jiǎn)單的方法:

http://www.cnblogs.com/longdouhzt/archive/2012/10/11/2720045.html

安裝完minted.sty 就大功告成了~~

--------

使用

查看支持的語言: $ pygmentize -L lexers
  如 C, NASM

注意用小寫 如\begin{minted}{nasm}

幾個(gè)可能有用的配置:

1. 背景:

\definecolor{bg}{rgb}{0.95,0.95,0.95}
\begin{minted}[bgcolor=bg]{php}
<?php
  echo "Hello, $x";
?>
\end{minted}

2. 行號(hào)

linenos (boolean)
(default: false)
Enables line numbers. In order to customize the display style of line numbers, you
need to redefine the \theFancyVerbLine macro:

\renewcommand{\theFancyVerbLine}{\sffamily
\textcolor[rgb]{0.5,0.5,1.0}{\scriptsize
\oldstylenums{\arabic{FancyVerbLine}}}}
\begin{minted}[linenos,
firstnumber=11]{python}
def all(iterable):
  for i in iterable:
    if not i:
      return False
  return True
\end{minted}

...以后再補(bǔ)充吧

---------------------------

最近用minted包發(fā)現(xiàn)一個(gè)bug:

Long listings are not splitted across pages.
即代碼太長(zhǎng),一頁放不下時(shí),minted不會(huì)自動(dòng)分頁,而是直接把超過一頁的部分截了。。囧。。

兩個(gè)可能的解決方法:
(1) 手動(dòng)分頁:
http://tex.stackexchange.com/questions/51165/code-over-two-pages-and-continue-counting-lines

 1 \begin{program}[H]
 2 \begin{minted}[bgcolor=lightgray,linenos=true,fontfamily=courier,fontsize=\footnotesize,frame=single]{javascript}
 3  \\Code Part 1 : numbers going from 1..28
 4 \end{minted}
 5 \caption{Same Caption}
 6 \label{prog:samelabel}
 7 \end{program}
 8 
 9 \newpage
10 
11 \begin{program}[H]
12 \ContinuedFloat
13 \begin{minted}[bgcolor=lightgray,linenos=true,fontfamily=courier,fontsize=\footnotesize,frame=single,firstnumber=29]{javascript} 
14  \\Code Part 2 change firstnumber value
15 \end{minted}
16 \caption{Same Caption}
17 \label{prog:samelabel}
18 \end{program}


(2) mdframed (沒試過)
http://tex.stackexchange.com/questions/23663/minted-truncates-the-code-if-it-doesnt-fit-into-one-page

總結(jié)

以上是生活随笔為你收集整理的ubuntu latex的minted 安装的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。