Document Classes%<*example> ... %</example>

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
Gnosos
Posts: 23
Joined: Wed Jun 29, 2011 10:52 pm

%<*example> ... %</example>

Post by Gnosos »

Hello,

I am putting the finishing touches on my first package by writing a dtx file containing the documentation. The latter includes a simple example of a .tex file using the package.

I tried following the example of http://mirrors.med.harvard.edu/ctan/mac ... stpage.dtx. At line 731 it has two statements, then lots of LaTeX code, and ends around line 845 with two statements that seem to close what the first two statements opened. The following code shows what I'm talking about.

Code: Select all

%    \begin{macrocode}
%<*example>

...

%</example>
%    \end{macrocode}
I understand the "\begin{macrocode}" command, but can't find anything on "<*example>". If I exclude these two <*example> ... </example> statements, running LaTex on the .ins file causes the example document code to appear in the .sty file. If I include the two <example> tags, they appear in the documentation as if they were part of the example -- which also is not what I want. I don't want the example code to be part of the .sty file, but I do want to include the example in the documentation for the package.

So, how does one use the <*example> ... </example> tags? Where can I find documentation on them?

Thanks.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

%<*example> ... %</example>

Post by localghost »

Before you continue, you should have a look at some documents and packages.
But nowadays it is not mandatory to submit contributions to CTAN this way [1].

[1] TeX Frequently Asked Questions — Contributing a file to the archives


Thorsten
Gnosos
Posts: 23
Joined: Wed Jun 29, 2011 10:52 pm

Re: %<*example> ... %</example>

Post by Gnosos »

Thanks Thorsten.

I'd already read the first two items on your list, although I did not know the second one is packaged as a tutorial. I also was unfamiliar with makedtx and sty2dtx. I can see how they would be very useful.

Fortunately, this initial project is deliberately small. So I learned a good deal by constructing the dtx file from scratch. I had actually stumbled on my own version of makedtx and sty2dtx. I started writing the package with a .sty file and a .tex file, one for code and the other for documentation. Then I combined them manually into the dtx file.

However, I scanned the various documentation files for the four things you referenced and could find nothing about "<*example>." Do you (or other viewers) have any idea where such things are documented?
Post Reply