如何使用 LaTeX3 為套件建立樣板 dtx 檔案(類似 LaTeX2e 的 dtxgen)

如何使用 LaTeX3 為套件建立樣板 dtx 檔案(類似 LaTeX2e 的 dtxgen)

我有興趣使用 LaTeX3 製作一個包,但我無法 (a) 找到有關如何為其生成新 dtx 文件的文檔,或者 (b) 找到用於使用 LaTeX3 為包創建 dtx 文件的模板(可能是使用l3doc)。

是否有dtxgen適用於 LaTeX3 軟體包的實用程式(例如 LaTeX2e)或範本?


我所追求的事物的例子。

當製作 LaTeX 包(例如mynewpackage)時,我的第一步通常是運行

$ dtxgen mynewpackage.sty

這會建立一個Makefileand mynewpackage.dtx(以及其他檔案)。預設情況下,這使用 docstrip 並使用文件類別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舉個例子。

相關內容