{counters} is about macro writing involving counters. For general questions about numbering document elements, use {numbering}.

learn more… | top users | synonyms

1
vote
1answer
2k views

Define new section

I have this document in the article documentclass. Everything is divided into sections and subsections. Now I'd like to have an example in my chapter two, that is also divided into sections. So I have ...
13
votes
3answers
347 views

Using counters within \index{…}

When trying to use a counter value within \index an odd behavior occurs. It seem as if the value would be evaluated at the end of the document, when the counter has already been changed. Therefore all ...
17
votes
1answer
182 views

Greatest hits? Can I find the most \ref'd part of my document?

I now have a 200 page document and have used \ref and \label very frequently. I was wondering if it is possible to use LaTeX to create a table at the start of the document with the "top ten" most ...
3
votes
1answer
490 views

Automatically increasing date in table cell

I'd like to have an automatic date in a table. Automatic date means I'd like to specify a start date which is shown in the first row of the table and every additional row shows appropriate next day. ...
6
votes
1answer
183 views

count the newlines in title

I am trying to automatically adjust the title page to get a pleasing result independent of the title size. This means that I have to count the number of line breaks in an argument. My MWE (not very ...
1
vote
1answer
228 views

Creating and using commands/counters which name depends on other counter

I would like to know how can I use a counter for defining other new counters. Something like this: \newcounter{foo} \stepcounter{foo} %% Perhaps more increments, this depends of the user. %% And ...
2
votes
2answers
728 views

Customize \section

I have a document, where I want typical code: "Problem # n" to be printed in every section. I made this code, which is working. How can I get rid of \setcounter{secnumdepth}{1} and ...
12
votes
1answer
166 views

Custom “counter” as page number substitute

I'm trying to typeset a book, covering a world trip. Instead of standard page numbers, I want each page to correspond with a digit representing driven kilometers. Of course I can't manually set that ...
2
votes
0answers
690 views

Lyx incorrect figure numbering [closed]

Just a quick question. I am currently working on writing my thesis. I have many figures and I want the numbering to be something like 4.1 or 5.3. Where the first number is my section number and the ...
2
votes
0answers
49 views

Counter too large if number of alphabet chapters is more that 26 [duplicate]

Possible Duplicate: Error: Counter too large! with \alph{cntr} and cntr>26 I need Alphabetic numeration of my chapters. But if they are more than 26 LaTeX gives an error message. How I ...
4
votes
1answer
574 views

How can I have Beamer number slides in a frame title?

More or less what it says on the tin: I want something like: \frame{\somecounterforpagenumbers : My Title} I assume there is a built in counter that I can reference here, but I'm not sure what it ...
0
votes
1answer
9k views

How can I set the table counter?

I've got my little examples env with \newlist{examples}{enumerate}{1} \setlist[examples]{label=(\arabic*), ref=\arabic*, resume} How do I use the same counter for the ...
10
votes
1answer
1k views

What is the purpose of putting \newenvironment, \newcounter in a document class?

In exam.cls, I saw the following codes which I don't understand how do they function in the document class (exam): \newcounter{question} \newcounter{partno} \newcounter{subpart} ...
4
votes
1answer
113 views

How to reference a point in a document with a counter and descriptive text?

This is a follow-up question to the previous questions: How to label a word inside a paragraph? How to refer back to a point in the document with custom counters? The code below ...
5
votes
3answers
565 views

Reset the counter back to one in every chapter

I have the following code to get a beautiful concept boxes with optional header for every new concept discussed. The code changes the concept number using the counter but I also need to reset it to 1 ...
10
votes
2answers
347 views

How to refer back to a point in the document with custom counters?

The easiest way to explain what I would like to have is to show the desired output and I would like to get this by writing something like: \begin{document} Draw point B \STEP{drawb}. Connect A and ...
4
votes
1answer
165 views

Use float counter in a section title

I defined a new float environment for examples \usepackage{float \newfloat{example}{htp}{example} \floatname{example}{Example} that I the use throughout the document \begin{example} ... ...
3
votes
1answer
344 views

How to create counters that display and increment dates in ConTeXt?

I need to create a document that has section titles named "October 1, 2012", "October 2, 2012", etc., like this: \section{October 1, 2012} This is text for the first day. \section{October 2, ...
23
votes
4answers
2k views

Count and use the number of items in advance

When writing LaTeX code, I often successively make changes like adding or removing items. I'd like to have TeX count and update the number of items in the list automatically, as in There are ...
12
votes
1answer
298 views

Counters and their “partners”

A counter created via \newcounter{<counter>} is stored internally as \c@<counter>, just like a reference made using \label{<label>} is stored internally using \r@<label>. ...
3
votes
1answer
158 views

Automatically count of glossary entries

I want to count all glossary entries of a document globally and automatically. Can I expand the macro \glossaryentry to do that and in such a way that I don't introduce a newly defined macro? I have ...
3
votes
2answers
230 views

How to create counters with index?

I need to create counters with names like mycounter1, mycounter2,... Basically this should be a counter-valued data array. The code like \newcounter{index} \newcounter{\csname ...
1
vote
0answers
162 views

Resetting a macro counter to 0 [closed]

I have a macro that is disabled after one use. The worksheet works fine until I need to clean the entire sheet and reuse it the next week. How do I reset the macro counter to zero so that I can use ...
8
votes
1answer
275 views

Savebox equivalent of \csname?

I would like to define a command which would increment a counter, and create a new savebox whose name is generated from the counter value. Something like: \documentclass{article} ...
7
votes
1answer
1k views

Citing many long URLs (shortening and numbering)

In my thesis I have to quote a lot from a single weblog. The URLs are mostly of this structure: blogname.providername.com/stories/123456 ...
5
votes
1answer
996 views

How to set the number of the first citation?

I am using BibTeX and natbib for my citations. In the bibliography the first entry usually starts with [1]. Now I would like to shift all the numbers in the bibliography and text by a certain offset, ...
1
vote
1answer
185 views

Counter linked to section and subsection [duplicate]

Possible Duplicate: Resetting theorem counters: \sections and (missing) \subsections I create a new counter as follow : \newcounter{question}[section] Thus at each new section ...
6
votes
1answer
260 views

Unique counter for all foot, side and end notes

When used together, as in the MWE, the text might be plagued of identical numbered marks, that is rather confusing. I want to have marks in this MWE ordered from 1 to 9 instead of three ...
3
votes
1answer
175 views

Counter not working as expected in pgfplot

Using pgfplot (for the first time), I try to create a chart with horizontal bars, sort of. See the figure. I know how to do it, but because the code is quite verbose and I have lots of data I've ...
5
votes
1answer
225 views

How can I consecutively number only some pages of a document?

The following code typesets a 12 page document; text only appears on every other page and there's an empty page between two text pages: \documentclass{article} \usepackage{atbegshi} ...
2
votes
2answers
1k views

Problems with theorem/definition/statement numbering

I have theorems, definitions, statements, that look like as follows \section{1} \subsection{1} Theorem 1.1.1 .... Statement 1.1.2 .... Definition 1.1.3.... \subsection{2} Theorem 1.2.1 .... ...
12
votes
3answers
3k views

Count number of references using biblatex

I am creating an annotated bibliography. Is there a way of obtaining a count of the number of references in a bibliography meeting certain criteria and inserting that into a document? For example ...
5
votes
2answers
2k views

Resetting counter

I have created two counters \newcounter{problem}[section] \newcounter{solution}[problem] As expected, problem resets every time section increases. However, solution does not reset when problem ...
6
votes
1answer
103 views

Beamer: suffix equivalent frametitles with a counter or index?

I wonder how to suffix equivalent frametitles with a counter or index. So for example, when I would have two slides with the same \frametitle (e.g. "Marvelous title"), it should result in Marvelous ...
5
votes
1answer
465 views

Counters for use in array/tabular cells

The following practical example \documentclass{article} \usepackage{array}% http://ctan.org/pkg/array \newcounter{tabcol}\newcounter{tabrow} \newcolumntype{C}{>{\stepcounter{tabcol}}c} ...
10
votes
1answer
109 views

How can one dynamically insert the number of subsections of the current section?

In a certain section of my document, I want to reference the number of subsections in this section ("In the following X subsections ..."). Is there any way to do this programmatically?
6
votes
1answer
6k views

No Counter Theorem1 is defined

I got an exception in the following latex code: "No Counter Theorem1 is defined", what is the problem? \documentclass[conference]{IEEEtran} \newtheorem{definition}[theorem1]{Definition} ...
4
votes
1answer
1k views

Creating variables with index (using counters)

Is there a way to add an index to a command? For example: \newcounter{count} \loop<condition> \def\var\Roman{count}{some data} \repeat The \var\Roman{count} should become the variable ...
7
votes
1answer
596 views

Is there something like \renewcounter or \providecounter?

Is there a command that creates a counter or, if it already exists, redefines it? Thing is that I'm working with nested loops. The second loop is however in a command. This means if I want to use a ...
9
votes
1answer
3k views

How to typeset the formatted counter in compactenum (paralist)?

I am using the compactenum environment from the paralist package, and would like to know how I can typeset the counter. What I mean is \begin{compactenum}[a)] \item I would like to typeset "a)" ...
4
votes
1answer
547 views

Reset counter after each item

How to reset the counter of equation numbering after each item in the enumerate environment?
3
votes
3answers
538 views

Beamer overlays and counters: compiling loop

I tried to compile \documentclass{beamer} \usepackage[english]{babel} \newcounter{xxslide} \begin{document} \begin{frame} \addtocounter{xxslide}{2} \visible<\value{xxslide}>{blabla} ...
5
votes
1answer
810 views

Using \thesubsection in header references last instance - not first

I would like to include \thesubsection in my header, referring to the first instance of subsection, and not the last as seems to be the default. The following MWE says it all: ...
7
votes
2answers
2k views

Increment counter in TikZ

How to increment counter in TikZ using code below: \newcounter{ga} %counter \setcounter{ga}{1} \begin{tikzpicture} \foreach \t in {1,...,10}{ \pgfmathparse{Mod(\t,2) == 1 ? 1 : 0} ...
4
votes
1answer
169 views

How to count the number of authors of a document?

I need to make a change to a Latex style (.sty) which contains the following line: {\large {\boldCondensed\color{corporate3Color}\raggedright AUTHORS: \MakeUppercase \@author\par}} The problem is ...
2
votes
3answers
310 views

Process Last Item in \ForEach (forarray package)

The following command of the forarray package \ForEach{,}{\thislevelitem(\the\thislevelcount) : }}{x,y,z} produces the output x(1) : y(2) : z(3) : I want to have the same output without the last ...
11
votes
2answers
29k views

\setcounter{tocdepth}

Using \setcounter{tocdepth}{0} displays just the chapter's title in the table of contents. In the last chapter, there's a subsection. I want to use \setcounter{tocdepth}{0}! Therefore no subsection ...
10
votes
1answer
4k views

Redefining a theorem counter

I have a document with a lot of lemmas and theorems. In the main part of the document there are sections and subsections, so I defined \newtheorem{lem}{Lemma}[subsection] to number the lemmas ...
6
votes
1answer
603 views

Checking if is Appendix or Chapter

How can i check if the value in \thechapter or \value{chapter} is a letter or a number? That way i could identify if the counter is referring to a normal Chapter or an Appendix.
14
votes
1answer
633 views

How to erase/delete a counter

I was wondering how does TeX manage counters. In particular, assuming I define a new counter in TeX by \newcount\mycounter and at some point I don't need it anymore, can I delete it and free the ...