自己动手写latex宏包

自己动手写latex宏包

2023年7月18日发(作者:)

⾃⼰动⼿写latex宏包写⼀个宏包的基本⼯作就是将你原本很长的⽂档导⾔拷贝到⼀个分离的⽂件中去,这个⽂件需要以 .sty 结尾,⽂件中需要使⽤⼀个专⽤的命令:ProvidesPackage{package name}这个命令应该在宏包⽂件起始处使⽤,⽤于声明 LaTeX 宏包的名称,当⽤户尝试两次引⼊同⼀个宏包时,ProvidesPackage 命令会给出宏包重复引⽤的错误信息。哪些内容应当放⼊宏包⽂件中呢?当然是你的⼤多数 LaTeX ⽂档都要⽤到宏包、⾃定制的排版命令,把这些东西丢到宏包⾥,就可以实现复⽤。宏包使⽤得当,可以避免很多繁琐的输⼊与排版命令的记忆。下⾯是我基于⾃⼰的排版习惯定制的⼀个宏包,仅供初学者参考:% lyanry book style packageProvidesPackage{lyrbook}% 设定页边距usepackage[top=1.1in,bottom=1.1in,left=1.25in,right=1in]{ geometry}% 加载 ams 数学公式与数学字体宏包usepackage{amsmath, amsfonts}% 有时要⽤ PGF/TikZ 绘制⼀些图usepackage{tikz}usetikzlibrary{trees,shapes,snakes,arrows,backgrounds}% 加载 CJK 相关宏包,并设置中⽂字体usepackage{CJKutf8, CJKnumb, CJKpunct}newcommand{lyrtitle}{ CJKfamily{yahei}}newcommand{lyrem}{ CJKfamily{yahei}}% 设置中⽂段落⾸⾏缩进与段落间距usepackage{indentfirst}setlength{parindent}{2em }setlength{parskip}{0pt }% 设置⾏间距renewcommand{baselinestretch }{1.2}% 设置页眉页脚usepackage{fancyhdr}pagestyle{fancy}renewcommand{chaptermark}[ 1]{markboth{small 第,thechapter ,章quad #1}{}}renewcommand{sectionmark}[ 1]{markright{smallthesection quad #1}{}}fancyhf{}fancyhead[ER]{ leftmark}fancyhead[OL]{ rightmark}fancyhead[EL,OR]{ $cdot$,thepage,$cdot$ }renewcommand{headrulewidth}{ 0.4pt}headheight=16pt

%------------------------------------------% 以下是为符合中⽂阅读习惯⽽重新定制的命令

%------------------------------------------% 设定章节标题格式usepackage{titlesec}titleformat{chapter}{ centeringLARGElyrtitle}{第, CJKnumber{thechapter},章}{1em}{}titleformat{section}{ largelyrtitle}{thesection}{1em}{}titleformat{subsection}{ normalsizelyrtitle}{thesubsection}{1em}{}% 设定表格、插图等元素的标题usepackage[small, center]{caption2 }renewcommand{captionlabeldelim }{~} %将图⽚标题后的冒号替换为空格

发布者:admin,转转请注明出处:http://www.yc00.com/xiaochengxu/1689641674a273141.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信