使用 fancyvrb LaTeX 环境时出错

发布于 2024-08-04 06:49:09 字数 1580 浏览 0 评论 0原文

嗨,我正在尝试寻找 vrb 环境。我正在使用完全升级的 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,但我不确定我是否误用了它,或者我是否安装了不正确的东西。

Hi I'm trying to fancyvrb environment. I'm using a fully upgraded Ubuntu 9.04.

If I issue a simple Verbatim environment, for example:

\begin{Verbatim}
  foobar
\end{Verbatim}

it works. However, if I try to pass in a parameter, for example, setting the font size:

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

This is ignored. If I try to set the color:

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

I get the following error:

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

I'm starting my way with LaTeX, and I'm not sure if I'm misusing it, or if I have something installed incorrectly.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

输什么也不输骨气 2024-08-11 06:49:09

您的问题有两个部分:

  1. fontsize 选项仅接受 LaTeX 字体大小,例如 \small\large
  2. 正如其他人提到的,您需要加载 color 包(或 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}

Two parts to your problem:

  1. The fontsize option only accepts LaTeX font sizes such as \small and \large
  2. As mentioned by others, you need to load the color package (or the xcolor package) to get colours to work.

Here's an example that works:

\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}
锦欢 2024-08-11 06:49:09

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

Colors are provided by the color package. Try adding \usepackage{color}

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文