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

learn more… | top users | synonyms

7
votes
1answer
2k views

\newcounter vs \newcount [duplicate]

What are the differences between \newcounter vs \newcount? So far as my knowledge goes \newcounter is from LaTeX and \newcount is from TeX. Also, I find that \newcounter has an optional automatic ...
9
votes
2answers
504 views

How to store a counter value at some point in the document?

I'm beginning to learn LaTeX and I need some help with counters. My goal is to store the value a certain counter reaches at some point in the document and use it later. This is my attempt: ...
15
votes
1answer
499 views

Dos and Don'ts of \countdef\mycount=<number> and \newcount vs \newcounter{} in LaTeX

Let's clarify that countdef\mycount=<number> is a bad idea in LaTeX, then clarify appropriate usage of \newcount\mycount vs \newcounter{mycount} in LaTeX. Background: I only started with TeX ...
5
votes
2answers
138 views

How can I obtain total number of points?

I defined the command: \newcommand{\shcpoint}[1]{% \ifnum #1<2 (\emph{#1 point})\quad\phantom{s}% \else (\emph{#1 points})\quad% \fi } and I use it in the ...
3
votes
1answer
106 views

Changing the item numbering

Similar to Numbering exceeding the 26 letter alphabet I tried to define Roman numbering. The result is OK, but LaTeX gives me a Missing number, treated as zero.-error. MWE: \documentclass{article} ...
3
votes
2answers
107 views

Determining spacing by a number that is a multiple of a counter

I have \hspace and I have a stepcounter xyz \documentclass[12pt]{article} \usepackage[top = 1in, bottom = 1in, left = 1in, right = 1in]{geometry} \usepackage[T1]{fontenc} ...
3
votes
1answer
118 views

Number and reference paragraphs

For "law-documents" you often want to enumerate every paragraph and cite them somewhere else in your document. This enumeration shall increase through the whole document and have the possibility to ...
2
votes
1answer
81 views

Hide all but one instances of a custom environment

I have a file containing a number of custom environments numbered by a counter "exercisesheetnumber". I would like to use a second counter "printonly" to hide all instances of the environment but the ...
4
votes
1answer
87 views

Enumerate every row, excluding the first one in a table

I want to numerate every row, excluding the first one, in a tabularx environment. In my MWE the first line, headline, is also numerated. How can I turn this off? \documentclass{article} ...
9
votes
4answers
280 views

How can I reference the current (sub)section number?

I want to create a macro that dynamically returns the current chapter, section, subsection (etc.) I'm in. I've created a macro called \getCurrentSectionNumber that does this, but it lacks the ability ...
6
votes
1answer
115 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 ...
34
votes
3answers
943 views

Visual counter for LaTeX?

Does anyone know of a LaTeX package that implements a visual counter similar to the countdown counter of this context-module? It produces images like this: However, I would like to stick to LaTeX ...
7
votes
3answers
240 views

How to count cells in tabular (horizontal and vertical)?

Thank Herbert, I have a part of code with list of students and presence at lesson. Now I need counting cells horizontal and vertical in table. And counting rows too. Thank you for helping me. I am ...
6
votes
1answer
163 views

How to count the number of questions separately for different parts in exam class?

I am creating an exam with two parts, the first part is short questions and the second part is essay question, and I would like to automatically count the number of questions for the two parts ...
3
votes
1answer
473 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
5
votes
1answer
409 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. ...
4
votes
2answers
70 views

Insert newline if this line is the last one before a new page

I have this simple Idea: I want to have LaTeX keep count of the number of text-parts (which already works fine): \newcommand{\newpart}{ \bigskip \begin{center} ...
9
votes
1answer
220 views

Bad page break with \newenvironment, \refstepcounter and hyperref

I tried to define some environment but came across bad page breaks sometimes. The minimal working example is as follows: \documentclass[b5paper]{article} \usepackage{hyperref} % page break is correct ...
13
votes
1answer
893 views

Computing a value inside \setcounter

I am using an enumerate list. I often want to decrement the counter of a list, to get output like this: 1. Some text here 2. Some more text here 2. This is a re-use of the number 3. The counter ...
7
votes
1answer
107 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 ...
2
votes
1answer
381 views

Adding caption and counter to source code environment

I have a source code listing with minted environment. How can I make a counter/caption to be shown as follows. I also need to make \tableofsourcecode to enlist all the source code references. The ...
4
votes
1answer
82 views

Create new counter and give it a specific value

Consider the following: \documentclass{article} \usepackage[T1]{fontenc} \usepackage{fancyhdr} \usepackage{caption} \usepackage{subcaption} \usepackage{expl3} \usepackage{pst-eucl} ...
5
votes
2answers
87 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}} ...
0
votes
0answers
27 views

Chemmacros is not resetting the reactions counter in the new chapter [duplicate]

I have a problem with chemmacros counter. When I type the reaction in different chapter, the counter of the equation doesn't restart. See the example \documentclass[twoside]{ecsthesis} ...
4
votes
2answers
301 views

Reset custom counter in new frame

I'm using a custom counter to cycle bullet point colours in beamer: \documentclass{beamer} \usepackage{graphicx,color} \usepackage[T1]{fontenc} \usepackage[latin9]{inputenc} \usepackage{marvosym} ...
0
votes
1answer
87 views

Setting a new counter to be nested under Chapter number

In my thesis, I'm using a hack in a sty file that adds margin notes with entries in the Index, like so: \newcommand{\thenota}{\thechapter.{\it \alph{notas}}.} ...
5
votes
1answer
315 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} ...
6
votes
2answers
178 views

Use of a macro to set counter value in another macro

I am trying to simply set the value of the counter try which I defined previously to the value of the output of the \foo command. However this does not work. I guess that the problem is coming from ...
2
votes
1answer
76 views

Using arithmetic (other than foreach) to set label of nodes [closed]

I'd like to use integer variables to set the text inside the label of nodes, BUT WITHOUT using foreach (because these variables have their value set according to some conditional processing) Any ...
3
votes
2answers
58 views

Count items later in the document [duplicate]

The question is simple enough: How can I make the following output of my counter (\themycounter) say 6? \documentclass{article} \newcounter{mycounter} \newcommand{\myitem}{\refstepcounter{mycounter}} ...
5
votes
1answer
109 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 ...
6
votes
2answers
448 views

Trouble with Bible Style page header lines

I'm attempting to typeset a Bible for my mom and I'm running into a few problems and I was hoping someone here could help. First I'll start with the easy question. I'm currently using two columns ...
7
votes
1answer
141 views

Count the number of references containing substring in field

I have several references in a document. I'd like to display some statistics regarding the references - for example, citations with author Smith, citations between year xxxx and yyyy, citations ...
5
votes
1answer
135 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). ...
4
votes
3answers
132 views

Theorem numeration shift

I would like to numerate my theorems not by chapters but by shifted chapters in such a way that the theorems in chapter 2 would read Theorem 1.1, Theorem 1.2 and so on. I need something along the ...
8
votes
2answers
151 views

Custom counter steps twice when invoked from caption using caption package

I made a custom counter with a custom command that steps the counter and sets an automatic label for it. However, when invoking this from a caption AND using the caption package, my counter steps two ...
3
votes
1answer
60 views

Use the content of a counter in cline

consider the following example: \newcounter{cnt} \setcounter{cnt}{3} \begin{tabular}{l|l|l|} \cline{2-3} a & b & c \end{tabular} I have a package that generates tables with a ...
5
votes
1answer
512 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: ...
6
votes
1answer
232 views

How to put \value{counter} as value to .aux file?

I'm trying to customize eledmac settings in a way that I can use its footnote ability just like the ordinary LaTeX footnote style, but not as one paragraph per footnote but all footnotes in one ...
13
votes
1answer
213 views

Defining a counter

I'm trying to define a new counter which does the following: \documentclass[10pt]{article} \usepackage{amsmath} \usepackage{amssymb} \usepackage{array} \usepackage{tikz} \usepackage{longtable} ...
3
votes
2answers
134 views

Section numbering with numbering like 1.11

How do I set my section numbers like the given format? I'm in need of the format given below. I'm using gsm-l.cls. I'm just using tags like: \chapter{name} \section{sectionname} \begin{theorem} ...
4
votes
2answers
150 views

The package zhnumber without xeCJK

I need to use the function zhdigits from the package zhnumber to typeset a counter the way I want, i.e. convert 235 to 二三五. This package requires the package xeCJK to work properly, but xeCJK messes ...
2
votes
1answer
103 views

Add prefix command(s) - counter of todos

I would like to see the number of todos I have left. Therefor I tried to redefine the todo command as follows: \newcounter{todocounter} ...
8
votes
2answers
338 views

How can you make custom counter display types?

I'm a comp sci prof working on an exam for my students in LaTeX, using the exam class. I like to throw in a few in-jokes here and there. Unfortunately, the class breaks if you try to use 0-indexing on ...
3
votes
0answers
148 views

Reproduce the beamer miniframes environment

I would like to reproduce the miniframes features of beamer, with the bullets per section even though it would concern the chapters per part. I need a counter counting the total number of chapters in ...
7
votes
2answers
2k views

How to reset section counter

This is the barebones of my document: \documentclass[12pt]{article} \begin{document} \begin{center} \textbf{\LARGE{Topic I}} \end{center} \section{Section I} content \section{Section II} ...
5
votes
1answer
322 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 ...
7
votes
1answer
2k views

LaTeX Error: Command \c@T already defined

this is an easy question, but I couldn't find the answer just from other similar questions. A lot of people often get an error in the form: LaTeX Error: Command \XYZ already defined. ...
2
votes
1answer
137 views

Customised counter macro in fancyvrb

I am using the fancyvrb package in LaTeX2e. I have chosen to display line numbers as I am displaying some code. (The code I am displaying is Maple, which unfortunately is not supported by the ...
6
votes
1answer
286 views

How to repeat a block of code and increment a variable by one each time?

I have many images which I would like to include in a latex document. \begin{figure}[h] \centering \includegraphics[scale=0.15]{DSC_0001.jpg} \end{figure} This block of code only differs in the ...