概述
什么是.cls
和.sty
文件?它们的区别是什么?
What are
.cls
and.sty
files? How are they different?
通常来讲,.cls
和.sty
文件是用于增强LaTeX功能的附带文件。它们分别通过documentclass{...}
和 usepackage{...}
命令进行加载。我们通常称.cls
文件为“类文件”,.sty
文件为“样式文件”(或者“包文件”)。
In general,
.cls
and.sty
files are supplementary files that increases the functionality of LaTeX. They are the files loaded with thedocumentclass{...}
andusepackage{...}
commands, respectively. We generally call.cls
files ‘classes’, and.sty
files ‘style files’, of often just ‘packages’.
它们(.cls
和.sty
)都可以包含在任意的TEX
和LATEX
代码中,但是它们使用两种不同的方法。加载类文件
强制使用documentclass
命令,在一个LATEX文档中只加载一个类文件
,通常这个命令出现在文档的开始。另一方面,包含包文件
是一个可选的选项,可以根据用户的需求加载任意数量的包文件
(在文档本身开始之前加载包文件
)。
They both may contain arbitrary TEX and LATEX code, but they are used in separate ways. Loading a class via
documentclass
is mandatory, and may only appear once in a LATEX document; usually, it is the very first command. On the other hand, packages are optional and as many of them may be loaded as one could wish (prior to the beginning of the document itself).
在理想的样例中,一个类文件
定义了整个文档的结构。article
类就是一个很好的例子,这个类定义了排版的文章需要的命令,包括section
,tableofcontents
和authorand
等等。
In the ideal case, a class file will completely define the structure of the document. The familiararticle
class is a good example: it provides commands for typesetting articles, such assection
,tableofcontents
,authorand
so on.
包文件
,或者也叫做样式文件
,是用来提供任何类文件
不能提供的命令的。主要分为两大类:一是对类文件
的修正,或者为类文件
添加附加功能。例如:graphicx
包提供了在文档中添加图片和对文档中各种元素应用各种图形效果的方法。这种包文件
将会与任意的类文件
搭配生效。
Packages, or style files, are then used to provide anything else that the class doesn’t accommodate. These fall into two broad categories: amendments to the class file, or additional functionality. For example, the graphicx package provides methods to include images and apply all manner of graphical effects to elements in a document. This package will work with essentially any class file.
另一类型的包文件
,例如sectsty
包,提供了一些方法用于自定义化LATEX类中的section
样式。例如,假如使用memoir
类,然后再使用sectsty
包,就会重写memoir
中的section
样式,这可能会导致文档样式的冲突。
On the other hand, the
sectsty
package provides methods to customise the section headers in the default LATEX classes (article, report, or book). So, trying to use it with thememoir
class, say, will result in it over writingmemoir
’s method of creating section headers, and calamity will ensue.
总结来讲,.cls
和.sty
文件是LATEX用来提供或者改进文档功能的文件。通常来讲,类文件
提供文档的结构,包文件
用于提供适用于任意类的通用功能,或者用于“样式化”特定类中提供的方法。
To summarise,
.cls
and.sty
files are loaded by LATEX to provide and improve methods that are used to create documents. Generally speaking, class files implement the specific structure of the document, whereas packages are used to provide either generic functionality to any document, or to ‘style’ the methods provided by a specific class.
原文:What are.clsand.styfiles? How are they different?
最后
以上就是糟糕宝贝为你收集整理的[LaTeX|翻译]What are .cls and .sty files? How are they different?的全部内容,希望文章能够帮你解决[LaTeX|翻译]What are .cls and .sty files? How are they different?所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复