
我有興趣使用 LaTeX3 製作一個包,但我無法 (a) 找到有關如何為其生成新 dtx 文件的文檔,或者 (b) 找到用於使用 LaTeX3 為包創建 dtx 文件的模板(可能是使用l3doc
)。
是否有dtxgen
適用於 LaTeX3 軟體包的實用程式(例如 LaTeX2e)或範本?
我所追求的事物的例子。
當製作 LaTeX 包(例如mynewpackage
)時,我的第一步通常是運行
$ dtxgen mynewpackage.sty
這會建立一個Makefile
and mynewpackage.dtx
(以及其他檔案)。預設情況下,這使用 docstrip 並使用文件類別ltxdoc
。這兩個都很好,但 LaTeX3 引入了一些更改,包括:
- 使用 來
l3docstrip
引入新功能,例如@@
被替換為__<module name>
(來自expl3.pdf
fromhttps://www.ctan.org/pkg/l3kernel) - 使用
\ProvidesExplPackage
而不是\ProvidesPackage
(來自使用 LaTeX2e 或 LaTeX3 編寫新包) - 使用
l3doc
類別代替ltxdoc
(似乎很有意義,因為它支援清楚地記錄 LaTeX3 函數)
目前,我無法找到啟用完整的 LaTeX3 支援而應進行的所有變更的完整參考。
是否有一個腳本可以產生初始 dtx 文件,其中包含 LaTeX3 的所有建議更改和/或記錄所有必要更改的位置?
答案1
我建議使用一個簡單的結構,其中:
- 一個或多個
.dtx
文件 - 一個
.ins
文件 README.md
- 一份
CHANGELOG.ms
文件(參見https://keepachangelog.com/en/1.0.0/) - (可能)
LICENSE
作為 LPPL 的副本(用於例如GitHub)
對於較大的包裝
- 單獨的
.tex
使用者文檔 - (如果使用多個
.dtx
文件).tex
將所有程式碼文件合併到一個 PDF 中的文件
採用該模型,.dtx
我建議如下
% \iffalse meta-comment
%
% File: <NAME>.dtx Copyright (C) <YYYY> <AUTHOR>
%
% It may be distributed and/or modified under the conditions of the
% LaTeX Project Public License (LPPL), either version 1.3c of this
% license or (at your option) any later version. The latest version
% of this license is in the file
%
% https://www.latex-project.org/lppl.txt
%
% This file is part of the "<NAME> bundle" (The Work in LPPL)
% and all files in that bundle must be distributed together.
%
% The released version of this bundle is available from CTAN.
%
% -----------------------------------------------------------------------
%
% The development version of the bundle can be found at
%
% <SOURCE REPO>
%
% for those people who are interested.
%
% -----------------------------------------------------------------------
%
%<*driver>
\documentclass{l3doc}
% The next line is needed so that \GetFileInfo will be able to pick up
% version data
\usepackage{<NAME>}
\begin{document}
\DocInput{\jobname.dtx}
\end{document}
%</driver>
% \fi
%
% \GetFileInfo{<NAME>.sty}
%
% \title{^^A
% \pkg{<NAME>} -- <DESCRIPTION>^^A
% \thanks{This file describes \fileversion,
% last revised \filedate.}^^A
% }
%
% \author{^^A
% <AUTHOR>^^A
% \thanks{^^A
% E-mail:
% \href{mailto:<EMAIL>}
% {<EMAIL>}^^A
% }^^A
% }
%
% \date{Released \filedate}
%
% \maketitle
%
% \begin{documentation}
%
% \end{documentation}
%
% \begin{implementation}
%
% \section{\pkg{<NAME>} implementation}
%
% Start the \pkg{DocStrip} guards.
% \begin{macrocode}
%<*package>
% \end{macrocode}
%
% Identify the internal prefix (\LaTeX3 \pkg{DocStrip} convention).
% \begin{macrocode}
%<@@=<PREFIX>>
% \end{macrocode}
%
% \subsection{Initial set up}
%
% Load the essential support (\pkg{expl3}) \enquote{up-front}.
% \begin{macrocode}
\RequirePackage{expl3}
% \end{macrocode}
%
% Make sure that the version of \pkg{l3kernel} in use is sufficiently new.
% \begin{macrocode}
\@ifpackagelater {expl3}{<MINIMUM DATE>}
{}
{%
\PackageError {<NAME>} {Support package expl3 too old}
{%
You need to update your installation of the bundles 'l3kernel' and
'l3packages'.\MessageBreak
Loading~<NAME>~will~abort!%
}%
\endinput
}%
% \end{macrocode}
%
% Identify the package and give the over all version information.
% \begin{macrocode}
\ProvidesExplPackage {<NAME>} {<DATE>} {<VERSION>}
{<DESCRIPTION>}
% \end{macrocode}
%
% \begin{macrocode}
%</package>
% \end{macrocode}
%
% \end{implementation}
%
% \PrintIndex
在上面,我假設我們有一個原始檔案(一個較小的套件):較大的分割將expl3
只載入一次。
同樣,對於更大的來源,我會將@@
約定分成幾個子部分,以便每個部分.dtx
都是獨立的。請參閱範例https://github.com/josephwright/siunitx舉個例子。