使用fancyvrb LaTeX环境时出错

时间:2009-09-07 19:40:06

标签: latex

嗨,我正在尝试fancyvrb环境。我正在使用完全升级的Ubuntu 9.04。

如果我发布一个简单的Verbatim环境,例如:

\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

我正在开始使用LaTeX,我不确定我是否误用了它,或者我是否安装了错误的东西。

2 个答案:

答案 0 :(得分:2)

颜色包提供颜色。尝试添加\usepackage{color}

答案 1 :(得分:2)

问题的两个部分:

  1. fontsize选项仅接受LaTeX字体大小,例如\small\large
  2. 正如其他人所说,你需要加载颜色包(或xcolor包)才能让颜色起作用。
  3. 这是一个有效的例子:

    \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}
    
相关问题