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

learn more… | top users | synonyms

2
votes
1answer
38 views

Command \alph{counter} compile error

I am trying to write a template for writing tests and homework for math classes in the familar format: 1) Given . . . a) question . . . b) question . . . Here is what I have tried: \...
2
votes
1answer
54 views

Why does my custom sectioning command crash on second run when using etoc?

Finally I have narrowed down the problem to a custom definition of a sectioning command using titlesec in explicit mode. I suspect it has something to do with me not providing an adequate counter for ...
4
votes
1answer
179 views

How to draw the clock cycle number to the rising edge?

I want to display the number of every clock cycle at the rising edge. I tried to setting a counter but it gives me this error: Package pgfkeys Error: I do not know the key '/tikz/timing/counter/new',...
9
votes
2answers
253 views

How to assign TWO parents to LaTeX counter?

I am working on a own LaTeX (using KOMA-Script) class, based on scrartcl. The document structure is supposed to provide sections and subsections, as well as own environments (exercises, solutions, ...
3
votes
2answers
91 views

Counters, assignments, and groups

I have learned at my own expense to be careful with scratch counters. However, I recently encountered a situation I cannot understand. Consider the following code \documentclass{article} % print the ...
0
votes
1answer
87 views

Beamer pause and numbering [duplicate]

I'm trying beamer for the first time (but have some experience with LaTeX). I want to use \pause and number some problems, but the numbers increment when I don't want them to. There must be a simple ...
3
votes
1answer
91 views

Increase counter for each line in custom align environment

What is a good way to advance the counter in a custom align environment? I defined the regalign environment below, but to get the counter to advance with each line, I had to define a new command (\...
4
votes
1answer
194 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 ...
1
vote
1answer
48 views

Automatically reset the counter of a custom-defined sectioning block with titlesec

I added a custom sectioning block to my document following the instructions I found on this question: Defining custom sectioning commands. Below is a mvce: \documentclass[12pt]{article} \usepackage{...
16
votes
2answers
1k views

What is the maximum integer that can be saved in a LaTeX counter?

I am using counters to save positive integers, something like that: \setcounter{mycoutervalue}{59} Is there any limit in the value I can save in a counter, in this case mycountervalue? And what is ...
3
votes
1answer
68 views

How do you set page numbering on the “part” page?

I'm trying to get something together for my thesis and part of the organization I would like to use employs the \part{} feature (it is to the chapter what a chapter is to a subsection). The beginning ...
2
votes
1answer
41 views

totcount gives wrong chapter count when appendices present

I found that totcount gives the wrong chapter count when appendices are present. In the following MWE, the chapter count should be 3 but is actually 1: \documentclass{report} \usepackage{totcount} \...
5
votes
1answer
209 views

Counter Not Incrementing

I'm trying to typeset a document in amsart and I wasn't familiar with the counter used for sections, so I just redefined the section environment to try to get the look I'm going for... unfortunately, ...
1
vote
1answer
204 views

\setcounter{section} numbering not working

Here is what I am working with: \documentclass{amsart} \newcounter{mysection} \let\realsection=\section \renewcommand\section[1]{\refstepcounter{mysection}% \subsection*{\themysection.\space #1} } ...
2
votes
1answer
47 views

Reset counter in new \chapter before the first \section

\newtheorem{lemma}{Lemma}[section] \chapter{First chap} \section{First sec} \begin{lemma} this one is correct. \end{lemma} \chapter{Second chap} \begin{lemma} This number is wrong. \end{lemma} \...
1
vote
1answer
101 views

Multirow reacting to rownumber instead of linenumber

I'm trying to create a table in LaTeX which contains a multirow as height as the rest of the table. This table appears lots of times in my document. The problem is that the second row can contain ...
2
votes
1answer
63 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 ...
5
votes
1answer
107 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
152 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
82 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 ...
2
votes
1answer
22 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
84 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
163 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
90 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 ...
4
votes
1answer
140 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: http://www.pnas.org/site/misc/PNASTWO....
2
votes
2answers
171 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
44 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. \begin{...
1
vote
1answer
43 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
63 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
46 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
56 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 \Alph{...
2
votes
1answer
73 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
56 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
47 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
58 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
77 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
14 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
96 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 ...
1
vote
1answer
67 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 numbers/...
4
votes
2answers
130 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} \usepackage{...
1
vote
1answer
114 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
84 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
142 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
267 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} \...
7
votes
3answers
216 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
81 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
39 views

edit an environment to add to a new extra parameter

I'm trying to define a new \newenvironment but I'm having some problems. I need an environment that uses a counter and uses an extra parameter to write some text. I'm working with this environment: ...
0
votes
1answer
56 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 \addcontentsline{...
4
votes
2answers
225 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
261 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 ...