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

learn more… | top users | synonyms

22
votes
2answers
505 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 ...
8
votes
3answers
4k 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 ...
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 ...
26
votes
5answers
3k 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 ...
9
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 ...
17
votes
2answers
3k 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} ...
5
votes
2answers
466 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: ...
34
votes
3answers
791 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 ...
19
votes
2answers
2k 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” ...
13
votes
4answers
602 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 / ...
18
votes
2answers
784 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 ...
6
votes
1answer
209 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 ...
8
votes
2answers
216 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
4answers
341 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 ...
6
votes
1answer
5k 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
396 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
765 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 ...
9
votes
4answers
4k 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: ...
5
votes
3answers
547 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
2k 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 ...
34
votes
2answers
855 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 ...
14
votes
1answer
190 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 ...
21
votes
4answers
741 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 ...
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
486 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
299 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
318 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 ...
6
votes
3answers
620 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
271 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 ...
13
votes
2answers
945 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
255 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} ...
11
votes
3answers
6k 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 ...
10
votes
2answers
465 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
127 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
262 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 ...
6
votes
2answers
1k 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 ...
4
votes
2answers
425 views

Numbering theorems within the innermost sectioning environment present at that point in the document?

Here is what I am trying to achieve: Chapter 1. ... Theorem 1.1. ... Section 1.1. ... Theorem 1.1.1. ... Subsection 1.1.1. ... Theorem 1.1.1.1. Is this even possible? If so, how? ...
17
votes
3answers
2k views

footnote counter, would like to restart from '1' each page

I would like the footnote counter to automatically restart from '1' for each page of my document.
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
1answer
780 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 ...
9
votes
2answers
110 views

Do assignments need to be appended by % to remove the trailing white spaces?

The following shows code snippet taken from multido.tex. I noticed assignments are not ended with %. See \dimen@=#1\advance\dimen@#2 in \def\multido@step@d#1#2{% \dimen@=#1\advance\dimen@#2 ...
8
votes
2answers
363 views

Cross-referencing between files and equation counters

I am using package xr to cross reference between two files. Is there a way to make the equation numbers in one of the files follow the ones in the other? What I mean is, if the last equation in file ...
7
votes
1answer
141 views

Counter problem with tabulary

EDIT: As the example below was quite long, I made a minimal example below to make it easier to see the problem: In the example below, the expected values of the counters should be 0, 1 and 2, but its ...
7
votes
4answers
188 views

How to refer to number of items in a list before the list appears in the .tex file?

I would like LaTeX to "know" how many items there are in a certain list. I want this number to be stored in a variable. In such a way I hope that this variable is sampled during the first compilation ...
7
votes
1answer
210 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} ...
4
votes
1answer
148 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 ...
3
votes
1answer
200 views

Figure refs stop working after I added a new counter

I was using the amspset document class for generating exam practice problems. I had wanted to add some referencing to the problems so I started a new counter like this (adapted from some Tex Exchange ...
1
vote
1answer
379 views

How to create a new counter for an a new environment that is in sync with subsections

I want to create an example environment with a counter which will be in sync with my subsections. So I'll have: subsection 3.2 lemma 3.2 example 3.2 example 3.3 lemma 3.3 subsection ...
20
votes
3answers
269 views

Chart showing the relative number of pages in the document

I'm playing with the idea of adding a chart in the begining of my thesis, showing the relative dimension of each chapter (or section, maybe). This is something that I would want to generate ...