How to write LaTeX package

5,750 views

Published on

如何编写LaTeX宏包

0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
5,750
On SlideShare
0
From Embeds
0
Number of Embeds
35
Actions
Shares
0
Downloads
117
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

How to write LaTeX package

  1. 1. L TEX A LittleLeo@newsmth 2007.9.27
  2. 2. L TEX A ThuThesis
  3. 3. TEX TEX Anti MS
  4. 4.
  5. 5.
  6. 6. ♣ author{ } ♣ title{ }
  7. 7. ♣ author{ } ♣ title{ } ♣ defchapter#1{cleardoublepageheisanhao #1}
  8. 8. The TEXbook, The L TEX Companion, TEX for the Impatient A
  9. 9. The TEXbook, The L TEX Companion, TEX for the Impatient A L TEX2ε for class and package writers A
  10. 10. The TEXbook, The L TEX Companion, TEX for the Impatient A L TEX2ε for class and package writers A L TEX A
  11. 11. The TEXbook, The L TEX Companion, TEX for the Impatient A L TEX2ε for class and package writers A L TEX A TEX L TEX A
  12. 12. The TEXbook, The L TEX Companion, TEX for the Impatient A L TEX2ε for class and package writers A L TEX A TEX L TEX A
  13. 13. The TEXbook, The L TEX Companion, TEX for the Impatient A L TEX2ε for class and package writers A L TEX A TEX L TEX A comp.text.tex
  14. 14. The TEXbook, The L TEX Companion, TEX for the Impatient A L TEX2ε for class and package writers A L TEX A TEX L TEX A comp.text.tex Google
  15. 15. The TEXbook, The L TEX Companion, TEX for the Impatient A L TEX2ε for class and package writers A L TEX A TEX L TEX A comp.text.tex Google
  16. 16. TEX L TEX A ♣ ♣ ♣ aux/bbl ♣ latex
  17. 17. TEX L TEX A ♣ ♣ ♣ aux/bbl ♣ latex newif, ifcondition, show, par, csname, endcsname, hbox, hskip, vbox, vskip, hrule, vrule, hspace, parbox, minipage, fontsize, clearpage, cleardoublepage, pagestyle, setlength, addtolength, AtBeginDocument, AtEndDocument, ......
  18. 18. (2) ♣ def def, let, newcommand, renewcommand ♣ if ifx, ifnum, @ifnextchar ♣ expand expandafter, noexpand ♣ relax, empty
  19. 19. (2) ♣ def def, let, newcommand, renewcommand ♣ if ifx, ifnum, @ifnextchar ♣ expand expandafter, noexpand ♣ relax, empty L TEX A ♣ m@ne, z@, @ne, @tempa ♣ hb@x, hb@xt@, @namedef, @nameuse ♣ fnum@type, ext@type, l@type ♣ ps@type, c@counter
  20. 20. L TEX A author defauthor#1{def@author{#1}}
  21. 21. L TEX A author defauthor#1{def@author{#1}} @ifnextchar defchapter{ @ifnextchar * {@chapter[]}{@chapter}} def@chapter[#1]#2{% ifopenrightcleardoublepageelseclearpagefi begingroup heisan #2 endgroupvskip20pt addcontentsline{toc}{#1}}
  22. 22. L TEX A (2) letoldcmd=cmd defcmd#1{precmdoldcmd#1postcmd}
  23. 23. L TEX A (2) letoldcmd=cmd defcmd#1{precmdoldcmd#1postcmd} newenvironment{envname} {begin code} {end code} defenvname{begin code} % begin{envname} defendenvname{end code} % end{envname} defbegin#1{csname #1endcsname} defend#1{csname end#1endcsname}
  24. 24. newlengththu@linespace newcommand{thu@choosefont}[2]{% setlength{thu@linespace}{#2*real{#1}}% fontsize{#2}{thu@linespace}selectfont} defthu@define@fontsize#1#2{% expandafternewcommandcsname #1endcsname[1][baselinestretch]{% thu@choosefont{##1}{#2}}} thu@define@fontsize{chuhao}{42bp}
  25. 25. (2) defps@thu@headings{% def@oddhead{vbox toheadheight{% hb@xt@textwidth{% hfillwuhaosongleftmarkifthu@bachelorrelaxelsehfillfi} vskip2pthbox{vrule widthtextwidth height0.4pt depth0pt}}} def@evenhead{vbox toheadheight{% hb@xt@textwidth{wuhaosong% ifthu@bachelorthu@schoolenamethu@bachelor@subtitle% elsehfillleftmarkfihfill}% vskip2pthbox{vrule widthtextwidth height0.4pt depth0pt}}} def@oddfoot{hfilwuhaothepagehfil} let@evenfoot=@oddfoot} pagestyle{thu@headings}
  26. 26. (3) RequirePackage{paralist} defthu@item@space{% letitemizecompactitem letenditemizeendcompactitem letenumeratecompactenum letendenumerateendcompactenum letdescriptioncompactdesc letenddescriptionendcompactdesc} AtBeginDocument{thu@item@space}
  27. 27. (4) defthu@define@term#1{ expandaftergdefcsname #1endcsname##1{% expandaftergdefcsname thu@#1endcsname{##1}} csname #1endcsname{}} thu@define@term{cauthor} % gdefcauthor#1{gdefthu@cauthor{#1}}
  28. 28. (5) defthu@parse@keywords#1{ expandaftergdefcsname thu@#1endcsname{} % todo: need or not? expandaftergdefcsname #1endcsname##1{ @forreserved@a:=##1do{ expandafterifxcsname thu@#1endcsname@emptyelse expandafterg@addto@macrocsname thu@#1endcsname{% ignorespacescsname thu@#1@separatorendcsname} fi expandafterexpandafterexpandafterg@addto@macro% expandaftercsname thu@#1expandafterendcsname% expandafter{reserved@a}}}} thu@parse@keywords{ckeywords} thu@parse@keywords{ekeywords} % ekeywords{LaTeX, thesis, fault tolerance}
  29. 29. (6) newenvironment{denotation}[1][2.5cm]{ thu@chapter*[]{thu@denotation@name} % no tocline noindentbegin{list}{}% {vskip-30bpxiaosi[1.6] renewcommandmakelabel[1]{##1hfil} setlength{labelwidth}{#1} % label box width setlength{labelsep}{0.5cm} % label to text setlength{itemindent}{0cm} % label indent setlength{leftmargin}{labelwidth+labelsep} % left margin setlength{rightmargin}{0cm} setlength{parsep}{0cm} % setlength{itemsep}{0cm} % label vspace setlength{listparindent}{0cm} % parindent from the second par setlength{topsep}{0pt} % vskip to top text }}{end{list}}
  30. 30. L TEX A
  31. 31. L TEX A class: documentclass{thuthesis} style: usepackage{thutils}
  32. 32. [ ] NeedsTeXFormat{LaTeX2e}[1999/12/01] ProvidesClass{thuthesis} [2007/05/13 3.0 Tsinghua University Thesis Template] %ProvidesPackage{thutils} % [2007/05/13 3.0 Tsinghua University Thesis Template] % code body endinput
  33. 33. L TEX A %% %% Minimal LaTeX class file. %% NeedsTeXFormat{LaTeX2e} ProvidesClass{minimal}[2001/05/25 Standard LaTeX minimal class] renewcommandnormalsize{fontsize{10pt}{12pt}selectfont} setlength{textwidth}{6.5in} setlength{textheight}{8in} pagenumbering{arabic} % but no page numbers are printed because: pagestyle{empty} % this is actually already in the kernel
  34. 34. ♣ How to Package Your L TEX Package A ♣ The Docstrip Program ♣ The doc and shortvrb Packages ♣
  35. 35. ♣ ♣ ♣ Emacs+AucTEX+RefTEX+CDLTX
  36. 36. ThuThesis
  37. 37. CJK Doc http://thuthesis.sf.net
  38. 38. thuthesis.ins, thuthesis.dtx, thubib.bst thuthesis.pdf
  39. 39. 1 1 5.3 . . . . . . . . . . . . 20 5.4 . . . . . . . . . . . 22 2 1 5.4.1 Three matters . . . . . . 22 2.1 . . . . . . . . . . . . . . . 1 5.4.2 . . . . . . . . . . 23 2.2 . . . . . . . . 2 5.4.3 . . . . . . . . 25 2.3 . . . . . . . . . . . . 3 5.4.4 . . . . . . . . 26 2.4 . . . . . . . . . . . . 3 5.4.5 . . . . . . . . . . 27 2.4.1 dvi→ps→pdf . . . . . . 4 5.4.6 . . . . . . . . . . 28 2.4.2 dvipdfm(x) . . . . . . . 4 5.4.7 . . . . . . . . 29 2.4.3 pdflatex . . . . . . . . . 4 5.4.8 . . 31 2.4.4 . . . . . . 5 5.4.9 . . . . . 32 2.5 . . . . . . . . . . . . . . . 6 5.4.10 . . . . . . . . 33 3 6 5.4.11 . . . . . . . . 36 3.1 . . . . . . . . . . . . 6 5.4.12 . . . . . . 37 3.2 TT . . . . . . 6 5.4.13 . . . . . . . . 44 3.3 TT . . . . . . 7 5.4.14 . . . . . . 45 3.4 . . . . . . . . . . . . . . . 8 5.4.15 . . . . . 46 3.5 . . . . . . . . . . . . . . . 9 5.4.16 . . . . . . . . 47 3.5.1 . . . . . 10 5.4.17 . . . . . . . . 48 3.5.2 . . . . . . . . 12 5.4.18 . . . . . . . . . . 49 3.5.3 . . . . . . . . 14 5.4.19 . . . . . . . . 49 3.6 . . . . . . . . . . . . 16 5.4.20 . . . . . . . . . . 50 3.7 . . . . . . . . 17 5.4.21 . . . . . . . . . . 51 5.4.22 . . 51 4 17 5.4.23 . . . . . . . . . . 52 5 19 53 5.1 . . . . . . . . . . . . 19 5.2 . . . . . . . . . . . . 19 57
  40. 40. bst XETEX
  41. 41. bst XETEX
  42. 42. L TEX A (1) begin{document} vspace*{0.5cm} vspace begin{center} begin {zihao heiti {huge bf LaSalle} 定理及其在稳定性分析中的应用{huge $^*$}}[0.7cm] zihao zihao{2}heiti huge huge ^ zihao{4} 无名氏qquad {large $^dagger zihao {zihao ^dagger qquad large ^dagger$}}[0.2cm] {zihao ( 山 东 大 学 控 制 科 学 与 工 程 学 院 ~~~ 山 东 济 南 quad 邮 编 :~{footnotesize tt zihao zihao{6} footnotesize 250061})}[0.1cm] end{center} end begin begin{table}[b] begin{tabular}{l} begin rule[0.2ex]{5cm}{0.1mm} rule textwidth parbox[t]{0.95textwidth parbox textwidth}{ baselineskip setlength{baselineskip baselineskip zihao setlength baselineskip}{0.8baselineskip {zihao baselineskip}} zihao{6} hspace{-2mm}{small $^*$}本研究得到国家自然科学基金资助(批准号:~{{ hspace small ^ footnotesize }})和山东省科技发展计划资助(批准号:~{{ footnotesize }}).}[-1.5mm] zihao {zihao hspace zihao{6},,,,hspace small ^dagger$}联系人:~heiti }: 山东大学, 控制科学与 ^dagger hspace{-2mm}{{small $^dagger heiti 工程学院(邮编: {footnotesize footnotesize footnotesize250061},~电话:~{ footnotesize {tt 0111-1234?678}}, tt 电子邮箱:~{footnotesize {tt lygfr@sdu.edu.cn}}).}[-1.5mm] {,,,zihao footnotesize tt zihao{6}{heiti 无名氏}的 zihao heiti 电子邮箱:~footnotesize {tt wumingshi@126.com.}} footnotesize tt end end{tabular} end{table} end
  43. 43. L TEX A (2) Large {Large zihao Large1~~~zihao zihao{4}引~~言} vskip vskip3mm 系统理论中最基本的问题是动态系统的稳定性.对非线性动态系统的稳定性分析有最大 贡献的应属Lyapunov[ ].Lyapunov定理及Barbashin-Krasovskii-LaSalle 不变集原理 [5mm] Large {Large zihao{4}LaSalle 定理} zihao Large2~~~zihao vskip3mm vskip 首先给出如下两个定义. {heitibf 定义,1}~{kaishu 如果系统,dref heiti heitibf kaishu dref dref{eq.sys},的解,$x(t)$,起始于,$ M$,并始终在 dref ,$M$,内,~那么称,$M$,为系统,dref dref{eq.sys},的不变集.} [5mm] Large {Large zihao{4}LaSalle 定理的推广} zihao Large3~~~zihao vskip3mm vskip
  44. 44. — —
  45. 45. — — —
  46. 46. — Word Word TEX Word TEX Word TEX
  47. 47. Thank you! Institute of Structural Mechanics, CAEP, P.O.Box Address: 919-414, Mianyang, Sichuan, China, 621900 E_mail: qlx1205@263.net & qian_lixin@sohu.com 08162485474(O), 08162482055(H), Tel: 13981148905(M) Fax: 08162281485 Ruini Xue

×