Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4130243
  • 博文数量: 626
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 11080
  • 用 户 组: 普通用户
  • 注册时间: 2012-08-23 13:08
文章分类

全部博文(626)

文章存档

2015年(72)

2014年(48)

2013年(506)

分类: 架构设计与优化

2013-09-10 09:30:39

注意:在tex的编写中,如果用到带@的命令,必须把它包含在/makeatletter和/makeatother之间。如果是在宏包中使用,则无需此两个命令。

一、class and package的结构:
1) Identification: 
  1.1)Package files do this as follows:
 /NeedsTeXFormat{LaTeX2e}
 /ProvidesPackage{}[]
For example:
 /NeedsTeXFormat{LaTeX2e}
 /ProvidesPackage{latexsym}[1994/06/01 Standard LaTeX package]
  1.2)Class files do this as follows:
 /NeedsTeXFormat{LaTeX2e}
 /ProvidesClass{}[]
For example:
 /NeedsTeXFormat{LaTeX2e}
 /ProvidesClass{article}[1994/06/01 Standard LaTeX class]
的格式应该是:年/月/日
2) Using classes and packages:
  2.1)A LaTeX package or class can load a package as follows:
 /RequirePackage[]{}[]
For example:
 /RequirePackage{ifthen}[1994/06/01]
  2.2)A LaTeX class can load one other class as follows:
 /LoadClass []{}[]
For example:
 /LoadClass [twocolumn]{article}
  2.3)Simply load a class or package file:
 /LoadClassWithOptions{}[]
 /RequirePackageWithOptions{}[]
For example:
 /LoadClassWithOptions{article}
 /RequirePackageWithOptions{graphics}[1995/12/01]
3) Declaring options:
 /DeclareOption{

二、Commands for class and package writers
1) Identification
/NeedsTeXFormat{}[]
/ProvidesClass{}[]
/ProvidesPackage{}[]

information is displayed by /listfiles and should therefore not be too long.
example:
/ProvidesClass{article}[1994/06/01 v1.0 Standard LaTeX class]
/ProvidesPackage{ifthen}[194/06/01 v1.0 Standard LaTeX package]

/ProvidesFile{}[]
It is used for declaring any files other than main class and package files.
Example:
/ProvidesFile{T1enc.def}[1994/06/01 v1.0 Standard LaTeX file]
2) Loading files
/RequirePackage[]{}[]
/RequirePackageWithOptions{}[release-info>]
This group of commands can be used to create your own document class or package by building on existing classes or packages.
Example:
/RequirePackage{ifthen}[1994/06/01]
/RequirePackageWithOptions{graphics}[1995/12/01]

/LoadClass[]{}[]
/LoadClassWithOptions{}[]

Examples:
/LoadClass{article}[1994/06/01]
/LoadClassWithOptions{article}[1995/12/01]
3) Option declaration
/DeclareOption{}{}
This makes a 'delcared option' of the class or package in which it is put.
The argument contains the code to be executed if that option is specified for the class or package; it can contain any valid LaTeX2e construct.
Example:
/DeclareOption{twoside}{/@twosidetrue}

/DeclareOption*{}
This declares the to be executed for every option which is specified for, but otherwise not explicitly declared by, the class or package; this code is called the 'default option code' and it can contain any valid LaTeX2e construct.
4) Commands within option code
/CurrentOption
This expands to the name of the current option.
/OptionNotUsed
This causes the current option to be added to the list of 'unused options'.
5) Moving options around
/PassOptionsToPackage{}{}
/PassOptionsToClass{}{}
The command /PassOptionsToPackage passes the option names in to package . This means it adds the to the list of options used by any future /RequirePackage or /usepackage command for package .
Example:
/PassOptionsToPackage{foo,bar}{fred}
/RequirePackage[baz]{fred}
is the same as:
/RequirePackage[foo,bar,baz]{fred}
For example:
/LoadClassWithOptions{article}
This should be compared with the slightly different construction.
/DeclareOption*{/PassOptionsToClass{/CurrentOption}{article}}
/ProcessOptions/relax
/LoadClass{article}
If, however, the class declares options of its own then the two constructions are different.
/DeclareOption{landscape}{/@landscapetrue}
/ProcessOptions/relax
/LoadClassWithOptions{article}
with:
/DeclareOption{landscape}{/@landscapetrue}
/DeclareOption*{/PassOptionsToClass{/CurrentOption}{article}}
/ProcessOptions/relax
/LoadClass{article}

6) Delaying code
/AtEndOfClass{}
/AtEndOfPackage{}
These commands declare that is saved away internally and then executed after processing the whole of teh current class or package file.
/AtBeginDocument{}
/AtEndDocument{}
You should include a /clearpage at the appropriate point in .
Permit to repeat use of these commands.
/AtBeginDvi{}

7) Option processing
/ProcessOptions
This command executes the for each selected option.
Local options:
/PassOptionsToPackage{} 
/usepackage[]
/RequirePackage[]
Global options:
are any other options that are specified by the author in the argument of /documentclass[]
For example, suppose that a document begins:
/documentclass[german,twocolumn]{article}
/usepackage{gerhardt}
whilst package gerhardt calls package fred with:
/PassOptionsToPackage{german,dvips,a4paper}{fred}
/RequirePackage[errorshow]{fred}
then:
fred's local options are german, dvips, a4paper and errowshow;
fred's global options is twocolumn.
example:
/DeclareOption{dvips}{/typeout{DVIPS}}
/DeclareOption{german}{/typeout{GERMAN}}
/DeclareOption{french}{/typeout{FRENCH}}
/DeclareOption*{/PackageWarning{fred}{Unknown '/CurrentOption'}}
/ProcessOptions/relax

/ProcessOptions*
/@options
This is like /ProcessOptions but it executes the options in the order specified in the calling commands, rather than in the order of declaration in the class or package. For a package this means that the golbal options are processed first.
The /@options command from LaTeX2.09 has been made equivalent to this in order to ease the task of updating old document styles to LaTeX2e class files.

/ExecuteOptions{}
execute the command /ds@

8) Safe file commands
These commands deal with file input; they ensure that the non-existence of a requested file can be handled in a user-friendly way.
/IfFileExists{}{}{}

/InputIfFileExists{}{}{}

9) Reporting errors, etc.
/ClassError{}{}{}
/PackageError{}{}{}
For example:
/newcommand{/foo}{F00}
/PackageError{ethel}{%
  Your hovercraft is full of eels, /MessageBreak
  and /protect/foo/space is /foo
}{%
  Oh dear! Something's gone wrong. /MessageBreak
  /space /space Try typing /space
  /space to proceed, ignoring /protect/foo.
}

/ClassWarning{}{}
/PackageWarning{}{}
/ClassWarningNoLine{}{}
/PackageWarningNoLine{}{}
/classInfo{}{}
/PackageInfo{}{}
Within the and : /protect can be used to stop a command from expanding; /MessageBreak causes a line-break; and /space prints a space. Also, these should not end with a full stop as on eis automatically added.

10) Defining commands
/DeclareRobustCommand{}[][]{}
/DeclareRobustCommand*{}[][]{}
This command takes the same arguments as /newcommand but it declares a robust command, even if some code within the is fragile. You can use this command to define new robust commands, or to redefine existing commands and make them robust. A log is put into the transcript file if a command is redefined.
For example:
/DeclareRobustCommand{/seq}[2][n]{%
 /ifmmode
   #1_{1}/ldots#1_{#2}%
 /else
   /PackageWarning{fred}{You can't use /protect/seq/space in text}%
 /fi
}
for example:
/section{Stuff about sequences $/seq{x}$}

/CheckCommand{}[][]{}
/CheckCommand*{}[][]{}

11) Moving arguments
The setting of protect whilst processing moving arguments has been reimplemented, as has the method of writing information from the .aux file to other files such as the .toc file. Details can be found in the file ltdefns.dtx.

三、Miscellaneous commands
1) Layout parameters
/paperheight
/paperwidth
2) Case changing
/MakeUppercase{}
/MakeLowercase{}
3) The 'openany' option in the 'book' class
The openany option allows chapter and similar openings to occur on left hand pages. Previously this option affected only /chapter and /backmatter. It now also affects /part, /frontmatter and /mainmatter.
4) Better user-defined math display environments
/ignorespacesafterend
Suppose that you want to define an environment for displaying text that is numbered as an equation. A straightforward way to do this is as follows:
/newenvironment{texteqn}
 {/begin{equation}
   /begin{minipage}{0.9/linewidth}}
 {/end{minipage}
   /end{equation}}
For example:
/newenvironment{texteqn}
 {/begin{equation}
  /begin{minipage}{0.9/linewidth}}
 {/end{minipage}
  /end{equation}
  /ignorespacesafterend}

5) Normalising spacing
/normailsfcodes
This command should be used to restore the normal settings of the parameters that affect spacing between words, sentences, etc.

四、Upgrading LaTeX2.09 classes and packages
1) Try it first
test your style in 'compatibility mode'.
2) Troubleshooting
3) Accommodating compatibility mode
accommodate old edition
/if@compatibility
 
/else
 
/fi

4) Font commands
Some font and size commands are now defined by the document class.
/newcommand{/rm}{/rmfamily}
/newcommand{/sc}{/scshape}
Another possible definition is:
/DeclareOldFontCommand{/rm}{/rmfamily}{/mathrm}
/DeclareOldFontCommand{/sc}{/scshape}{/mathsc}

/normalsize
/@normalsize

5)Obsolete commands
Some packages will not work with LaTeX2e, normally because they relied on an internal LaTeX command which was never supported and has now changed, or been removed.

阅读(2594) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~