doctex 模板中有多个版权信息

doctex 模板中有多个版权信息

我刚刚意识到我的 DocTeX 模板中有三个版权部分???我试图合并从德图作者:Scott Pakin,模型 DTX 文件由约瑟夫·赖特(Joseph Wrights)提出。

% ^^A Read Me and Copyright
%
% \iffalse meta-comment
% !TEX program = pdfLaTeX
%
%<*internal>
\iffalse
%</internal>
%<*readme>
----------------------------------------------------------------------
Package : <PACKAGE>
Author  : <AUTHOR>
E-Mail  : <E-MAIL>
Licence : LaTeX Project Public Licence (LPPL) v1.2 or later
          (See https://www.latex-project.org/lppl.txt)
----------------------------------------------------------------------

A LaTeX package providing a style/class file for use in ones documentation.

%</readme>
%<*internal>
\fi
%</internal>
%
% Copyright (C) 2019 by <AUTHOR> <<E_MAIL>>
% -----------------------------------------
%
% This file may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.2 of this license or (at your option) any later
% version. The latest version of this license is in:
%
% http://www.latex-project.org/lppl.txt
%
% and version 1.2 or later is part of all distributions 
% of LaTeX version 1999/12/01 or later.
%
% \fi

后来,我又重复了同样的事情不下两次。

% \iffalse
%
% ^^A Package Installation
%
%<*batchfile>
\begingroup
%%
%% Copyright (C) 2019 by <AUTHOR> <<E_MAIL>>
%%
%% This file may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.2 of this license or (at your option) any later
%% version. The latest version of this license is in:
%%
%% http://www.latex-project.org/lppl.txt
%%
%% and version 1.2 or later is part of all distributions of
%% LaTeX version 1999/12/01 or later.
%%

\input docstrip.tex
\keepsilent
\askforoverwritefalse         % ^^A Always overwrite
\preamble

This is a file was autogenerate from the \jobname package.

\endpreamble
\postamble

Copyright (C) 2019 by <AUTHOR> <<E_MAIL>>

This work may be distributed and/or modified under the
conditions of the LaTeX Project Public License (LPPL),
either version 1.2 of this license or (at your option)
any later version. The latest version of this license 
is in:

  http://www.latex-project.org/lppl.txt

and version 1.2 or later is part of all distributions 
of LaTeX version 1999/12/01 or later.

\endpostamble

\usedir{doc/latex/\jobname}
\generate{
 \nopreamble
 \nopostamble
 \file{\jobname/README.txt}{\from{\jobname.dtx}{readme}}}
\usedir{source/latex/\jobname}
\generate{\file{\jobname/\jobname.ins}{\from{\jobname.dtx}{batchfile}}}
\usedir{source/latex/\jobname}
\generate{\file{\jobname/\jobname.sty}{\from{\jobname.dtx}{Pkg,Sty}}}
\nopreamble\nopostamble

\endgroup
%</batchfile>
% \fi

如果我没记错的话,第一次重复是我很久以前将整个*.ins模板直接复制/粘贴到我的模板中。第二次重复是为了帮助在输出文件中生成版权信息。我打算删除第一次重复,因为该文件已合并到文件中,除了调试之外,我认为没有理由重新生成它(出于某种原因,Joseph Wright 在他的模板中这样做了)。对于第二次重复,我想知道是否可以以某种方式将其与原始文件合并,也许有一些我不知道的守卫诡计可以利用?*.dtx*.ins*.dtx

答案1

首先,包含\preamble实际上是不必要的,DocStrip 默认会包含以下消息(我猜 DTXtut 和模型 DTX 文件都覆盖了此消息以方便说明)。就我而言,后者的版权可能已被删除。

%% IMPORTANT NOTICE:
%% 
%% For the copyright see the source file.
%% 
%% Any modified versions of this file must be renamed
%% with new filenames distinct from invoice/invoice.sty.
%% 
%% For distribution of the original source see the terms
%% for copying and modification in the file invoice.dtx.
%% 
%% This generated file may be distributed as long as the
%% original source files, as listed above, are part of the
%% same distribution. (The sources need not necessarily be
%% in the same archive or directory.)

要覆盖默认设置并在所有生成的文档中产生版权,以下方法似乎有效。

% \iffalse meta-comment
% !TEX program = pdfLaTeX
%
%<*batchfile>
\begingroup

\input docstrip.tex

\preamble

Copyright (C) 2019 by <AUTHOR> <<E-MAIL>>
-----------------------------------------

This file may be distributed and/or modified under the
conditions of the LaTeX Project Public License, either
version 1.2 of this license or (at your option) any later
version. The latest version of this license is in:

http://www.latex-project.org/lppl.txt

and version 1.2 or later is part of all distributions 
of LaTeX version 1999/12/01 or later.

\endpreamble
%</batchfile>
% \fi

然而,有几点需要注意:

  • 这是有效的,因为

    % \iffalse meta-content 
    ... 
    % \fi 
    

    确实

    % \iffalse
    ... 
    % \fi
    

    block.meta-content没有任何意义,它仅仅是一种约定。

  • 上述代码使用 打开一个组\begingroup,稍后需要使用 关闭该组\endgroup

    % \iffalse
    %<*batchfile>
    \keepsilent
    \askforoverwritefalse
    % Read Me
    \usedir{doc/latex/\jobname}
    \generate{
      \nopreamble
      \nopostamble
      \file{\jobname/README.txt}{\from{\jobname.dtx}{readme}}}
    % Install File (Still not sure why this is done in Joseph's model DTX file)
    \usedir{source/latex/\jobname}
    \generate{\file{\jobname/\jobname.ins}{\from{\jobname.dtx}{batchfile}}}
    % Produce the Style/Class file itself
    \usedir{source/latex/\jobname}
    \generate{\file{\jobname/\jobname.sty}{\from{\jobname.dtx}{Pkg,Sty}}}
    \endgroup
    %</batchfile>
    % \fi
    

    我实际上不知道是否可以\endgroup稍后再继续\begingroup?这些宏对我来说是新的。模型 DTX 文件使用清楚的使用这些宏时会进行 TeX 检查,可能是兼容性问题。我记得有一篇与 DTX 相关的文档说这些复杂的构造是不必要的,但我记不起来源和原因了。

  • 我们需要导入docstrip.tex以使\preamble\endpreamble宏可用。还有\declarepreamble\BLOB\declarepostamble\BLOB宏可用于命名前/后序,在需要时分别使用\usepreamble\BLOB和引用它们\usepostamble\BLOB。我不确定是否\BLOB可以互换。

  • 我将 read me 代码从% \iffalse meta-content ... % \fi块中移出,放入其自己的块中。这就是

    <*internal>
    \iffalse
    </internal>
    ...
    

    <*internal>
    \fi
    </internal>
    
  • 我承认这一点是错误的,但这似乎<batchfile>是 Doc/DocStrip 实用程序的标准。我不确定<install>标签在模型 DTX 文件中来自哪里。也许它们是同义词?

相关内容