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

learn more… | top users | synonyms

22
votes
2answers
481 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
3k 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 ...
26
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 ...
25
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 ...
34
votes
3answers
738 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 ...
18
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” ...
5
votes
2answers
420 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: ...
13
votes
4answers
469 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
769 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 ...
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} ...
8
votes
2answers
190 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
314 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 ...
4
votes
1answer
337 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
738 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: ...
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 ...
13
votes
1answer
174 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
645 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
1k 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 ...
15
votes
2answers
289 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: ...
6
votes
3answers
559 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
2answers
952 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
1answer
196 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 ...
13
votes
2answers
883 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
252 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} ...
10
votes
2answers
342 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
104 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
242 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 ...
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
2answers
402 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
997 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
736 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
105 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
283 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
4answers
175 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
198 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} ...
5
votes
3answers
484 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
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
194 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
356 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 ...
33
votes
2answers
804 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 ...
20
votes
3answers
252 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 ...
6
votes
2answers
489 views

How to reset section counter

This is the barebones of my document: \documentclass[12pt]{article} \begin{document} \begin{center} \textbf{\LARGE{Topic I}} \end{center} \section{Section I} content \section{Section II} ...
6
votes
1answer
178 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 ...
16
votes
3answers
534 views

square root of number in counter

I would like to get the square root of a number which I have stored into a counter. I have been using the calc package for summation and multiplication operations, but I cannot find anything like ...
11
votes
1answer
877 views

Infinite-depth list

I want to create a command set that allows me to do something like \nestedlist{ \listitem An item \sublist{ \listitem A sub item \listitem Another sub item } } and get An item 1.1 A ...
7
votes
1answer
578 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 ...