I noticed that all of the packages that come with Mathematica start with a header that is in a standard format. (See e.g. the header of NIntegrateUtilities` at the end.)

There are several commented sections, each starting with a word surrounded by colons.

Question: What is the purpose of these colon-surrounded words? Do they have any meaning to Mathematica? They look like they were made for a machine to parse. Does Mathematica have any functions/tools that can read these?

(* :Name: NIntegrateUtilities` *)

(* :Title: Utility functions for NIntegrate. *)

(* :Author: Anton Antonov *)

(* :Summary:
 This package provides a number of supporting functions for NIntegrate.

(* :Context: DifferentialEquations`NIntegrateUtilities` *)

(* :Package Version: 1.0 *)

(* :Copyright: Copyright 2007, Wolfram Research, Inc. *)

(* :History:
 Version 1.0 by Anton Atnonov, March 2007.

(* :Keywords:
 NIntegrate, integration, evaluations, profiling.

(* :Source:

(* :Mathematica Version: 6.0 *)

(* :Limitation:

(* :Discussion:

3 Answers 3


Old versions of Mathematica featured the package Utilities`Package`. This had the function Annotation[] that read those commented lines in packages so that one could see those annotations without having to explicitly open those packages in the front end.


{"Title", "Context", "Name", "Author", "Summary", "Copyright", "Package Version", "Mathematica Version", "History", "Keywords", "Sources", "Discussion", "Warning", "Example", "Example", "Example"}

Annotation["Statistics`NonlinearFit`", "Mathematica Version"]
{"(* :Mathematica Version: 5.0 *)"}

If you want to still use this function, it's available here. I would say those specific delimiters allowed the package to pick out annotations instead of code comments.

  • $\begingroup$ +1. I knew about this once, but my memory didn't hold it. Oh well. $\endgroup$ Jan 26, 2012 at 0:08
  • $\begingroup$ Do you have the package file since the package file available now doesn't contain the Annotation function. $\endgroup$
    – user13892
    Jun 20, 2018 at 10:34
  • $\begingroup$ @user, did you check the MathSource link I gave? $\endgroup$ Sep 24, 2018 at 11:07

An excerpt from "Programming in Mathematica" by Roman Maeder, 3rd edition, section 2.4 Package Framework and Documentation:

Another important tool for documentation is the reference section of the package. This section consists of a number of standard comments, identified by keywords with colons next to them:

(* :header: text... *)

The standard format of these comments allows document classification tools to extract this information in a machine - readable form. ... If you plan to submit your package to MathSource, these headers are important to properly classify and retrieve your package among the gigabytes of information present.

So, at least some automated tools were developed and used to read these, as you have guessed. How much this is in use currently I don't know. One fact which I find indicative is that new packages auto-generated with WorkBench do not contain these headers (may be this is just a setting which is switched off by default, I did not dig into this particular issue deep enough).

  • $\begingroup$ Ah, so the tool that can read these tags is some script they use to organize MathSource then. I've been looking at these for years, and never knew what they were for! $\endgroup$
    – Szabolcs
    Jan 25, 2012 at 23:42
  • $\begingroup$ @Szabolcs Yes, I suppose these tools are still at work on MathSource (or, Wolfram Library Archive, as it is called now). $\endgroup$ Jan 25, 2012 at 23:45

(* :Edit:
I just noticed that the packages created by the Mathematica package editor use double-colon-surrounded words - not the single colon-surrounded words asked in the question.
So Leonid's answer is the correct one...
The package editor does not care about structures like (* :header: text... *)

These are how Mathematica package files .m denote their metadata.

If you start a new package by going File ► New ► Package (.m) then you get into the Mathematica package editor. It looks almost like a normal notebook, you can have Section cells, Text cells, etc, but the default cell is a Code cell. When you save this file, only the Code cells are used to create the package. Everything else is commented out. The colon-surrounded words tell the Mathematica package editor what to do with commented out parts of the file.

Here's a simple example - save it as a .m file and view using the Mathematica package editor:

(* ::Package:: *)

(* ::Section:: *)
(*Section 1*)

(* ::Subsection:: *)
(*Subsection 1*)

(* ::Text:: *)
(*some text*)

some code

(* ::Subsection:: *)
(*Subsection 2*)

(* ::Text:: *)
(*some more text*)
  • $\begingroup$ Ah, these things you mention are a bit different: they are double-colon-surrounded. I was not aware of this. Maybe I should use Mathematica to tinker with m-files instead of Vim ... But note: Mathematica doesn't seem to parse the single-colon-surrounded words I mentioned in the question. It just shows them as plain text. And they have been around long before M- had a code editor for .m files. Leonid mentioned these were used on MathSource. $\endgroup$
    – Szabolcs
    Jan 25, 2012 at 23:46
  • $\begingroup$ @Szabolcs: Yep! see my edit (posted before you finished your comment) $\endgroup$
    – Simon
    Jan 25, 2012 at 23:47
  • $\begingroup$ I didn't know about the ::Section:: thingies either, I'm glad you mentioned them $\endgroup$
    – Szabolcs
    Jan 25, 2012 at 23:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.