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

learn more… | top users | synonyms

2
votes
1answer
34 views

How can I redefine the description list to pass an arg to redefined items that contain TikZ nodes?

I am open to suggestions regarding my question's wording. I would like to have all description lists support an optional argument that represents node name prefixes. This will be passed to the ...
4
votes
1answer
19 views

Reset `equation` counter for any section change, regardless of section depth

I would like the equation counter to reset automatically whenever a \section command is called, independent of section depth: \section \subsection \subsubsection \paragraph \subparagraph MWE ...
2
votes
1answer
70 views

Print iteration counter in for loop

I am new using for loops in latex, and not sure if the following is possible. This is basically what I am trying to achieve: \documentclass{article} \begin{document} \foreach \x in {a,b,c} { ...
0
votes
1answer
24 views

how to create a list for mdframed example boxs

So i found the question Make an Example and shaded box like in the book which fitted to my desires. I modified the box and counter so it fits to my whishes. (first number is the chapter second number ...
1
vote
1answer
17 views

Using undefined references to set counters

Consider this example where a number from a previous reference is being used to set a counter. \documentclass{article} \begin{document} \begin{enumerate} \item \label{e:one} One \end{enumerate} ...
2
votes
1answer
19 views

\refstepcounter within \subsection breaks \ref to \subsubsection

Usually a \ref to a \subsubsection gives 1.1.1 (from the parent \subsection). Sample: \documentclass{book} \begin{document} \chapter{chap} \section{sec} \subsection{sub} \subsubsection{subsub} ...
2
votes
1answer
64 views

Filename in line 0 of a lstlisting

I'm trying to write a lstlisting-environment which sets the filename as line 0. I tryed \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{listings} \lstset{numbers=left} % @param 1 : ...
1
vote
1answer
21 views

How to redefine the section counter in amsart? [duplicate]

I'm using the document class amsart, which defines the section counter as follows: \newcounter{section} However, I want the section counter to reset to zero every time I start a new part. Thus, I ...
2
votes
1answer
31 views

Why does subsection counter not reset in appendix?

So when I put subsections in the appendix, the counter does not reset after starting new chapters. I'm about to change the subsections to unnamed sections, but still wondering why the counter does not ...
4
votes
1answer
37 views

Error when >9 affiliations are added in PNAS (pnastwo.cls) LaTeX template

I ran into the following error when attempting to add more than 9 affiliations in the author list using the pnastwo.cls PNAS LaTeX template file (available here: ...
2
votes
2answers
150 views

Accessing value in forloop

This code is not compiling and creates an error "Missing number, treated as zero". \newcounter{x} \forloop{x}{0}{\value{x} < 5}{ value is \value{x} \\ } How can the value of x be printed ...
3
votes
2answers
30 views

How can I print beginning and end values of a counter within an environment?

I'm working on a formatting system for standardized tests. Within each section of a test, there are groups of consecutive questions that I might choose to contain inside an environment. ...
1
vote
1answer
22 views

Use macro as totcount counter name

In the top level of the document environment, a macro defined (using \def) can be expanded into the name of a totcount counter. This, for some reason, does not work inside an environment definition. I ...
2
votes
2answers
34 views

How to use \ref to print the value of a counter the way it was originally produced?

I want to number the lines in a table with roman numerals, and then when I cross-reference them have the reference printed in the same way. For example, \documentclass{article} \begin{document} ...
1
vote
2answers
33 views

Dynamic chaptername wrong in tableofcontents

I want to print my appendix-titles with the prefix "Appendix A: [some title]" , "Appendix B: [some other title]" ... . I used the following defined commands (runnable tex-document at the end): ...
1
vote
0answers
39 views

Created counter ist counting twice (sometimes) [closed]

I wanted to create a couter to count additional chapters (appendix of the thesis). \newcounter{anhangCount} \setcounter{anhangCount}{0} \DeclareRobustCommand{\anhangPraeFix}{ Anhang ...
2
votes
1answer
37 views

How to do IF counter+1 < … THEN nicely for beautifying Biblatex backreference

This article and snippet: BibLaTeX: Customizing backreferences Produces: [4] “Tile 3”. In: () (Cited on pages 1, 2, and 3). Now I want to get the rid off this last comma (Oxford comma) after ...
1
vote
1answer
36 views

Custom item in enumerate

I would like to have an enumerate - list in which, after 1, 2, 3, 4, I need to put 4bis. How to do it?
4
votes
0answers
46 views

What does `\escapechar` do? [duplicate]

In latex.ltx you can find several situations where \escapechar is set to -1 -- from what it's clear that it has to be a count register. But, what does it actually "count" or control? A small ...
5
votes
1answer
43 views

Can \totvalue be called in the preamble?

I am trying to use the totcount package, and I noticed some strange behaviour I cannot explain. With the following MWE : \documentclass{book} \usepackage{lipsum} \usepackage{totcount} ...
2
votes
1answer
39 views

Reset counter with starred sections as well (example using exsheets)

I am typesetting exercise/exam sheets with the “exsheets” package. It allows me to reset the question counter with every other counter step (e.g. with every section). Unfortunately this does not work ...
2
votes
0answers
11 views

Referencing custom counter [duplicate]

I want to define a new counter for numbering some headlines. I also would like to reference them. So, if I label the headline 3, then \ref should just return the number 3. Unfortunately, all other ...
3
votes
1answer
69 views

Increasing number in a text automatically

Is it possible in Latex to set in the "middle" of a text a field or another thing, that increases a number (without having to do this by hand)? For example: M-ERF020 M-AUSW030 the numbers between ...
0
votes
1answer
23 views

Is it possible to call/reference sagetex within a latex command?

I'm doing a few projects in which it would be very helpful to get some numbers from a sagetex environment, and then directly using them within latex. I know Latex isn't great at storing ...
4
votes
2answers
81 views

Resuming a list (for nested lists)

I'm trying to resume a list by storing and restoring the counter. This works fine (as described here), but I fail to do it for a nested list. Here's my code: \documentclass{article} ...
1
vote
1answer
40 views

exercise package; how to get counter for a custom exercise type to increment with memoir sections?

Just started learning LaTeX, because I'm trying to write a short math book. I started out using LyX, but ultimately I want more control over the typesetting, so I have to learn LaTeX. Anyway, I want ...
4
votes
2answers
27 views

Creating a new float environment without the numbering but still displaying the float type

So I would like to create a new float environment using the float package (for example) but without a counter: \documentclass{article} \usepackage{float} \floatstyle{ruled} \newfloat{afloat}{t!}{log} ...
4
votes
1answer
119 views

Starting counter from 0

I'm working on a sheet of exercises using LaTeX. I've set up my sections to look like Exercise # | <title>. How can I force the section counter to start from 0, so that I can have an exercise 0 ...
5
votes
1answer
122 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
3answers
123 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} ...
3
votes
3answers
68 views

Saving counters

Consider the situation: Two authors A,B (in fact, it will be four) inserting comments on a tex file. Each author has his own command \alertA and \alertB to insert comments. Each author should has ...
3
votes
1answer
36 views

edit an enviroment to add to a new extra parameter

I'm trying to define a new \newenviroment but I'm having some problems. I need an enviroment that uses a counter and uses an extra parameter to write some text. I'm working with this enviroment: ...
0
votes
1answer
27 views

Error; bookmark in PDF

I have this problem in LaTeX when I use; \addcontentsline{toc}{section}{Resumen} \section*{\bf Agradecimientos} \addcontentsline{toc}{section}{Agradecimientos} \tableofcontents ...
4
votes
2answers
131 views

Count number of elements in a list

This question is somewhat similar to Count the number of elements of each size in a list. It should actually be simpler but I nevertheless can't figure out how to do it without using the same code as ...
2
votes
1answer
114 views

\label is forcing roman numerals into arabic numbers

I am trying to put a caption and label on a table for a lab report. My professor insists that we use roman numerals for tables e.g. (Table IV). But the \label command is forcing 'IV' into '4' when I ...
1
vote
2answers
88 views

How to set a simple counter in a certain chapter

How can I set the equation counter to behave differently for a certain Chapter? I am writing my phd thesis, and I want to have a simple equation counter for the introduction. In general, ...
3
votes
2answers
159 views

Loop to create new counters

I want to create counters in a loop like this (with the packages multido, totcount) : \newcounter{compteurChi}% first counter \regtotcounter{compteurChi}% define the first counter as a ...
8
votes
3answers
320 views

Counting backwards

The following produces a counter that counts in increasing arabic numerals. \documentclass[12pt]{article} \pagestyle{empty} \begin{document} \newcounter{myCounter} \addtocounter{myCounter}{1} ...
2
votes
1answer
118 views

Get number of each slide and total slides with respect to the whole presentation

I need to get the number of each slide and the total number of slides in order to calculate the progress of my presentation, but I can only do this for frames, as my MWE below shows. Basically I need ...
0
votes
1answer
53 views

Dot before Chapter and Section numbers

My Chapter numbers come out to me Chapter .1 instead of Chapter 1. This problem persists throughout in section as well as ToC. A similar question is answered earlier, Dot before numbering, but it ...
3
votes
1answer
48 views

How change numbering table just in one chapter?

I have set book and numbering a table is 1.1...second chapter 2.1.....and one chapter just in one I need numbering my table just table 1 table 2.... any help ? ...
2
votes
0answers
36 views

Two different counters in chemnum package

Is there any possibility to use two independent counters within the chemnum package? I would like to label (by replacing the tags in my .eps file) substances in reactions and steps in catalytic cycles ...
9
votes
1answer
297 views

How to count the total number of sections within a chapter?

How can one count the total number of sections within each chapter? I am trying to use the totcount package, but it returns the total number of sections of the last chapter, not total number of ...
3
votes
1answer
25 views

one counter for multiple theorems?

I searched the internet for a while now but didn't quite get what i wanted. I want number different theorems with the same counter, which depends on chapter and section. eg Lemma 1.1.1 Example 1.1.2 ...
3
votes
2answers
30 views

Numbering of items in a chapter

I am writing my thesis with book class. All but one of the chapters have subsection. For the particular chapter without a subsection, the first definition number comes as 2.0.1. The 0 is for the ...
3
votes
2answers
45 views

Do a setcounter only for an included file

I have currently the following situation: I am including a Latex-File in my main file. This file already has several \section{}-parts. Now I want to let their counting begin at 1 again, but without ...
4
votes
1answer
57 views

Setting a counter to a value obtained by expansion

I use the glossaries and minitoc packages. Minitocs are generated for all glossaries printed in the table of content, eg with the toc option for the glossaries package. When one prints the glossaries ...
4
votes
2answers
110 views

Add version number to document from file

I have been going crazy looking for a solution. Essentially, I need to add the version number of the document somewhere on the title page. What I want to do is have a file such as version.tex which ...
5
votes
3answers
75 views

Own counter starts at 3 in tabularx environment

the following example shows that the self defined counter in the tabularx environment does not start with "1". Can't figure out how to define the command to always start with "1". Ideas? ...
5
votes
2answers
153 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} ...