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

learn more… | top users | synonyms

10
votes
1answer
79 views

Use node name with arithmetic counter expression

I want to call a PSTricks macro with a node name which involves the result of an arithmetic expression with counters. Consider the following, not working example: \documentclass{article} ...
6
votes
1answer
98 views

Problem with macro using \newcount in \caption

I have a macro \foo that performs arithmetic on it's argument: \documentclass{article} \newcommand{\foo}[1]{ \newcount\tmpR \tmpR=#1 \advance\tmpR by -1 R{\number\tmpR} } ...
6
votes
1answer
84 views

\alph without counters

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
2answers
103 views

How to repeat chapter numbers

I'm writing my Ph.D. thesis, and I have to write the Introduction both in English and in Spanish. Since the content is the same, I want to repeat the number of this first chapter: Introducción. ...
6
votes
1answer
50 views

Why doesn't fancyhdr like random numbers?

In the following MWE I use \lhead{\stepcounter{step}\arabic{step}} and it works perfectly, incrementing by 1 each page. I also use \chead{\setrand{100}\arabic{rand}} and get the same number every ...
1
vote
0answers
47 views

Counter in fancyhdr not matching body

I'm trying to set a counter that says "x of 3" at the right header where x increments based on when I use \pgroup. However it shows "2 of 3" on the first page and then "3 of 3" on the second and third ...
11
votes
1answer
119 views

How to make figure and listing share their counter

I'm using the "listings" package to write pieces of code (XML, RDF, Java, etc) and I want them to have the same counter of the Figure environment. For example, Listing 1: blablabla Listing 2: ...
4
votes
2answers
59 views

Temporarily resetting figure counters within a chapter

The code below works perfectly in an article (permitting me to put two captions in the same figure and have one of them called Table, picking up the table counter—there’s a sensible reason for doing ...
5
votes
1answer
379 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 ...
6
votes
2answers
144 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: ...
13
votes
1answer
196 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 ...
4
votes
2answers
70 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
89 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
66 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
89 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
48 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
68 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} ...
8
votes
4answers
167 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
84 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
737 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
157 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
87 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
106 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
138 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
63 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} ...
8
votes
1answer
142 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 ...
12
votes
1answer
374 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
74 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
131 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
64 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
73 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
142 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
68 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
127 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
119 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
70 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
52 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
72 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 ...
2
votes
1answer
198 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
93 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
102 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
114 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
95 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
43 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 ...
4
votes
1answer
132 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
169 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
162 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
97 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
108 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 ...