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

learn more… | top users | synonyms

5
votes
2answers
110 views

Missing number, treated as zero with amsmath and calc

This simple code produces "Missing number, treated as zero" \documentclass{article} \newcounter{test} \newcounter{testtwo} \usepackage{calc} \usepackage{amsmath} \begin{document} ...
5
votes
3answers
235 views

New counter that can be referenced

I have created a method \makeExample that creates a new counter called example. Can you tell me how I can modify it, so that I can make references to the example counter? So that I for example can ...
5
votes
2answers
1k 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} ...
5
votes
1answer
383 views

Is it possible to remove length, counter, dim, etc that have been declared?

Let's see the following screenshot taken from an answer of Efficient ways to anonymize a document and the given comment. Is it possible to remove length, counter, dim, etc, that have been declared ...
5
votes
1answer
87 views

How to define a new counter independent of section

I am trying to create exercises within a paper, by which the numbering will be as one would expect (1, 2, 3, ...). However, when defining a new counter and theoremstyle: \documentclass{article} ...
5
votes
2answers
96 views

Defining special counter

Theorem counters can be set to zero automatically on changes of chapter, section, or subsecion, by the second optional argument of \newtheorem (e.g. \newtheorem{foo}{Foo}[section] produces a theorem ...
5
votes
2answers
126 views

Corollary counter in SVmono

When using the predefined Theorem and Corollary commands using the Springer template svmono, the theorem and corollary counters are different. How can I make the counters match? The desired effect ...
5
votes
1answer
315 views

Complex Count in \foreach for number line

I am looking to create simple number lines. I have asked a similar question: Resetting numerical labels in \foreach commands on a numberline. But now I am in a different situation. I know how to ...
5
votes
1answer
311 views

Print the counter given as an argument

I have a counterA and a counterB. I want to define a command \PrintCounter, which gets either A or B as argument, and then prints the value of the corresponding counter. I wrote the following code: ...
5
votes
4answers
1k views

Problem with a counter inside a \ul command

The following MWE gives a compilation error. If i move the \arabic{count} outside from the \ul command, it works \documentclass{article} \usepackage{soul} \begin{document} \newcounter{count}% ...
5
votes
2answers
62 views

Evaluate \arabic inside \nth (1st, 2nd… in lists)

I'm trying to define the following environment: \newlist{aims}{enumerate}{1} \setlist[aims,1]{ label={~ \textbullet ~ ~ ~ ~ ~\nth{\arabic*} best ~~~ =}, leftmargin=*, align=left, ...
5
votes
1answer
114 views

What's the meaning of the command \number and when to use it? And some confusion about the following code

\setcounter{numofgaps}{\numexpr\number\value{numofboxes}-1} \setlength{\truetextsectionwidth}{\textsectionwidth-\number\value{numofgaps}\gapwidth} The above code is a snippet from the answer of How ...
5
votes
2answers
175 views

\stepcounter is not working in subsection heading

I have defined a new counter as: \newcounter{lecCounter} \newcommand{\lecID}{\stepcounter{lecCounter}\thelecCounter} And I wish to use it as: \subsection{Lecture \lecID } But it gives error: ! ...
5
votes
1answer
121 views

Is there a way to know how often latex has already run? [duplicate]

A few days ago, I have seen an example of a latex file, that did conditional \defs on subsequent runs but I can't find that one again. I still remember that it was by looking into the \jobname.aux do ...
5
votes
1answer
40 views

Total number of longtables (v3.02+)

I'm wondering, are there any ways to get (and forward-reference at the beginning of the document) the total number of tables when using longtables? There are utility packages for standard table ...
5
votes
2answers
196 views

`xr` - temporarily redefine `\label` for exporting section counter to sister document?

The goal My objective is to have continuous page (and possibly section) counters for several independent documents. The purpose is a cumulative dissertation where each paper should retain the ...
5
votes
1answer
415 views

Change colour depending on counter

I have some text that I want to change colour depending on the current state of a counter. But I can't get this file to compile. (This is obviously simplified, since the texcolour command is actually ...
5
votes
2answers
104 views

Do section counters need to be reset if you reset chapter counter?

The answer to this question How to remove chapter numbering without removing it from tableofcontents was given as: \newcommand{\mychapter}[2]{ \setcounter{chapter}{#1} \setcounter{section}{0} ...
5
votes
2answers
593 views

Number of Equation: 1, 1a, 1b

Following Problem: I have a PDE and two boundary conditions what i actually want is: PDE (1) BC1 (1a) BC2 (1b) and what i have is: PDE (1) BC1 (2a) BC2 (2b) is there something which provides a ...
5
votes
2answers
130 views

Counter inside a tikz tree

I would like to increment and print counter at some node of tikz tree. I am able to do it when the tree grows to bottom, but not when it grows to left. My problem is that couter must be increment ...
5
votes
1answer
288 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 ...
5
votes
1answer
138 views

Date and time macros in Chinese

Is there a way to get time and date stamps, or other standard counters, to appear in Chinese? I am using xeCJK. Package babel (with \selectlanguage{french} etc. in context) makes it simple for the ...
5
votes
2answers
683 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: ...
5
votes
1answer
10k views

Changing number within \numberwithin causes malfunction but no compile error

An interesting one here. It could be a bug or I might be missing a trick. In my thesis I use \numberwithin{}{} to have numbering done within sections. Top level is chapter, so it goes ...
5
votes
2answers
95 views

arrays of counters for tikz nodenumbers?

Answering How to highlight portions of a matrix is a nice technique that isn't invasive, but requires manually numbering the nodes. I'd generalized it slightly: \documentclass{article} ...
5
votes
1answer
187 views

Only show header if section number > 0

The current section name + chapter.section number is shown in the header. This is normal behaviour (what I want). Example: How can I remove the header text, if there is no section on the page. The ...
5
votes
2answers
134 views

Cross reference to counter in section title

I am trying to use a custom counter in Latex in order to auto number Use Cases in section titles (eg. \section{UC <counter>: use case title}). I also want a \usecaseref command to substitute a ...
5
votes
1answer
540 views

How to customize cross-reference numbering of custom environments?

Context: I have several environments with custom counters. As usual, I'm referencing them along to my document but I get only the corresponding counter value as reference. Example: ...
5
votes
1answer
202 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} ...
5
votes
2answers
5k views

Access the chapter/section number and the chapter/section label through variables

Often I find myself in the situation that I'd like to design how chapters and sections look. I know there are packages that help to design such things, but non of them seems to give me the option to ...
5
votes
1answer
1k views

Beamer overlay and counter

I have a counter that I want to use for the beamer \onslide command. Using \newcounter{coun} %.... % \onslide<\coun ->{ ....} doesn't work. What is the correct way to do this?
5
votes
1answer
177 views

How to output the final value of some counter, like number of figures or tables in the middle of the document?

I need to put some formal statistics on the document itself somewhere in the middle, like "This document contains XXX figures and YYY tables (and may be even ZZZ formulas and PPP theorems)". Is there ...
5
votes
1answer
56 views

How do I feed evaluated references into this sorting routine?

Below is some code I cobbled together from examples found on the net. I would like the sorted list routine to use the results of evaluating \ref rather than using the literal argument of \ref. ...
5
votes
1answer
80 views

Passing current counter value to stack data structure

I'm trying to combine a stack data structure with a \newcounter{} definition so that I can automatically pair together a collection of points scattered throughout my text. Each point is either ...
5
votes
1answer
133 views

Defining a command that conditionally defines/checks for counters

In order to complete one custom package command I needed an internal macro, I called it \@test@count{❬argument❭}, and should accomplish the following: Internally defines a new counter \❬argument❭ ...
5
votes
1answer
427 views

Beamer total slides counter?

Thanks to Change the page number of slides in notes when using | handout: command I can count the slides in a frame. What I would also like is a counter for the total number of slides in a frame. ...
5
votes
1answer
334 views

How to use a counter inside node<> in TikZ?

I'm trying to draw nodes one by one on a list of predefined coordinates. \documentclass{beamer} \usepackage{caption} \usepackage{pgf,tikz} ...
5
votes
1answer
115 views

Using counter within database

I try to add a countervalue into a database. But if the database content will be printed, the value is allways the maximum value. I have a simple code example ...
5
votes
1answer
142 views

Carrying counters over to another file

I have two files, say file1.tex and file2.tex. file1.tex is the first of a series of files, and it begins with counters (say chapter 1 for instance, although my counters are not used for chapters). ...
5
votes
2answers
150 views

How to reference the most recently used multiply-defined label

I want to be able to do something like the following: \incmycounter{abc} %% counter value initialized to 0; associated with label 'abc' \incmycounter{def} %% counter value initialized to 0; ...
5
votes
1answer
392 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} ...
5
votes
1answer
760 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: ...
5
votes
2answers
89 views

How can I create a counter so that it will enumerate a list I define

I am using a counter, like so: \newcounter{sectionnumber} \setcounter{sectionnumber}{0} \newcounter{courseday} \newcommand{\nextsection}{HW/Quiz \stepcounter{sectionnumber}\arabic{sectionnumber}} ...
5
votes
1answer
341 views

Problem with counter and \pause

I am trying to create a manual continuation annotation for my presentations (because I need more flexibility than provided by the automatic splitting feature of beamer). What I thought of is, for ...
5
votes
1answer
907 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 ...
4
votes
2answers
94 views

Change \part counter to text: from I to ONE

I have included the \part command into my dissertation in \documentclass{report} which automatically uses Roman numerals: I, II, etc. as its counter. Is it possible to change these to text/string ...
4
votes
4answers
182 views

Count points per task

We have a cooperate design template for exams. The disadvantage is, that we have to count the point for each task manually. My idea was to this automatically with counters. What I am looking for: ...
4
votes
3answers
130 views

Advanced hierarchical counting for theorems

I want to number successive theorems with hierarchical counting (top level counter n, sub level counter m) in a way that I can chose from the following options for each theorem: Theorem n. ...
4
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 ...
4
votes
2answers
397 views

Write a \setcounter command to a file

I try to write a setcounter command to a file (using the newfile package) by something like the following \addtostream{mystream}{\protect\setcounter{mycounter}{\myvariable}} However, since the ...