Questions tagged [counters]

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

Filter by
Sorted by
Tagged with
1
vote
2answers
61 views

Why is table of contents not showing incremented counter in headings in ConTeXt?

I setup a macro that very simply creates heading titles numbed "Puzzle 1", "Puzzle 2", etc. \newcount\a\newcount\counter \advance\a by 1 \define\puzzle{\chapter{Puzzle~\the\a}\...
0
votes
0answers
46 views

Customize text of cross reference with values of multiple counters

I'm looking for a way to make cross reference, in which the text of hyperlink include several counters in a customized format, as following picture: The counter theorem are defined as follow: \...
1
vote
1answer
27 views

Variable with counter that increases automatically

I want to define a variable that does the following \newcounter{ver} \newcommand{\version}[1][]{Version ~\thever ##1 \addtocounter{ver}{1}} The idea is that whenever you write the command \version it ...
2
votes
1answer
32 views

A counter that behaves in two ways in a tabular environment

I was testing code just for fun and found a strange behavior (for me) of a counter in the "tabular" environment: \documentclass{article} \usepackage{ifthen} \begin{document} \def\yy{&...
2
votes
1answer
20 views

addtocounter side effect

I am trying to define the following macro: \newcounter{cp} \setcounter{cp}{1} \newcommand{\phase}[3]{ \multicolumn{#2}{|l|}{\makecell[l]{Phase \thecp{} - #3 JEH \\ \footnotesize{#1}}} \...
3
votes
3answers
164 views

Tikz /foreach problem

The code below used to draw a plot of a permutation: \documentclass[a4paper]{article} \usepackage{tikz} \newcommand{\normaldot}[1]{ % Make a dot of fixed absolute size. \node at #1 {\normalsize $\...
2
votes
2answers
29 views

How can I enforce the evaluation of \refstepcounter when called?

I have an issue with \themycounter being evaluated too late: \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{hyperref} \newcounter{mycounter} \newcommand{\defineXX}[3]{% \...
2
votes
3answers
57 views

Count number of succeeding sections within the text

Writing about structure of the remainder of my article in the Introduction section, I want to dynamically get how many sections are left to the end of the manuscript. So in case my article consists of ...
0
votes
1answer
42 views

tcolorbox lemma numbering

I was wondering if there is a way to number Theorems and Lemmas the following way: Theorems are numbered as [section number].[theorem number] (which I've already done), and Lemmas are numbered as [...
2
votes
2answers
48 views

Is it possible to output a relative line number in flagderiv?

I am trying to output a number relative to the current step of my proof instead of being hard coded. I'll try and explain what I mean with this proof: \documentclass[11pt]{article} \usepackage[...
0
votes
1answer
34 views

Create a label if reference undefined, else reference it (unique label)

I'm trying to label items on a table. In my use, multiple labels may exist, so the initial location of the creation of the label is irrelevant (not trying to hyperlink). I want to use one command that ...
1
vote
1answer
33 views

Label section from \thesection

How can I put a label on \thesubsection without using \subsection? MWE: \documentclass{article} \usepackage[english]{babel} \newcommand*{\subsectioncounter}{\stepcounter{subsection}\thesubsection} \...
3
votes
2answers
68 views

How do I change a counter display so it shows alphabetic characters instead of arabic numerals?

I have a table (the one here is just an example) whose rows need to be numbered alphabetically, i.e., using a), b), c) etc instead of with arabic numerals. I tried every way of adding \alph to the ...
1
vote
1answer
48 views

Increase a counter when a command is called

I would like to increase a counter whenever the command \item is called. Of course, the following code \renewcommand{\item}{\item\stepcounter{counterNbQuestions}} will not work. How can I do? Edit ...
1
vote
1answer
60 views

\nameref using 'unexpanded' text?

Suppose I define a custom command \exercise as follows. \newcounter{exercise} \newcommand\exercise{% \refstepcounter{exercise}% \section*{Exercise \theexercise}% } Now, in the following ...
0
votes
0answers
28 views

How do I augment the numbers of the counted theorems by one?

Suppose I have some theorems 1 to n. How may I display these as Theorem 2 through n+1?
0
votes
1answer
44 views

How do I reset the equation counter in a tcolorbox align environment?

After poring over this site and the tcolorbox documentation for over an hour, I can't figure out how to reset the equation counter inside my derivation environment. I wrote the old version with ...
0
votes
0answers
12 views

Get the first (and last) page number of an arbitrary section and subsection anywhere in a Beamer document

For example, I would like to print out, on the first frame of section X, and again the first frame of section X-subsection 1, the beginning (end) page number of section X, subsection 1. Can I do that? ...
0
votes
1answer
16 views

Definition counter resetting on new section

I encountered this behavior from LaTex: last definition from section 2.1 was labeled (correctly) as 2.1.8. Then, the first definition of the next section was 2.2.9. I would like it to be 2.2.1 (don't ...
0
votes
0answers
8 views

How to set the citation counter for Bibtex? [duplicate]

I need the citation labels to start at some number larger than 1. I use Bibtex and cite with \cite{}. There has been an answer on this for natbib here, which does however not work for Bibtex. This ...
1
vote
0answers
31 views

LaTeX Error: No counter 'refsection' defined generated by \listoftheorems

I was wondering if anyone could help me with this problem. Somehow I'm getting the following error message ! LaTeX Error: No counter 'refsection' defined. See the LaTeX manual or LaTeX Companion for ...
1
vote
1answer
37 views

patching \setcounter and \addotocounter not working well with calc

for some very specific needs of reledac, I need to get the value of the page counter each time it is changed, either via settocounter, either with addotcounter. So I did something like this (it is a ...
1
vote
2answers
22 views

Glossaries: Can I have counters on a per glossary basis?

I know how to change the counter used for referencing occurrences in the glossaries package options. For instance, I know how to use sections instead of pages. Thing is, I have several glossaries in ...
2
votes
1answer
35 views

Problem with subfigure numbering when using the memoir class

I'm using the memoir class for my thesis and I noticed it recently started giving the wrong numbering for subfigures. I have some old PDFs when it was working properly and I'm quite sure I haven't ...
0
votes
0answers
41 views

Setting a common counter to different environments (figures, tables, theorems, etc)

I am trying to set a common counter to the environments figure, table, algorithm, thm, lstlisting. After searching over the internet I found a partial solution: to add the following code at the ...
1
vote
1answer
32 views

How to number constants based on first use?

Much like the author of this question, I would like to automatically number some constants in my document. A relatively easy way to do this is by creating a new counter, assigning a label to each ...
2
votes
2answers
30 views

Counter Error only in align environment?

I'm currently working on making a kind of textbook for Japanese math learners. Then, I made a counter macro as below. It seems to work nice in normal environment, as far as I know. But once I put it ...
1
vote
1answer
30 views

Hyperref from a glossary leads to wrong page after using /setcounter

I have a document with the code, that I added below. The first two pages of the document are the title page and the page with the table of contents. These two pages should not be counted, because the ...
0
votes
1answer
24 views

Use total number of pages in beamer as counter

I'm trying to set a count in latex on the total number of pages: \newcount\mypagecount \mypagecount=\insertpresentationendpage But whenver I do this, it auto "prints" the total number of ...
0
votes
0answers
23 views

Make section counter not reset in a new chapter

I am trying to create the following structure: Chapter 1 I. This is a Section II. This is a Section III. This is a Section Chapter 2 IV. This is a Section ...
1
vote
1answer
16 views

Conditional add to Counter based on conditional ifboolexpr

I want to add to a counter based on an ifboolexpr using etoolbox but cant get it to work as I had hoped. I want to put various conditions throughout my document and then at the end have a count of how ...
1
vote
1answer
55 views

Dynamic table : setting the column number after the table

I would like to create a dynamic table with \N columns at the beginning of the page, in which \N is the number of sections in the whole document, so the value of \N is set after the table. When I set ...
2
votes
1answer
35 views

`\counterwithin` not work with custom counters

I want to recount section for each new lecture. I learn that \counterwithin can do this job. It compiles successfully but not works right now. Here is the relevant code. \newcounter{lecnum} \...
0
votes
0answers
16 views

Unable to reference sections in supplemental document

SOLUTION: It turns out it was a documentclass problem. By removing prl from \documentclass[reprint,aps,prl,superscriptaddress,notitlepage]{revtex4-2} it fixed my problem. I'm having a problem where I ...
0
votes
0answers
22 views

Use theorem counters in custom tcolorboxes [duplicate]

I want my custom boxes to use the same counter as my theorems. I took a look in the tcbox manual and tried various things like "use counter from=theorem" and so on but probably it doesn't ...
0
votes
0answers
13 views

Problems with configuring figure and table counters in LaTeX [duplicate]

I'm typesetting a series of documents with the article class which present a series of problems with figures and/or tables, using the amsthm package. There are no sections in the document. What I'm ...
1
vote
1answer
62 views

Make greek numeration [duplicate]

How can I print a counter in the greek alphabet? \newcounter{nc} \setcounter{nc}{2} \arabic{nc} %print 2 \greek{nc} %I'd like to see \beta
1
vote
2answers
42 views

How to total item counts in multiple enumerate environments, respecting \include

I'm writing a book in which each chapter ends with a list of numbered exercises. I would like to persuade LaTeX to count the total number of exercises in the book, to be referred to with \ref or ...
0
votes
0answers
17 views

Class memoir Error: listing is not a counter

I am trying to use \counterwithout{listing}{chapter} Chngcntr: \counterwithout not working Number listings the same way as figures and tables But memoir keeps complaining Class memoir Error: listing ...
0
votes
3answers
83 views

How can I prevent \mathclap from quadrupling \stepcounter

When I want to iterate a counter using \stepcounter inside \mathllap , \mathclap or \mathrlap the counter iterates by 4 instead of by 1. E.g, the following MWE \documentclass{article} \usepackage{...
4
votes
2answers
171 views

Why is there an arithmetic overflow in the progress bar with more than 44 frames?

I am trying to implement a progress bar into my beamer theme, but as soon as I hit 45 frames, I get the error message ! Arithmetic overflow. \progressbar@progressbar ...progressbar@tmpcounta \divide \...
1
vote
1answer
51 views

Clash somewhere among \fpeval, \or, and \CountToken

(This is my first question here, sorry for any "side effects" of it...) I'd like to implement that, depending on the value of \MyR (a number between 0 and 1, 1 excluded), the first/second/......
1
vote
1answer
49 views

Unwanted punctuation in cleveref rererences

I use cleveref for referencing. There are a set of questions (which could be items) and their subquestions, which I want to come out as "question 1.1" or (preferably) "subquestion 2.3&...
2
votes
1answer
57 views

xsim, counters, and TikZ

In my previous post, I asked how to save random numbers for the xsim package. Now I would like to know how to do that when those random numbers are inserted into a TikZ picture. What about my counter ...
0
votes
1answer
24 views

Misplaced minitoc

I am struggling to use minitoc when I have a starred chapter before the TOC (that I want to appear in the TOC). In the following MWE, the minitoc of Chapter 1 appears under Chapter 2, despite I used \...
0
votes
0answers
21 views

Displaying a counter that is computed later [duplicate]

Most probably a trivial question for you: I have a counter \thetotalnoexercices that I compute while compiling my book, but I want to refer to it in the introduction ("This book contains ... ...
1
vote
0answers
15 views

Todonotes custom counter not referencing in align environment

I have set up todonotes with a counter and would like to reference the tasks I create. In the align environment, I am unable to place the task in the margin so it is inline in a \text{} command. ...
3
votes
3answers
89 views

Misplaced \noalign when trying to define a command for cmidrules

When trying to maintain large tables with \cmidrules, I find them tedious to use, so I thought I'd define my own shortcut. Instead of writing \cmidrule{1-3} \cmidrule{4-5} I would simply write \...
1
vote
1answer
47 views

What do the packages amsmath and libertine do that prevents counters from working?

So I have been using a custom setup of counters after some great help on here (thank you, egreg). The thing is, I have been running into a really odd problem with the counters which I am just unable ...
1
vote
1answer
22 views

Equation relabel then reset

I have asked a previous question, but that was for cases. Here, I would like to relabel some equations midway before resetting the labelling set to default. Code: \documentclass[12pt]{beamer} \...

1
2 3 4 5
24