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

learn more… | top users | synonyms

22
votes
2answers
593 views

What is the proper method of accessing a counter?

It seems that there are different ways of accessing counters. I have been using \theMyCount as in this post about Using counters or macros, but noticed that the arrayjobx package uses ...
9
votes
3answers
5k views

Resetting theorem counters: \section and (missing) \subsection

Suppose I define a new theorem "Theorem" and declare that its counter should be reset whenever the subsection counter is incremented or reset: \newtheorem{theorem}{Theorem}[subsection] At some ...
29
votes
5answers
4k views

How to output a counter with leading zeros?

I can output the value of a counter in a LaTeX document via: \setcounter{mycounter}{1} \arabic{mycounter} Which inserts a 1. But how do I format the output by, for example, adding a leading zero if ...
27
votes
3answers
1k views

How to display the final value of a counter at the beginning of a document?

At the beginning of my document, I have created a counter using \newcounter. Over the course of the document, this counter is increases using \stepcounter. How can I display the final value of the ...
11
votes
3answers
2k 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 ...
21
votes
2answers
3k views

Wrong (hyper-)references after resetting chapter counter

The following MWE produces a PDF whose TOC has two entries: “Foo” and “Bar” with correct page numbers. So far, so good. However, upon clicking on the link to “Bar”, I am taken to the page for “Foo” ...
5
votes
2answers
639 views

Re-displaying section headings after page-breaks

I'd like to automatically repeat section headings after a page break. My naive attempt at doing this is to check the page counter and print the extra text whenever the counter increments: ...
19
votes
2answers
4k views

Error: Counter too large! with \alph{cntr} and cntr>26

I would like to have \alph{counter} for values larger than 26. The following MnWE gives me the error ! LaTeX Error: Counter too large. \documentclass{article} \begin{document} \begin{enumerate} ...
13
votes
4answers
1k views

Dividing dimensions to get a count

Is there a way to divide two dimens and get a count? For example, if I have a box that doesn't fit on a single page, and I want to know the number of pages I'd need for the box (i.e., \heightofbox / ...
34
votes
3answers
925 views

Visual counter for LaTeX?

Does anyone know of a LaTeX package that implements a visual counter similar to the countdown counter of this context-module? It produces images like this: However, I would like to stick to LaTeX ...
23
votes
1answer
2k views

What are the differences between TeX counts and LaTeX counters?

The title already states the whole question. It has been answered by Joseph Wright at http://www.texdev.net/2009/11/17/tex-counts-and-latex-counters/, but I have not seen the according answer here at ...
8
votes
1answer
383 views

Output two sided, but only on recto page — occasional images on verso

I am preparing a thesis. In order to reduce the number of physical sheets of paper, I need to print certain figures/tables on the verso side. However the university regs state that, while figs/tables ...
6
votes
2answers
2k views

Save current value of counter in a command

I would like to define kind of an own index, that collects certain information and one counter value - in the following small example the \addstuff-command that may get the value of a counter as its ...
11
votes
4answers
6k views

custom counter and cross-referencing

I created a custom counter 'rtaskno' and a command '\rtask' as following: \newcounter{rtaskno} \newcommand{\rtask}{% \stepcounter{rtaskno}% \thertaskno} I like to use them as following: ...
23
votes
4answers
1k 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 ...
18
votes
2answers
849 views

Check if an entry is cited multiple times

I am trying to find out whether it is currently possible to have a test in Biblatex that tests at the very first time an entry is cited whether the same entry will be cited more than once in the ...
11
votes
1answer
916 views

Accessing the current overlay number in beamer

For some beamer related code in one of my packages I need to access the current overlay number. I mean the internal number used for things like \only<1>{..}. \only<1>{ Some internal ...
5
votes
1answer
364 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} ...
13
votes
2answers
1k views

Displaying a later value of a counter

I have a counter which is used throughout my document. At the beginning of each chapter (right after the \chapter command), I want to print the value of the counter which is reached immediately before ...
11
votes
2answers
898 views

Check if counter exists

I've written a package that introduces a new environment: \newfloat{foo}{htb}{bar}[chapter] The package however can be used for articles, books, ... Since not all of these environments have the ...
8
votes
2answers
323 views

How to refer to the count value of number of lines in a lstlisting

I need to refer to to the count value of the number of lines in a listing. Is there a way to do that ? \lstinputlisting[caption={SPARQL query used...},label={lst:sqry}]{codes/sparql_query.sparql} ...
8
votes
1answer
251 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} ...
8
votes
4answers
434 views

Slave duplicate counter

Is it possible to create a counter that is a "slave" to another (master) counter, but also an exact duplicate? The \@addtoreset{<slave>}{<master>} resets <slave> whenever ...
7
votes
1answer
7k views

pdfTeX warning: destination with same identifier has been already used, duplicate ignored (weird behavior)

Here is a minimal example: \documentclass{amsart} \usepackage{amsthm} \usepackage[pdftex]{hyperref} \newtheoremstyle{myexercise}{\baselineskip}{\baselineskip}{}{}{\bfseries}{.}{ ...
4
votes
1answer
615 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, ...
4
votes
1answer
875 views

Easy-to-use reference-able environment for restating theorem-like environments?

This question is a development of the same issue as this one; following my own answer and later comment there, I decided it deserves a spin-off. I would like to define an environment for restating ...
12
votes
3answers
1k views

How can I calculate the difference of 2 counters (pageref)?

How can I calculate the difference between 2 counters (like page numbers), so that pdfLateX outputs "3" in the last line of my example? and how could I calculate the difference between the "current" ...
10
votes
3answers
443 views

Making register declarations local, Undefining a register (count, toks, etc.)

Is it possible to make \newcount, \newtoks, etc. respect grouping, so that, e.g., \newcount\temp\temp=2{\newcount\temp\temp=1}\showthe\temp gives 2 (instead of 0)? Relatedly, is it possible to ...
8
votes
1answer
133 views

Arbitrary named counter, referenced

Apologies if this has been asked before, but I simply can't find it, despite voluminous searching. Some question answer bits of my question, but not the whole. The problem is this. I want a counter ...
5
votes
3answers
667 views

Using \total of totcount package in section title

I am keeping track of all the journal papers I review, and of course I'm using LaTeX. There are different journals I review for and I have different tables and counters keeping track of papers. Each ...
4
votes
1answer
197 views

How to incorporate counter in list label [duplicate]

I want to label my enumeration like SOMETEXT01, SOMETEXT02, ..., SOMETEXT10, etc. I read through a couple of questions and know how to create a counter that adds in leading zeros. ...
4
votes
1answer
3k views

Chngcntr: \counterwithout not working

I need to place the tables section after my appendix. I've used \counterwithin{table}{section} to number appendix tables A.1, A.2, etc. Then I use \counterwithout{table}{section} so that the tables ...
36
votes
2answers
983 views

Can I count the number of times each reference is cited?

I am writing a paper, and I would like to be able to find out automatically how many times each reference is cited. This could either be appended to the references in a printed version, or outputted ...
15
votes
1answer
239 views

A problem with counters

While trying to answer a question I came upon a problem with counters and I need some help. The idea is to collect answers to some numbered exercises, so the collected answers can be all typeset at ...
10
votes
3answers
10k views

How to reset chapter and section counter with \part

To get the output Toc or pdf bookmark below: Part I Chapter I Chapter II Part II Chapter I Chapter II I need to reset the chapter counter. I google and get one method. ...
7
votes
3answers
2k views

Count number of figures, tables and citations in report class

I'm using report documentclass and trying to use totcount for counting figures, tables and references, but there are two problems: Figures and tables counters are reset for each chapter, so ...
17
votes
2answers
559 views

Automatically numbering constants

I would like to somehow use LaTeX to automatically number constants. Some background As a mathematician, in my daily work there are a lot of throw-away constants which are not extremely important ...
15
votes
2answers
322 views

A new kind of “symbol wrapping”

alphalph defines three methods for continuing a set of symbols if you hit the end. alph continues like so: a,b,c…z,aa,ab,ac… mult continues like so: a,b,c…z,aa,bb,cc… wrap continues like so: ...
12
votes
4answers
348 views

Counting of selected words

I am typesetting a book, which has got more number of plants. While entering the text, I have to record the total number of plants recorded in my book. In fact, I have created an index of all these ...
7
votes
1answer
804 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 ...
6
votes
1answer
229 views

Print counter value minus 1

I have defined a new counter that keeps increasing each time I call the macro that's using it. How can I print the counter value minus one? Something like \value{\theCounter-1} but formatted for text? ...
6
votes
3answers
741 views

Extract document statistics? - How many pages has chapter xy? Count fixmes?

I have a large pdflatex document where each chapter is located in an extra text file and included with \include{chapter3.tex} ... How can I extract the page numbers of each chapter and write them ...
14
votes
1answer
475 views

Dos and Don'ts of \countdef\mycount=<number> and \newcount vs \newcounter{} in LaTeX

Let's clarify that countdef\mycount=<number> is a bad idea in LaTeX, then clarify appropriate usage of \newcount\mycount vs \newcounter{mycount} in LaTeX. Background: I only started with TeX ...
14
votes
2answers
1k views

Using counters or macros

Should I use counters or macros to store numerical data? Is there a limitation on a number of counters that can be used at the same time or other considerations? I would also like to perform simple ...
12
votes
3answers
8k views

Change footnote “numbering” temporarily

I would like to change my footnote "numbering" style temporally to letters (a,b,c ...) the default numbering beeing numbers (1,2,3 ...). This is needed only for specific paragraph, so I can't use the ...
12
votes
1answer
924 views

Why do \setcounter and \addtocounter commands have global effect, while \setlength and \addtolength commands obey the normal scoping rules?

The \setcounter and \addtocounter commands have global effect, while the \setlength and \addtolength commands obey the normal scoping rules. Why were they designed like this? Why are ...
11
votes
2answers
271 views

Hiding a counter if it is only displayed only one time

I have two macros on my document. \showcounter increases a counter, then displays it. \resetcounter sets the counter back to "0". \documentclass{article} \newcounter{counterone} ...
8
votes
2answers
158 views

Customise counters, cross references to environments

I would like to make cross references to own defined counter on environments. So far I have tried the following, \documentclass{book} \newcounter{entryc}[subsection] ...
8
votes
2answers
303 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 ...
5
votes
1answer
274 views

How to imitate great looking Motion Mountain ToC, including hyperlinks?

I wanted to customize my ToC to look more or less like the one in Motion Mountain physics textbook, including clickable page numbers. My decision was to use hyperref and titletocpackages. Now it seems ...