2009-09-07 81 views
1

嗨,我試圖fancyvrb環境。我正在使用完全升級的Unbuntu 9.04。使用fancyvrb LaTeX環境時出錯

如果我發出了一個簡單的逐字環境中,例如:

\begin{Verbatim} 
    foobar 
\end{Verbatim} 

它的工作原理。但是,如果我嘗試傳入參數,例如設置字體大小:

\begin{Verbatim}[fontsize=8] 
    foobar 
\end{Verbatim} 

這被忽略。如果我嘗試設置顏色:

\begin{Verbatim}[formatcom=\color{red}] 
    foobar 
\end{Verbatim} 

我得到以下錯誤:

Running `LaTeX' on `test' with ``latex -interaction=nonstopmode "\input" test.tex'' 
This is pdfTeXk, Version 3.141592-1.40.3 (Web2C 7.5.6) 
%&-line parsing enabled. 
entering extended mode 
LaTeX2e <2005/12/01> 
Babel <v3.8h> and hyphenation patterns for english, usenglishmax, dumylang, noh 
yphenation, loaded. 
(./test.tex (/usr/share/texmf-texlive/tex/latex/base/article.cls 
Document Class: article 2005/09/16 v1.4f Standard LaTeX document class 
(/usr/share/texmf-texlive/tex/latex/base/size10.clo)) 
(/usr/share/texmf-texlive/tex/latex/fancyvrb/fancyvrb.sty 
Style option: `fancyvrb' v2.6, with DG/SPQR fixes <1998/07/17> (tvz) 
(/usr/share/texmf-texlive/tex/latex/graphics/keyval.sty) 
No file fancyvrb.cfg. 
) (./test.aux) 
! Undefined control sequence. 
\FancyVerbFormatCom ->\color 
          {red}\relax 
l.20 \begin{Verbatim}[formatcom=\color{red}] 

[1] (./test.aux)) 
(see the transcript file for additional information) 
Output written on test.dvi (1 page, 644 bytes). 
Transcript written on test.log. 

LaTeX exited abnormally with code 1 at Mon Sep 7 15:19:05 

我開始我的方式乳膠,我不知道如果我濫用它,或者如果我有東西安裝不正確。

謝謝

回答

2

兩部分,以您的問題:

  1. fontsize選項只接受LaTeX的字體大小,如\small\large
  2. 正如其他人所說,你需要加載彩包(或xcolor包)來讓顏色起作用。

這裏有一個工作的例子:

 
\documentclass{article} 
\usepackage{color,fancyvrb} 
\begin{document} 
\begin{Verbatim} 
    foobar 
\end{Verbatim} 
\begin{Verbatim}[fontsize=\small] 
    foobar 
\end{Verbatim} 
\begin{Verbatim}[formatcom=\color{red}] 
    foobar 
\end{Verbatim} 
\end{document} 
2

顏色由顏色包提供。嘗試添加\usepackage{color}