\documentclass[a4paper,10pt]{article}
\usepackage{framed}
\usepackage{lipsum}
\newenvironment{nb}
{\begin{framed}\begin{quotation}}
{\end{framed}\end{quotation}}
\begin{document}
\begin{nb}
\lipsum
\end{nb}
\end{document}
该代码在我的 PC(安装了 miktex 的 Windows 7 32 位系统)上无法运行,我不知道问题出在哪里。
正如您所看到的,我正在尝试创建一个新的环境,它可以帮助我尽可能简单地保存我的文本,使我能够将环境内的文本以引用的形式显示在框架中。
这是完整的输出,我的文件名为 test.tex,采用 UTF8 编码:
pdflatex test.tex
This is pdfTeX, Version 3.1415926-2.3-1.40.12 (MiKTeX 2.9)
entering extended mode
(C:\Users\windows\Documents\latex\test\test.tex
LaTeX2e <2011/06/27>
Babel <v3.8m> and hyphenation patterns for english, afrikaans, ancientgreek, ar
abic, armenian, assamese, basque, bengali, bokmal, bulgarian, catalan, coptic,
croatian, czech, danish, dutch, esperanto, estonian, farsi, finnish, french, ga
lician, german, german-x-2009-06-19, greek, gujarati, hindi, hungarian, iceland
ic, indonesian, interlingua, irish, italian, kannada, kurmanji, lao, latin, lat
vian, lithuanian, malayalam, marathi, mongolian, mongolianlmc, monogreek, ngerm
an, ngerman-x-2009-06-19, nynorsk, oriya, panjabi, pinyin, polish, portuguese,
romanian, russian, sanskrit, serbian, slovak, slovenian, spanish, swedish, swis
sgerman, tamil, telugu, turkish, turkmen, ukenglish, ukrainian, uppersorbian, u
senglishmax, welsh, loaded.
("C:\Program Files\MiKTeX 2.9\tex\latex\base\article.cls"
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
("C:\Program Files\MiKTeX 2.9\tex\latex\base\size10.clo"))
("C:\Program Files\MiKTeX 2.9\tex\latex\framed\framed.sty")
("C:\Program Files\MiKTeX 2.9\tex\latex\lipsum\lipsum.sty")
(C:\Users\windows\Documents\latex\test\test.aux)
! Extra }, or forgotten \endgroup.
\endMakeFramed ...eight \z@ \penalty -100 \egroup
\begingroup \fb@put@frame ...
l.10 \end{nb}
?
答案1
您的环境以错误的方式结束quotation
。framed
如果您将其更改为
...
\newenvironment{nb}
{\begin{framed}\begin{quotation}}
{\end{quotation}\end{framed}} % Note this line
...
那么它工作正常。
每当你使用它调用你的nb
环境时,\begin{nb}
它都会调用开头的代码
\begin{framed}
\begin{quotation}
当你用它结束你的环境时\end{nb}
会调用
\end{quotation}
\end{framed}
在您的代码中,它们的顺序是乱序的,所以它试图framed
在结束环境之前结束环境quotation
,因此出现错误。