Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

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
7
votes
3answers
2k 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 ...
7
votes
1answer
633 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❭ and ...
7
votes
2answers
3k 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
7
votes
2answers
1k views

Counting pages of sections

After building a second page counter that is reset for every section, I wonder how to get the number of pages of a section. Every section starts on a new page. How can I calculate the number of ...
7
votes
1answer
243 views

Make sure the back cover of a book ends on a even page

I'm trying to create a back cover for a book, and I don't want to manually have to make sure it ends on a even page. However since I have different sections with different numbering (think preamble, ...
7
votes
1answer
298 views

Cross-reference of custom environments created with environ and TikZ package

Problem: I want to create an environment named Example, and the environment has a counter (number within chapter). I want to refer to the counter for illustration just as the table, figure and ...
6
votes
3answers
288 views

How to get maximum number that \newcount can hold?

Is there a command that contains greatest positive integer that \newcount can hold?
6
votes
2answers
213 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} \usepackage[...
6
votes
3answers
1k 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 ...
6
votes
5answers
637 views

Reference an environment counter through label in another counter

I have an implications environment impl whose counter works as intended (1,2...). In a subsequent chapter, I develop a series of hypotheses for each implication, and I want the hypothesis environment ...
6
votes
1answer
227 views

Treatment applied in parallel to `LaTeX3`'s integers and `LaTeX2e`'s counter gives differents results

I'm in the process to try to give an expl3 flavor of my answer of my question: Add a marginal note when a page break occurs in the middle of a multi-line equation. During this process, I noticed a ...
6
votes
2answers
670 views

How can I make sure that *all* counters start at 0?

I am dogmatic, and I believe that 0 is the very zerost number. Naturally, I would like all my counters to start at 0. Page counters, section counters, subsection counters, theorems, definitions -- ...
6
votes
2answers
204 views

Complex parsing of arguments in new environments

I am trying to build an invoice generation system in LaTeX which will be easy and maintainable. Right now we are using longtable and a preprocessing layer. I would like to change this to a .sty and ...
6
votes
1answer
678 views

How can I define my own sequence of symbols for a new counter style?

I know I can change a counter style as this: \renewcommand\thechapter{\Roman{chapter}} (The above command will make chapter numbers be written in upper case roman numerals) However, according to ...
6
votes
2answers
1k 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} \addtocounter{...
6
votes
3answers
807 views

list of newcounter

I've set up a newcounter in a LaTeX document: \newcounter{example}[section] \newenvironment{example}[1][]{\refstepcounter{example}\par\medskip \textbf{Example~\theexample. #1} \rmfamily}{\medskip} ...
6
votes
1answer
645 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 in ...
6
votes
5answers
166 views

Appending to a command while also expanding a counter

I want to append some text to a command but expand a counter while doing so. Here is an example of what the problem is: MWE: \documentclass{article} \newcommand{\topics}{} \newcounter{topic} \...
6
votes
1answer
273 views

How to get total number of pages per chapter (at the chapter heading)

I am writing a thesis and I want to track how many pages I'm aiming for per chapter. At the moment I have a rough (non-functional) macro for this which I put below the chapter heading. How can I get ...
6
votes
1answer
2k 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} \...
6
votes
1answer
216 views

Caption number increases by two for every inclusion

I am trying to typeset my captions in margin using marginpar and captionof. Here is what I get by the MWE. Note the wrong caption numbers. The first caption is included using macro \fixedmarginpar ...
6
votes
3answers
4k views

How to get autoref working with different counters for different listing environments?

In my document I want several different custom listing environments. The solution from fraktalek works like a charm, except for one thing: \autoref doesn't work for me. I have tried the following: \...
6
votes
2answers
243 views

How to create a fixed counter?

How can I create a counter which is fixed once it has been set? The idea is to insert some kind of remarks into a text which should be numbered, but increasing with the date of actual implementation ...
6
votes
3answers
2k views

Reset the counter back to one in every chapter

I have the following code to get a beautiful concept boxes with optional header for every new concept discussed. The code changes the concept number using the counter but I also need to reset it to 1 ...
6
votes
3answers
1k views

How to mark equation number but not change the reference text?

I would like to mark a few equations as special by adding an asterisk (or some other symbol) to the equation number. I accomplish this as follows: \documentclass{article} \usepackage{amsmath} \...
6
votes
2answers
737 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, ...
6
votes
1answer
897 views

Correct usage of the LaTeX \newcounter and associated commands?

Previously I had a question about the \newcount command. I was then led to consider the \newcounter command instead, that does allow the use of digits in counter names. Accordingly, I have modified ...
6
votes
1answer
211 views

\alph without counters [duplicate]

When I iterate numbers with TikZ \foreach, they are stored in a macro. Now, when I need the letter corresponding to this macro, I can only convert it by saving it to a counter and then receiving it ...
6
votes
1answer
9k 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 ...
6
votes
4answers
5k 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}% \setul{...
6
votes
1answer
4k views

Defining repeated tabular/array columns using a computed value to specify the number

Background: I just recently saw that one could define multiple columns in a tabular or array using the syntax: *{num}{<align>} So, for example \begin{tabular}{r*{3}{l}r} is the identical to \...
6
votes
1answer
727 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 ...
6
votes
1answer
104 views

Spacing issue in new environment from a theorem

I'm trying to create a theorem environment that I can use to repeat a theorem that has been previously stated in a book but number it the same as the 1st instance. I found some sort of solution: \...
6
votes
1answer
15k 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 <chapter>.&...
6
votes
1answer
2k views

Multiple footnotes using symbols produces error: “counter too large”

I am writing a long report and want to use symbols in footnotes instead of numbers. When I add the 10th footnote the error "counter too large" occurs \documentclass{report} % Using symbols for ...
6
votes
2answers
700 views

the counter in beamer changed with pause

I define a counter in beamer. But when the pause command occurs, the counter will be added automatically. How can I do to make the counter not sensitive to the pause command? The following is the tex ...
6
votes
1answer
1k views

Reset counter \section in \part*

I'm a rookie with LaTeX, I'm using LyX, but I think this is a LaTeX problem. Im using this LaTeX preamble for reset counter after parts \usepackage{chngcntr} \counterwithin*{section}{part} But it ...
6
votes
1answer
218 views

Weird list formatting with xwatermark and refstepcounter

I discovered some weird behaviour with xwatermark and \refstepcounter which I cannot explain. I created a list and the indentation of the first item is correct, but all others are too much indented. ...
6
votes
1answer
180 views

How to do pagenumbering in a fancy way

How do i get uneven increasing page numbers in the first half of my document, and in the second half in the second half? Example: 1,3,5,7,8,6,4,2 Here are my thoughts on how to solve it: My LaTeX ...
6
votes
1answer
200 views

Is there a switch to turn off LaTeX counters from inside a box?

I know that amsmath typesets at least twice its material, the first one for measurement and that it takes measures (sic) to avoid some counters being updated twice. Is there a switch a macro writer ...
6
votes
1answer
1k views

Counter problem with tabulary

EDIT: As the example below was quite long, I made a minimal example below to make it easier to see the problem: In the example below, the expected values of the counters should be 0, 1 and 2, but its ...
6
votes
2answers
233 views

My own page number from file {counters}

I would like to add my own page number in my publications. I have file: numerki.tex zzzero jEden dWa trZy cztery ... dwadzIescia etc...... How I can add counter \counter\cyferki from file. each ...
6
votes
1answer
1k views

Modifying \answerline in the exam class

When using the exam class, is there a way to change the formatting of the item answer blanks created by \answerline? For a question, the label is 1. For a part, the label is (a) For a subpart, the ...
6
votes
1answer
308 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 ...
6
votes
1answer
299 views

Stop counter increment in tcolorbox when using overlays in Beamer

I have defined two new theorems, myexample and myexercise, using \newtcbtheorem in the tcolorbox package in Beamer. I have overlays (e.g. \pause, \uncover<2+>{ ... }, etc.) within the new theorems. ...
6
votes
2answers
1k views

Reset counter at beginning of proof

My goal is to get a new claim environment which automatically numbers. This is fine - I can make a counter, define a claim environment and claimproof environment which number automatically, and this ...
6
votes
1answer
270 views

Using ntheorem's counter inside theorem statement

I'm using ntheorem package and I would like to use the theorem's counter within the theorem's statement. This is useful when you're defining a special object you wish to reference elsewhere, like: \...
6
votes
2answers
12k 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 ...
6
votes
1answer
211 views

exporting tikz pictures starting with 1 rather than 0

I want to export my figures for an editor for import in another text editing program. I would like to have the name of the file correspond to the figures in the document. In the document they start ...
6
votes
1answer
874 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} \usetikzlibrary{arrows,shapes,calc,intersections,through,...