SUMMARY OF CTEX LEARNING -- CTEX小结(.cls与.sty文件的编写)

1. How to write .cls & .sty file:

1.1 Difference between CLASS file and STYLE file in CTEX:

Class file (.cls) is used to define document classes with definitions of page margin, document style, and various options that user can pass to the class to configure the structure of this kind of document. For instance, the built-in classes include article, book, report, etc.

Style file (.sty) is used to define a kind of style, such as the font and size of book title, title of each section and subsection, the space between lines.

The golden rule you should obey to decide whether it should be a class or a style goes as follows:

If the commands could be used with any document class, then make
them a package; and if not, then make them a class.
— Quoted from book: LATEX2E FOR CLASS AND PACKAGE WRITERS

1.2 How to write a CLASS

The class file composed of mainly four sections: Identification, Resources Required, Option Declaration, and Style definition.

1.2.1 Identification

Identification is used as an ID for the class you are about to compose.
the very command used here is:
\ProvidesPackage {package_name} [<date> <introduction>]

e.g. \ProvidesPackage{digilentTrans}[2010/06/09 Translation Template]

1.2.2 Load a Package

We can use function “\RequirePackage” to load a style package or use “\LoadClass” to load a class file.
\documentclass is also available here, so that we can refer to external files for document properties.

1.2.3 Option Declaration

It is recommended to use function “\DeclareOption [option_name] {function}”
Here, we can specify the function when certain option is passed to this class. Moreover, we may pass the option to the class package we are about to load. The function “\PassOptionsToClass” helps in this situation.

We may use \DeclareOption* to define the default behavior when certain option is passed onto this class.

1.2.4 Style Definition

Style definition usually means define or redefine a series of macros to modify the character, paragraph, document attributes. We may redefine “\title” function to change the position, font, style, size, color, etc. of the title.

If the command is new, it is recommended to use “\newcommand [command_name] [<num>] {function}”
where <num> is the number of parameters the command can take. In “function” part, “#1” stands for the first variable, “#2” the second, and so on. if the command has been defined in the package included or by default, we should use \renewcommand. If we want to access the old command in renewed command, we should write “\gdef \@command_name \par”

2. Problems concerning Chinese characters in CTEX

2.1 Commands of CTEX

CTeX is the package that support Chinese characters. You may type “$ ctex” under command line to see the options.

It is better to use “-pdflatexmx” while using chinese characters, as italic style is not available for chinese characters if you use other options.

2.2 Chinese Characters

CTeX includes a package for chinese characters called “CJK”. There are other packages for Chinese characters, while CJK is the one commonly used and is default in CTeX classes.

To use a CJK package, you should first include CJK in your .tex file as follows:
\include {CJK}

To use CJK font in document, before the text you may write:
\begin {CJK*} {GBK} {song}

This command stands for using CJK package GBK character map, font SongTi.
in GBK, the following fonts are available: song – SongTi, hei – HeiTi, kai – KaiTi, fs – FangSong.

We can use GB instead of BGK. Here we have more fonts:
gcfang – FangSong, gckai – KaiTi, gchei – HeiTi, gcsong – SongTi, gcwei – WeiBei, gchw – ZongYi, gcdls – LiShu.

\bfseries stands for bold style, \textsl stands for italic style.

2.3 CTEX classes

CTEX provides several document classes that support Chinese Language. ctexart is the article class with chinese support, ctexbook is the book class with Chinese support, ctexreport is the report class with chinese support. It is more convenient to use these classes while writing chinese documents. the reference for CTeX can be found at
http://ctex-kit.googlecode.com/files/ctex.pdf

(Please include a link to this page while coping this article to other website or forum, Thanks!)

 

Advertisements

破窑赋 [吕蒙正]

天有不测风云,人有旦夕祸福。
蜈蚣百足,行不及蛇;
家鸡翼大,飞不如鸟。
马有千里之程,无人不能自往。
人有凌云之志,非运不能腾达。

文章盖世,孔子尚困于陈邦。
武略超群,太公垂钓于渭水。
盗跖年长,不是善良之辈。
颜回命短,实非凶恶之徒。
尧舜至圣,却生不肖之子。
瞽叟顽呆,反生大圣之儿。
张良原是布衣,
萧何称谓县吏。
晏子身无五尺,封为齐国首相。
孔明居卧草庐,能作蜀汉军师。
韩信无缚鸡之力,封为汉朝大将。
冯唐有安邦之志,到老半官无封。
李广有射虎之威,终身不第。
楚王虽雄,难免乌江自刎;
汉王虽弱,却有河山万里。
满腹经纶,白发不第;
才疏学浅,少年登科。

有先富而后贫,有先贫而后富。
蛟龙未遇,潜身于鱼虾之间。
君子失时,拱手于小人之下。
天不得时,日月无光;
地不得时,草木不长;
水不得时,风浪不平;
人不得时,利运不通。

昔时也,余在洛阳,日投僧院,夜宿寒窑。
布衣不能遮其体,淡粥不能充其饥。
上人憎,下人厌,皆言余之贱也!

余曰:非吾贱也,乃时也,运也,命也。

余及第登科,官至极品,位列三公,
有挞百僚之杖,有斩鄙吝之剑,
出则壮士执鞭,入则佳人捧秧,
思衣则有绫罗锦缎,
思食则有山珍海味,
上人宠,下人拥,
人皆仰慕,言余之贵也!

余曰:非吾贵也,乃时也,运也,命也。

盖人生在世,富贵不可捧,贫贱不可欺,
此乃天地循环,终而复始者也。

《写在人生边上》

最近为了交20世纪名著选讲这门通选课的文章,一直埋首于钱钟书的这本“写在人生边上”之中。
钱先生的围城记得在中学课外阅读的书目上出现过,不过过去没去读什么……
最近读了钱先的这本很薄的集子,不禁有不少感触,便想把它放在这个空间上,以兹大家分享。
也请读了的朋友多多少少留些痕迹下来,在此先谢了。