{counters} is about macro writing involving counters. For general questions about numbering document elements, use {numbering}.
18
votes
2answers
370 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
2k 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 ...
21
votes
5answers
2k 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 ...
17
votes
2answers
659 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 ...
4
votes
1answer
143 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, ...
14
votes
2answers
1k 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}
...
3
votes
1answer
584 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 ...
21
votes
4answers
342 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 ...
15
votes
2answers
250 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
2answers
678 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 ...
11
votes
2answers
215 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
4answers
242 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
2answers
153 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
61 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}
...
6
votes
2answers
714 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 ...
15
votes
3answers
1k 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.
10
votes
1answer
547 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 ...
7
votes
4answers
107 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 ...
4
votes
1answer
128 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 ...
4
votes
3answers
285 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 ...
1
vote
1answer
286 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 ...
19
votes
3answers
638 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 ...
14
votes
2answers
285 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
764 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 ...
1
vote
2answers
397 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 ...
15
votes
2answers
1k 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” ...
12
votes
2answers
223 views
How to refer to a chapter with a word
I would like to refer to my chapters with the notation "First Chapter", "Second Chapter" etc, rather than "Chapter 1", "Chapter 2", etc. How can I do this?
\documentclass{scrreprt}
...
9
votes
3answers
822 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 ...
9
votes
3answers
3k 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 ...
7
votes
1answer
364 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 ...
6
votes
2answers
763 views
Building labels out of counters
There is a simple version to my question, and a complex version. First, the simple version: I want to generate label names by combining a constant string with a counter's value, something like what is ...
4
votes
2answers
304 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?
...
3
votes
1answer
131 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}
...
3
votes
1answer
247 views
Using counter values as part of style name for plots
I figured I should be able to give a bunch of line styles and access them using counters. Sure enough, this works out fine; this document
\documentclass{article}
\usepackage{tikz,pgfplots}
...
2
votes
2answers
299 views
Increment custom counter with standard sectioning command?
My document is a (scr)book and I'm talking of parts and chapters here, but I think the underlying question is pretty generic.
I want tables in the book to be enumerated continuously, in a ...
2
votes
1answer
3k 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}{.}{ ...
17
votes
3answers
480 views
Should LaTeX counters always be modified globally?
In this answer, egreg states that "LaTeX counters should always be modified globally". However, the etoolbox package provides the \defcounter macro which will assign a value to a previously ...
12
votes
2answers
520 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
3answers
244 views
No room for a new \count with datatool
This question led to a new feature in a package:
datatool
Update: 2013-1-19
The MWE worked fines with the new (v2.13) version of the datatool package using \DTLnewdbonloadfalse. But in my ...
11
votes
2answers
311 views
Middle age roman numerals formatting
I've recently read about a middle age variation on roman numerals where the last "i" character is replaced by a "j". I was thinking about writing my own \roman and \Roman variations, but hit a stone ...
10
votes
3answers
826 views
How to save variables
I need to change 'hyphenpenalty' in some parts of my document, but I have no idea how to properly restore a previous value after that.
For example:
\hyphenpenalty=10000%
\@starttoc{toc}%
...
10
votes
1answer
521 views
How to count number of lines in PDF document?
I'm using the lineno package to print line numbers (each page starts with number one) in the draft of my document:
\usepackage[switch*, pagewise]{lineno}
Is there a way to read out the number of ...
8
votes
2answers
1k views
Listings: different counters for different listing environments
How do I create two lstlisting environments that each have its own counter?
If I use for example
\lstnewenvironment{algorithm}[2]{
\renewcommand\lstlistingname{Algorithm}
\lstset{ ... }
} ...
7
votes
3answers
335 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 ...
6
votes
1answer
135 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}
...
6
votes
2answers
514 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 ...
6
votes
1answer
700 views
Revert (reverse) \numberwithin effect
How can I revert the action of \numberwithin{mycounter}{section} so that mycounter does not reset with a new section?
Example: (This is not exactly my case but this is easy to understand.) I would ...
6
votes
1answer
221 views
How can I reset sectional counters in memoir class to avoid breaking ToC cross-referencing in a complex document?
I have already asked a similar question here:
Incorrect ToC/Index cross-references when resetting memoir class counters
and received a satisfactory answer. Now, I wish to apply the chapter counter ...
5
votes
1answer
349 views
Incorrect ToC/Index cross-references when resetting memoir class counters
The quasi-MWE below uses the memoir class and works fine. It produces a document with the following structure:
ToC
Book
Part1
Chapter1
Part2
Chapter2
Index
Here, cross-references in the ToC and ...
5
votes
4answers
2k 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:
...