Tagged Questions

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

learn more… | top users | synonyms

5
votes
1answer
37 views

Total number of longtables (v3.02+)

I'm wondering, are there any ways to get (and forward-reference at the beginning of the document) the total number of tables when using longtables? There are utility packages for standard table ...
1
vote
1answer
66 views

Problem with \addtocounter that doen't affect \label

I've a little issue with \label. here's the code: \chapter{previous chapter} \phantomsection \addtocounter{chapter}{1} \addcontentsline{toc}{chapter}{\Alph{chapter}~~ the chapter} ...
7
votes
1answer
103 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 ...
2
votes
1answer
98 views

How do I enumerate sections with numbers and subsections with letters like this

How do I enumerate sections with numbers and subsections with letters like this: This is a section A. This is a subsection B. This is another subsection. Thanks
1
vote
1answer
85 views

How to refer to a (La)TeX counter early in the document?

I am programmatically typesetting a long document from database contents. For reasons of efficiency, I would like to output all generated LaTeX code as early as possible. I would also like to provide ...
3
votes
1answer
75 views

Counters to be used in section (& similar) titles (any TeX)

I use LaTeX to take notes in University. The notes are divided into chapters which are the single lessons. They are numbered. It's easy to lose track of that lesson number. So I'd like LaTeX to do ...
11
votes
1answer
96 views

Multiple \the… formats for a single counter?

Say I have a definition (\arabic) that includes a small list of sub-definitions (\alph). Sometimes I want to use full cross-references (2.3a, 2.3b, ...). But sometimes, when the main definition is ...
3
votes
1answer
83 views

Printing absolute page numbers

I'm using the pagesel package to output only selected parts of a large document. The page numbers in that document are not absolute page numbers, but pagesel (quite rightly) uses absolute page ...
3
votes
1answer
161 views

Newcommand + Stepcounter

I'm trying to come up with a command which should increase a counter and return a string including the current value of the counter. Have a look at the following minimal example: ...
2
votes
1answer
153 views

Counter too long subfigure

I'm trying to make a igure with more than 26 subfigures, therefore, the counter of the alphabet is not enough since it goes only to the z. I tried as suggested in other posts to use the package ...
2
votes
0answers
69 views

Incrementing counters with subsubsection instead of subsection [closed]

I have previously tried to make a document with questions and answers. In a previous question I was shown a great way to do this, using the answer package in combination with hyperref. Adding ...
1
vote
0answers
21 views

counter by chapter [duplicate]

Im using \usepackage{float} to make my own float of the name Chart. So that i can use \captionof{chart}{<caption>} when insering a chart. I won't the counter to be chapter based so that chart 1 ...
8
votes
2answers
145 views

Customise counters, cross references to environments

I would like to make cross references to own defined counter on environments. So far I have tried the following, \documentclass{book} \newcounter{entryc}[subsection] ...
4
votes
1answer
495 views

siamltx + amsthm: “LaTeX Error: No counter 'Theorem' defined.”

When using the LaTeX class siamltx (from the SIAM page) together with amsthm (which I need for its theoremstyle command), I'm getting the error message ! LaTeX Error: No counter 'Theorem' defined. ...
10
votes
1answer
100 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
146 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
91 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
140 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
64 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
79 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 ...
13
votes
1answer
250 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
111 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 ...
7
votes
1answer
1k 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
281 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: ...
14
votes
1answer
351 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
113 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
101 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
84 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
108 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
69 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
72 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
201 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
99 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
842 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
199 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
116 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
279 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
277 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
66 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
190 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
594 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
88 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
276 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
76 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
78 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
229 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
76 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
205 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
150 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 ...