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

learn more… | top users | synonyms

4
votes
1answer
158 views

How do I determine the name of the counter associated with a theorem-like environment

(A question related to this one and leading up to this one.) Suppose I'm using ntheorem. I would like to have a command which determines the name (not the value) of the counter associated with a ...
4
votes
1answer
876 views

Easy-to-use reference-able environment for restating theorem-like environments?

This question is a development of the same issue as this one; following my own answer and later comment there, I decided it deserves a spin-off. I would like to define an environment for restating ...
10
votes
1answer
1k views

How to count number of lines in PDF document?

I'm using the lineno package to print line numbers (each page starts with number one) in the draft of my document: \usepackage[switch*, pagewise]{lineno} Is there a way to read out the number of ...
11
votes
2answers
271 views

Hiding a counter if it is only displayed only one time

I have two macros on my document. \showcounter increases a counter, then displays it. \resetcounter sets the counter back to "0". \documentclass{article} \newcounter{counterone} ...
13
votes
2answers
265 views

How to refer to a chapter with a word

I would like to refer to my chapters with the notation "First Chapter", "Second Chapter" etc, rather than "Chapter 1", "Chapter 2", etc. How can I do this? \documentclass{scrreprt} ...
12
votes
3answers
2k views

How can I calculate the difference of 2 counters (pageref)?

How can I calculate the difference between 2 counters (like page numbers), so that pdfLateX outputs "3" in the last line of my example? and how could I calculate the difference between the "current" ...
15
votes
2answers
322 views

A new kind of “symbol wrapping”

alphalph defines three methods for continuing a set of symbols if you hit the end. alph continues like so: a,b,c…z,aa,ab,ac… mult continues like so: a,b,c…z,aa,bb,cc… wrap continues like so: ...
9
votes
2answers
1k views

Combine two items in an enumerated list

Is there an easy way to combine two items in an enumerated list? For example: 1. First bullet 2-3. Second bullet 4. Third bullet My current plan involves screwing with \labelenumi and then ...
7
votes
2answers
262 views

Setting a counter for sections

I prepare a document where there are questions as follows and the relevant content \section*{Question 1} ... \section*{Question 2} ... \section*{Question 3} ... ... I want a counter instead of ...
6
votes
1answer
391 views

How can I reset sectional counters in memoir class to avoid breaking ToC cross-referencing in a complex document?

I have already asked a similar question here: Incorrect ToC/Index cross-references when resetting memoir class counters and received a satisfactory answer. Now, I wish to apply the chapter counter ...
6
votes
4answers
1k views

How do I make a counter start with 1?

I defined a counter like this: \newcounter{my_steps}[subsubsection] and I would like to make it start with 1 instead of 0 after each subsubsection. How?
3
votes
1answer
1k views

Defining repeated tabular/array columns using a computed value to specify the number

Background: I just recently saw that one could define multiple columns in a tabular or array using the syntax: *{num}{<align>} So, for example \begin{tabular}{r*{3}{l}r} is the identical to ...
3
votes
2answers
629 views

mdframed and ntheorem counters

In the code below, counters defined by mdframed seem to not be accessible to ntheorem environments which is problematic but ntheorem counters can be read by mdframed. I could not find a work around ...
6
votes
3answers
561 views

Odd interaction of secnumdepth and section-based counters

In the following MWE: \documentclass{book} \newcounter{exnum}[subsection] \begin{document} \chapter*{Chapter} \section*{Section 1} \subsection{Subsection A} \setcounter{exnum}{1} ...
23
votes
1answer
2k views

What are the differences between TeX counts and LaTeX counters?

The title already states the whole question. It has been answered by Joseph Wright at http://www.texdev.net/2009/11/17/tex-counts-and-latex-counters/, but I have not seen the according answer here at ...
27
votes
3answers
1k views

How to display the final value of a counter at the beginning of a document?

At the beginning of my document, I have created a counter using \newcounter. Over the course of the document, this counter is increases using \stepcounter. How can I display the final value of the ...
8
votes
4answers
434 views

Slave duplicate counter

Is it possible to create a counter that is a "slave" to another (master) counter, but also an exact duplicate? The \@addtoreset{<slave>}{<master>} resets <slave> whenever ...
1
vote
1answer
445 views

How to create a new counter for an a new environment that is in sync with subsections

I want to create an example environment with a counter which will be in sync with my subsections. So I'll have: subsection 3.2 lemma 3.2 example 3.2 example 3.3 lemma 3.3 subsection ...
2
votes
1answer
497 views

Should this combination of counters and \ifnum conditions work or does it need modification? Is there a better way?

I'm producing the final product of my thesis with LaTeX. I'm having trouble with the front matter of my thesis, specifically with getting LaTeX to recognize that if the front matter stops at a certain ...
3
votes
3answers
2k views

Table of Contents numbering in decimals?

I have created my first LaTeX document, its very small and have 4 sections. The problem is the numbering is in decimals and looks a little odd, I have searched every where, I'm sure its a simple fix. ...
6
votes
1answer
531 views

Incorrect ToC/Index cross-references when resetting memoir class counters

The quasi-MWE below uses the memoir class and works fine. It produces a document with the following structure: ToC Book Part1 Chapter1 Part2 Chapter2 Index Here, cross-references in the ToC and ...
11
votes
2answers
443 views

Middle age roman numerals formatting

I've recently read about a middle age variation on roman numerals where the last "i" character is replaced by a "j". I was thinking about writing my own \roman and \Roman variations, but hit a stone ...
0
votes
1answer
325 views

Counting letters inside paragraph

I am trying to make a new command \part which is defined such that each time I type \part the output equals \paragraph*(letter) where letter is bold. So, with typing the letter manualy in, the ...
2
votes
2answers
152 views

Cross-referencing to the number of a customized environment with a counter

On the internet I found a possibility to create an example environment that is helpful for linguistic research papers, because it provides all examples with numbers: \newcounter{exa} ...
4
votes
2answers
477 views

Numbering theorems within the innermost sectioning environment present at that point in the document?

Here is what I am trying to achieve: Chapter 1. ... Theorem 1.1. ... Section 1.1. ... Theorem 1.1.1. ... Subsection 1.1.1. ... Theorem 1.1.1.1. Is this even possible? If so, how? ...
2
votes
1answer
528 views

New sectioning level above section

I would like to create a newcounter (lectcount) which will be one level above the "section" in article class, and use its name in the headings (I am using fancyhdr). I don't know how to set the ...
29
votes
5answers
4k views

How to output a counter with leading zeros?

I can output the value of a counter in a LaTeX document via: \setcounter{mycounter}{1} \arabic{mycounter} Which inserts a 1. But how do I format the output by, for example, adding a leading zero if ...
2
votes
1answer
778 views

Refering to the same (alphabetically “numbered”) footnote more than once

Following my previous post concerning the change of numbering in footnote to temporally be alphabetical, I'm trying to merge this with the possibility to refer various time to the same footnote as ...
12
votes
3answers
8k views

Change footnote “numbering” temporarily

I would like to change my footnote "numbering" style temporally to letters (a,b,c ...) the default numbering beeing numbers (1,2,3 ...). This is needed only for specific paragraph, so I can't use the ...
3
votes
2answers
559 views

Increment custom counter with standard sectioning command?

My document is a (scr)book and I'm talking of parts and chapters here, but I think the underlying question is pretty generic. I want tables in the book to be enumerated continuously, in a ...
6
votes
1answer
480 views

Determine number of lines in a verbatim environment

I'm trying to implement two new key-value pairs for the fancyvrb package: head= and tail= specify how many lines to display: That is, head=10, tail=5 specifies to print the first 10 lines of the ...
8
votes
6answers
1k views

How to split an example into two parts?

I am trying to have an example (using the theorem environent in amsmath) split in two parts: Example 1 ... Some more discussion Example 1 (continued) ... What is the best way to do this ? The ...
2
votes
1answer
307 views

Changing \@itemdepth value to control indentation

I would like to be able to control the nesting level of an item (so that I can align the text with text that is at a deeper level of nesting.) I have been able to read the value of \@itemdepth ...
5
votes
1answer
9k views

Changing number within \numberwithin causes malfunction but no compile error

An interesting one here. It could be a bug or I might be missing a trick. In my thesis I use \numberwithin{}{} to have numbering done within sections. Top level is chapter, so it goes ...
4
votes
1answer
442 views

Command to find current enum depth?

I was wondering if there was a command to find what at what depth of the enum counter (i.e. enumi, enumii, etc.) a command was at compile time. I'm attempting to create a \question command. What I ...
13
votes
3answers
2k views

Number exercises according to chapter

I'm using the exercise package together with memoir class. How do I number my exercises according to chapter number, in the same way that display equations are numbered? Here's a minimal example ...
2
votes
1answer
265 views

Hyperref problem with enumerated tabularx rows

I was trying to do an enumeration with columns, which references one item from another one in the same list. I figured out that the best way is to make a table with enumerated rows. I had a working ...
3
votes
3answers
304 views

Show “Page X of Y” only if there are multiple pages?

I'm trying to add a line in the header to be "Page X of Y", but only if there are multiple pages. My main problem is how to format the if statement. So far I have \ifx \pageref{LastPage} 1 ...
1
vote
1answer
1k views

How to avoid beamer counter incrementing

In Latex beamer, I've created a handout environment for slides that are for the produced handout only (ie. not to be shown on the viewer). It looks like this: \newenvironment{handout}[2][1]{ ...
12
votes
1answer
924 views

Why do \setcounter and \addtocounter commands have global effect, while \setlength and \addtolength commands obey the normal scoping rules?

The \setcounter and \addtocounter commands have global effect, while the \setlength and \addtolength commands obey the normal scoping rules. Why were they designed like this? Why are ...
5
votes
3answers
2k views

How to get autoref working with different counters for different listing environments?

In my document I want several different custom listing environments. The solution from fraktalek works like a charm, except for one thing: \autoref doesn't work for me. I have tried the following: ...
9
votes
3answers
5k views

Resetting theorem counters: \section and (missing) \subsection

Suppose I define a new theorem "Theorem" and declare that its counter should be reset whenever the subsection counter is incremented or reset: \newtheorem{theorem}{Theorem}[subsection] At some ...
3
votes
2answers
2k views

Resetting newtheorem counter

This one is probably straightforward, but I'm not missing something with the newtheorem environment and using newcounter. I would like a new environment on its own counter like "Environment M.1", but ...
6
votes
3answers
741 views

Extract document statistics? - How many pages has chapter xy? Count fixmes?

I have a large pdflatex document where each chapter is located in an extra text file and included with \include{chapter3.tex} ... How can I extract the page numbers of each chapter and write them ...
3
votes
1answer
556 views

Why does hyperref bookmark work?

The \appendix command resets the section counter to zero: *\documentclass{article} *\show\appendix (/usr/share/texmf-texlive/tex/latex/base/article.cls Document Class: article 2007/10/19 v1.4h ...
8
votes
2answers
325 views

French chapter numbers

This question led to a new feature in a package: impnattypo French typography recommends that chapters be numbered in uppercase roman numbers, except for chapter 1 which should be called ...
18
votes
3answers
750 views

Should LaTeX counters always be modified globally?

In this answer, egreg states that "LaTeX counters should always be modified globally". However, the etoolbox package provides the \defcounter macro which will assign a value to a previously ...
4
votes
1answer
244 views

Length needs backslash but counter does not, why?

\documentclass{minimal} \parindent=0sp \newlength{\Length} \setlength{\Length}{1in} \newcounter{Count} \setcounter{Count}{10} \begin{document} \the\Length \theCount \end{document} Length needs ...
4
votes
1answer
266 views

How to get a customized counter

I would like to change my equation counter for a specific chapter to a customized one, for example: EQ.1, EQ.2, EQ.3. Does anyone know how to do it?
5
votes
3answers
598 views

Programmatically setting a counter to a substring

I'm trying to set a counter based on the name of the current job. I've got the number I need by doing something like \substring{\jobname}{5}{5}} using the stringstrings package, and if I just output ...