bye,this year.

微笑
### 创建和使用 LaTeX `.dtx` 文档类文件 #### .dtx 文件概述 `.dtx` 是一种文档化的 TeX 文件,它不仅包含了宏定义还提供了这些宏的说明文字。这种格式允许作者在同一份文件中同时提供代码实现及其解释[^2]。 #### 创建 DTX 文件结构 要创建一个新的 `.dtx` 文件,可以按照以下模板来构建: ```tex % \iffalse meta-comment % % Copyright (C) YEAR by AUTHOR % This file may be distributed and/or modified under the conditions of % the LaTeX Project Public License, either version 1.3c of this license or % any later version. % % The latest version of this license is in: % % http://www.latex-project.org/lppl.txt % % and version 1.3c or later is part of all distributions of LaTeX version % 2008/05/04 or later. % % \fi % % \iffalse \def\fileversion{v1.0} \def\filedate{\number\year/\two@digits\month/\two@digits\day} \begingroup \input docstrip.tex \keepsilent \nopreamble\nopostamble \usedir{tex/latex/mypackage} \generate{ \file{\jobname.sty}{\from{\jobname.dtx}{package}} } \endgroup \bye % \fi % %<*driver> \documentclass{ltxdoc} \usepackage{\jobname}[<DATE>] \EnableCrossrefs \CodelineIndex \RecordChanges \begin{document} \DocInput{\jobname.dtx} \end{document} %</driver> %\fi % % \title{^^A % \textsf{\filename}\thanks{This package has version number \fileversion{} dated \filedate}}^^A % \author{Author Name\\Email Address} % \date{\today} % \maketitle % % \changes{v1.0}{YYYY/MM/DD}{Initial release} % % \section{Introduction} % Introduction text here... % % \StopEventually{} % % \section{Implementation} % Implementation details go here... % % \begin{macrocode} %<*package> % Your code goes here %</package> % \end{macrocode} % % \Finale \PrintChanges \PrintIndex ``` 此模板分为几个部分: - **版权声明**:描述分发条件。 - **DocStrip 配置**:用于生成 `.sty` 文件的部分。 - **驱动程序代码**:这部分用来编译文档本身。 - **正文内容**:包括介绍、变化记录以及实际的宏定义。 #### 使用 DTX 文件 为了从 `.dtx` 文件中提取出可用的 `.sty` 文件并生成文档,执行下列命令: 对于 Windows 用户,在命令提示符下输入: ```cmd pdflatex mypackage.ins pdflatex mypackage.dtx makeindex -s gind.ist mypackage.idx makeindex -o mypackage.gls mypackage.glo pdflatex mypackage.dtx ``` 对于 Linux 或 macOS 用户,在终端窗口中运行相同的指令序列即可。 上述过程将完成两个主要任务: 1. `mypackage.ins` 被处理后会产生所需的 `.sty` 文件; 2. 编译 `.dtx` 文件两次以确保索引正确无误,并且交叉引用完全解析完毕。 通过这种方式,既可以获得功能性的宏包又能够获得详细的文档说明。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值