2

Latex documents often come with a number of different files. What does a .dtx file usually specify? Please assume that the person reading your answer has next to no experience with using LaTeX. I don't care about the syntax used inside of a .dtx, or how to write a .dtx, I just want a short explanation of what it does.

As an example, inside of a .dtx file put out by the association of computing machinery, I found the following:

% \begin{macro}{\if@ACM@screen}
%   Whether we use screen mode
%    \begin{macrocode}
\define@boolkey+{acmart.cls}[@ACM@]{screen}[true]{%
  \if@ACM@screen
    \PackageInfo{\@classname}{Using screen mode}%
  \else
    \PackageInfo{\@classname}{Not using screen mode}%
  \fi}{\PackageError{\@classname}{The option screen can be either true or
    false}}
\ExecuteOptionsX{screen=false}
%    \end{macrocode}
%
% \end{macro}

EDIT:
Originally I said that a .dtx was a "configuration file," and then asked what a .dtx did. However, others have informed me that a .dtx is not a "configuration file." I have subsequently edited the question.

IdleCustard
  • 1,194
  • My interpretation: Providing a boolean option that can be passed to a document class. – Dr. Manuel Kuehner Jan 06 '19 at 16:56
  • is that code fragment related to a configuration file? Nothing in the part that you posted suggests that it is? – David Carlisle Jan 06 '19 at 16:56
  • 1
    if your question is "what is a dtx file" then it isn't a configuration file it is the documented source for the package, it contains both the package code and the documentation of that code. – David Carlisle Jan 06 '19 at 16:58
  • Looks like defining book keys with xkeyval package syntax –  Jan 06 '19 at 17:01
  • I notice that you have received answers to some of your questions, yet you have not accepted any answer. Please consider marking answers as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?) if they answered the question. This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. ... – moewe Jan 10 '19 at 21:11
  • ... It is of course entirely up to you which answer you accept and you are free not to accept any answer, but it would be nice if you considered doing it. You may also want to consider upvoting (by clicking on the arrows next to the score) questions that were helpful. Feedback from you (who asked the question) by voting or accepting is what keeps this site going. – moewe Jan 10 '19 at 21:13
  • @DavidCarlisle You are correct that the question was more, "what is a .dtx file?" I was wrong to say that a .dtx file was a configuration file. – IdleCustard Jan 13 '19 at 01:10
  • yes note that I wasn't just criticising your terminology I assumed that it was a fragment of configuration code and so not clear enough to answer. Now you have clarified it the question is certainly a duplicate, I'll find the existing answers, – David Carlisle Jan 13 '19 at 09:33

1 Answers1

5

*.dtx files are part of the doc system for specifying, packaging and documenting code. For full information (> texdoc doc) to view the manual. Essentially a .dtx file can consist of snippets of TeX code, textual explanations, user manual, etc. The snippets can be extracted from the file and placed in a number of output files to provide, say, a complete package, example uses of such a package, and a user manual. A single .dtx could contain the code for several packages each to be output as separate files.

It provides a way for code developers to basically wrap everything up into a single file rather than separate code, example, manual files which, if anything changed, would have to be updated separately (provided the coder remembered) whereas all can be done in a coordinated fashion in the .dtx

Mind you, creating a .dtx is not necessarily for the faint-hearted but most users need never see a .dtx as it is normally expanded.

Peter Wilson
  • 28,066