User:Bibiko/GlossCnt

Extension GlossCnt &#8211; An auto-count function

Background
It is often the case that an editor of an article wants to number examples, figures, diagrams, etc. serially. This can be done by hand. By doing so a problem arises if you want to add for instance a further example between existing ones. After inserting it the editor has to renumber all example following the new one. Furthermore if within this article occurs a reference like see example (6) the editor has to renumber this reference as well.

To solve this problem the editor can use this extension GlossCnt to number them automatically by using the tags &lt;glcnt /&gt; and &lt;glref /&gt;.

Short Description
What can you do with this extension in short terms:


 * define several independent counters by using different ns (&lt;glcnt ns="ns" name="name" /&gt;)
 * refer to the a specific counter by using the name attribute (&lt;glref name="name" /&gt;)
 * predefine the type of counting (numeric or alphabetic)
 * for sub-counter: specify whether only the sub-counter will be displayed ( 7b or only b )
 * predefine the format, like (1), or §a, or figure :, which will be bequeathed
 * define a sub-counter linked via name (&lt;glsub of="name" /&gt;)
 * reset a global counter (&lt;glreset ns="ns" /&gt;)

The tag &lt;glcnt /&gt;
Syntax: &lt;glcnt ns="ns" pre="prefix" suf="suffix" name="name" type="type" nocnt /&gt;

Further explanations:


 * prefix and suffix have to have set together. If you set only suffix this attribute will be ignored.
 * It is possible to add HTML tags to prefix and suffix. Example: &lt;glcnt pre="[&amp;lt;b&amp;gt;" suf="&amp;lt;/b&amp;gt;]" /&gt; to set the number in bold face enclosed by "[]" like [3]. Please note that &lt;, &gt; , and &amp; must be escaped: &amp;lt; , &amp;gt; , &amp;amp;
 * name and ns may only contain the following characters: A to Z, a to z, numbers and an _
 * If you are editing only a section of an article please note that the numbering starts always at 1 (resp. A or a) in the Preview regardless the number of this tag within the entire article. After saving this section the numbering within the article is serially.
 * The type attribute must be specified within the first occurrence of &lt;glcnt {ns="ns"} /&gt;!
 * If prefix and suffix are set within the first occurrence of that tag you can use it as a kind of caption for figures, diagrams, examples, etc. (e.g.: figure 1, figure 2)

The tag &lt;glsub /&gt;
Syntax: &lt;glsub of="of" pre="prefix" suf="suffix" name="name" type="type" sep="sep" nocnt /&gt;

Further explanations:


 * It is possible to nest &lt;glsub /&gt; via the attribute name to get e.g. (1.4d).
 * The type attribute must be specified within the first occurrence of &lt;glsub of="of"} /&gt;!

The tag &lt;glref /&gt;
Syntax: &lt;glref pre="prefix" suf="suffix" name="name" /&gt; The tag &lt;glref name="myref1" /&gt; will be replaced by the number according to &lt;glcnt name="myref1" /&gt; and this number is implemented as Hyperlink to &lt;glcnt name="myref1" /&gt; to make it possible to jump to it easily.

Further explanations:


 * prefix and suffix have to have set together. If you set only suffix this attribute will be ignored.
 * It is possible to add HTML tags to prefix and suffix. Example: &lt;glref pre="[&amp;lt;b&amp;gt;" suf="&amp;lt;/b&amp;gt;]" /&gt; to set the number in bold face enclosed by "[]" like [3]. Please note that &lt;, &gt; , and &amp; must be escaped: &amp;lt; , &amp;gt; , &amp;amp;
 * name may only contain the following characters: A to Z, a to z, numbers and an _
 * If the name is unknown within this article an error will be printed out.
 * If you are editing only a section of an article and the name points outside of this section an error occurs. For editing such a case you have to edit the entire article to be sure that the reference is correct or dismiss the error and save the section if you know that the name is correct.
 * It is possible to use &lt;glref name="ref_name" before &lt;glcnt name="ref_name"&gt; occurs in the article.

The tag &lt;glreset /&gt;
Syntax: &lt;glreset ns="ns" /&gt;

This tag set the counter according to its ns to 1, or A, or a.

Further explanations:


 * You cannot reset a sub-counter.

Comments, Bugs, Wishes
Please don't hesitate to contact me via (bibiko[at]eva.mpg.de) if there are problems, errors, bugs, or wishes regarding to this extension.

March 20th, 2007