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

learn more… | top users | synonyms

3
votes
3answers
27 views

Extract correct counter value of a reference

Somewhere in my document there is a theorem labelled theoremA that has the number 2.21. Later, I want to set another counter to that specific number 21. First, I tried ...
2
votes
1answer
94 views

How to count the total number of subsections within a section? [closed]

How can I count the total number of subsection within each section. Actually, both section within each chapter, and subsections within each section for the article class. Based on this post I have ...
4
votes
1answer
47 views

Hyperref referring to the wrong label

I have this code in LaTeX and I am dealing with some dynamic work with labels and references. This code works - first reference references to the first text and second to the second but I want to ...
0
votes
1answer
68 views

Theorem numbering as subsections and automatic solutions

I have a problem environment where the counter is coupled to the subsection counter. However this doesn't work with automatic solutions. I tried to couple the solutions counter to the subsections as ...
2
votes
2answers
30 views

Programmatic Table Building Error

I am trying to build a variable size table programmatically. All the logic works separate from the table commands, and the table commands work separate from the programmatic logic, but somehow when I ...
0
votes
0answers
15 views

How can I avoid a longtable to be counted? [duplicate]

I use longtables to add Notes to my document. These notes shall not be counted. Can I tell longtable this (similar to \chapter* instead of \chapter)?
0
votes
2answers
27 views

If condition controlled with a loop variable

I want to print some images according to a variable being changed in a loop: if variable group is 1, then the image should not be printed. But if the value of group is 2, then the image should be ...
1
vote
1answer
42 views

Cross-referencing between different files with counter [closed]

I have the same problem in this question: Cross-referencing between different files The solution is ok, but in my label i have a counter and the compiler return thats: ! Missing number, treated ...
9
votes
5answers
559 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 ...
2
votes
1answer
29 views

Title with counter for Listings

I am trying to add a title with counter to my Listings. This is what I have so far: \usepackage{listings} \usepackage[many]{tcolorbox} \tcbuselibrary{listings} \newtcblisting[auto counter,number ...
3
votes
1answer
74 views

In CONTEXT, how can I get the total number of chapters?

For total number of pages, one can use \lastcounter[userpage] to get the total number of pages in the document. Actually it gives the number on the last page (which is more interesting). Similar ...
6
votes
2answers
70 views

counter in TOC fails when using xparse command instead of LaTeX2e command

Here I define a custom sectioning command, \Unit, which prints a numbered subject heading and adds it to the table of contents. If I use \newcommand for the command that creates the numbered label, ...
2
votes
1answer
47 views

Problem Splitting Very Long Algorithm on two or pages

In the example below, I have a very long algorithm, probably spanning 3 pages. I tried manually splitting the code up, but each time, a new algorithm number is generated. How do you maintain the ...
1
vote
1answer
53 views

How to reference a chapter after using the \setcounter{chapter}{0} [closed]

I'm trying to create a reference the appendix. The appendix package is resetting the chapter and section exectly like I do and I started to notice this bug while using it... So I use the \setcounter ...
3
votes
2answers
37 views

References for asparenum environment with counters depending on section

I'm writing math lectures using my own environment for definitions: \newenvironment{mydefs} {\begin{asparaenum}[\P\slshape\thesection.a]} {\end{asparaenum}} So every definition is numbered like ...
3
votes
1answer
39 views

edit an environment to add to a new extra parameter

I'm trying to define a new \newenvironment but I'm having some problems. I need an environment that uses a counter and uses an extra parameter to write some text. I'm working with this environment: ...
3
votes
2answers
24 views

Can I reference a number relative to a counter without changing the counter?

I have a counter called LCount, which I want to use in some text, and i would like to be able to reference numbers that are relative to that counter. for example, I would like this LaTeX code: For ...
2
votes
4answers
75 views

Setting a counter value based on a conditional statement?

I've been trying to google and this seems like a silly thing that should be obvious, but everywhere I look is answering how to use counter values inside a conditional statement, which I can do fine. ...
16
votes
2answers
1k views

What is the maximum integer that can be saved in a LaTeX counter?

I am using counters to save positive integers, something like that: \setcounter{mycoutervalue}{59} Is there any limit in the value I can save in a counter, in this case mycountervalue? And what is ...
5
votes
2answers
216 views

Is there a counter or variable that can be used to store non-integers?

I'm working on an invoice document which has a 'Grand Total' at the end of the document after some rows of invoice items. As such, I need to keep a running count of the total for each row. Using the ...
2
votes
1answer
42 views

Number formatting, addtocounter and calc package

I have been having troubles with the following issue: I am making an invoice template in LaTeX. I use \addtocounter to calculate values like subtotal, tax and total. This works fine, until the value ...
1
vote
0answers
62 views

No room for a new \count [closed]

I'm compiling an absolutely massive project for the first time on a new computer (using xelatex main.tex). It worked fine on the last computer I built the pdf on, but on this machine, I get the error ...
1
vote
1answer
22 views

hyperref points wrong figure/table with reset counter

I am trying to refer tables (and figures) in the main text with numbering modified and reset as shown in MWE, the numbers are correct in the main text, but hyperref points to wrong table. How to get ...
2
votes
1answer
15 views

Figure counter is not incrementing after use of paracol

I am using one column environment to write text and put figures with their captions. At a certain point I had a longitudinal figure to integrate so I wanted to put its caption laterally by using ...
5
votes
2answers
112 views

compare a value from \newcounter to value from \newcount

I searched for this topic, but I didn't find anything, so I hope this isn't a duplicate. I've got the following code: \documentclass[12pt,a4paper]{article} \usepackage[utf8]{inputenc} ...
4
votes
3answers
73 views

Change counter in \edef

When I try to change a counter in an \edef using \stepcounter, I get a whole lot of error messages ("Missing \endcsname inserted"). When I try to do the same with \addtocoutner I get no error, but the ...
5
votes
3answers
312 views

Is there a reverse \alph?

Is there a command that does the reverse of \alph, i.e. takes a letter and gives me the corresponding number of the letter in the alphabet? If there is, how about \Alph, \roman or \Roman? Context: ...
10
votes
2answers
10k 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}{.}{ ...
1
vote
0answers
44 views

Problem in combination of longtable and stepcounter{rowcount}

I am making a longtable consisting of 3 columns: linenumber of the text in the table, column with a short abbreviation and a column with possible a lot of text. Since the third column contains a lot ...
3
votes
1answer
53 views

Increment counter with name based on input

I have different counters, and I want to increment them. After I do not want to increment them separately, I wanted to write a macro which does that for me, depending on the input. I have the ...
2
votes
1answer
17 views

Forcing \alph to latin symbols in a multilingual document

If I use \alph{..} inside a hebrew block in a XeLaTeX document, I get a Hebrew numeral instead of a latin numeral. For example: \documentclass{standalone} \usepackage{polyglossia} ...
3
votes
2answers
48 views

Creating new counter formats on-the-fly with enumitem's \AddEnumerateCounter*

Aesthetic caveat: I am actually using small-caps with hanging figures and not lining. However, in creating a minimal example, I have succumbed to the defaults and created a typographical monstrosity. ...
3
votes
1answer
33 views

How do I have two different chapter numberings going on at once?

I am writing a strange textbook that needs each chapter in Chinese and then one English, all in the same book. I need there to be two chapter ones, two chapter twos, etc. The zhnumber package has all ...
1
vote
0answers
17 views

Change label in align environment [duplicate]

In LaTeX, I'm using the documentclass report with different chapters. Now, when using the align environment for listing formulas with labels, i get labels like (2.1), (2.2), ..., the first number ...
2
votes
1answer
59 views

ExerciseSelect with counter as key

I would like to use \ExcerciseSelect to choose some questions in order to create different assignments. I have more than 140 different questions. Ideally I would like to make something like student 1 ...
6
votes
1answer
192 views

I want to reset the question numbering under each section?

I am using exsheets to type questions and answers. When I start a new section, the question number continues from the previous one. How do I reset it it and make it start from number 1 again? Here is ...
1
vote
0answers
30 views

How to properly use a counter value in zref command

I am trying to expand on the answer to this question in order to automatize the creation of position markers with zref. I guess I am missing some important knowledge about how counters are printed. ...
4
votes
3answers
274 views

How to increment variable by using same variable?

How can I increment variable from the same variable? \pgfmathsetmacro\S{5}; \pgfmathsetmacro\S{\S + 1};% not working How can I work around this? I need counters which I use as line coordinates ...
3
votes
3answers
67 views

Numbering sections, subsection, subsubsections

I'm using the class book and for each chapter, section, subsection, etc. the numbering starts this way: Chapter 1 Section 1.1 Section 1.2 Section 1.3 . . . I would like to have ...
1
vote
0answers
14 views

number the equation without section or chapter [duplicate]

i want to number the equation without the number 2 in the image please \begin{equation}\label{N} ...
2
votes
3answers
47 views

includegraphics with leading zero in for loop

I would like to include graphics which have a filename with leading zeros. The filenames are: pic_001_test.png pic_002_test.png . . . pic_028_test.png I'm able to output leading zeros in a ...
2
votes
1answer
24 views

Changing the printing of a counter only in references

I have the following problem : I have a counter (in my case enumi) that I want to use for referencing with a different name than when it is appears first. Is there a tool in Tex/Latex to do this? ...
2
votes
1answer
37 views

totcount gives wrong chapter count when appendices present

I found that totcount gives the wrong chapter count when appendices are present. In the following MWE, the chapter count should be 3 but is actually 1: \documentclass{report} \usepackage{totcount} ...
4
votes
1answer
97 views

get the value of the current counter

I'd like to recover the value of the current environment counter and store it for my own uses, e.g. in the example below I'd like to store (not print) the number 1. With \@currenvir I can get the ...
4
votes
2answers
76 views

Exsheets print subsection counter?

When defining a counter format in exsheets I can use ch for chapter, se for section orqu for question. But how can I reference to the subsection counter? I can do: ...
4
votes
2answers
977 views

How to perform simple arithmetic with page number?

I want to play around the Latex variable \thepage. How to do that? For example subtract 1 from the current page: \thepage-1
2
votes
1answer
36 views

Cross Reference of Environments

I defined a personalized table environment as follows: \newcounter{Table}[section] \newenvironment{Table}[1][]{ \refstepcounter{Table} \newcommand{\tbtitle}{#1} \begin{center} } { ...
34
votes
6answers
6k 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 ...
2
votes
1answer
36 views

Using minutes package, how to change the minutes numbering

To create my minute report, I used following template : http://texdoc.net/texmf-dist/doc/latex/minutes/Sample.tex that I heavily commented because my needs are very basic, but this template is still ...
4
votes
1answer
55 views

Numbering Theorems with section number but not resetting the counter

I want to number theorems in the form "Theorem 1.4.26", such that the first two numbers are the chapter and section numbers and the last one is the number of the theorem in the whole book. That is, ...