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

learn more… | top users | synonyms

18
votes
3answers
681 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
239 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
260 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
548 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 ...
1
vote
1answer
338 views

Problems using \def commands inside an environment

In trying to build the commands \sol and \solutions to use them inside the exercises environment. The commands must work in this way: \begin{exercises} \exer text for exercise 1\sol{solutionA} ...
22
votes
2answers
566 views

What is the proper method of accessing a counter?

It seems that there are different ways of accessing counters. I have been using \theMyCount as in this post about Using counters or macros, but noticed that the arrayjobx package uses ...
10
votes
4answers
5k views

custom counter and cross-referencing

I created a custom counter 'rtaskno' and a command '\rtask' as following: \newcounter{rtaskno} \newcommand{\rtask}{% \stepcounter{rtaskno}% \thertaskno} I like to use them as following: ...
14
votes
2answers
1k views

Using counters or macros

Should I use counters or macros to store numerical data? Is there a limitation on a number of counters that can be used at the same time or other considerations? I would also like to perform simple ...
5
votes
2answers
335 views

How to decorate a LaTeX command

I've been trying to change the numbering behavior of subsection to use a global counter. I first did: \newcounter{maincount} \renewcommand{\thesubsection}{\stepcounter{maincount}\arabic{maincount}} ...
3
votes
2answers
599 views

LuaLaTeX and counters

I'm trying to use values from expanded macros within a direct lua block, but I can't figure out how to get a value from any macro that has braces in it. \directlua { tex.print(\value{footnote}} } ...
0
votes
1answer
481 views

How to mod a counter's value? [closed]

I think Custom calendar using TikZ is useful!
3
votes
1answer
864 views

Custom numbering of listings

I have a number of listings in my document, numbered 1, 2, 3 and so on. I need a table with three listings (say, three different variants of the same algorithm), that will be numbered as 2a, 2b, 2c. ...
9
votes
2answers
8k views

How to increase counter for \subsection

How can I make the first subsection under a section start on "d"? I currently have the following code to get a,b,c,d...: \renewcommand{\thesubsection}{\alph{subsection}} and I tried this to make it ...
35
votes
2answers
930 views

Can I count the number of times each reference is cited?

I am writing a paper, and I would like to be able to find out automatically how many times each reference is cited. This could either be appended to the references in a printed version, or outputted ...
9
votes
3answers
2k views

How to reference part of a theorem?

I have a corollary with a number of parts whose parts need to be referenced individually later on, so something like: \begin{cor}\label{cor} \begin{enumerate} \item Part one \label{partone} ...
6
votes
1answer
6k views

pdfTeX warning: destination with same identifier has been already used, duplicate ignored (weird behavior)

Here is a minimal example: \documentclass{amsart} \usepackage{amsthm} \usepackage[pdftex]{hyperref} \newtheoremstyle{myexercise}{\baselineskip}{\baselineskip}{}{}{\bfseries}{.}{ ...
18
votes
2answers
827 views

Check if an entry is cited multiple times

I am trying to find out whether it is currently possible to have a test in Biblatex that tests at the very first time an entry is cited whether the same entry will be cited more than once in the ...
6
votes
2answers
1k views

TikZ counter and logical comparison

Does TikZ have counter that is similar to for loop in c language and logical comparison? e.g., \foreach \x in {0mm,11.200000mm,...,33.600000mm} { counter++; <== is this possible in tikz ...
5
votes
2answers
4k views

Access the chapter/section number and the chapter/section label through variables

Often I find myself in the situation that I'd like to design how chapters and sections look. I know there are packages that help to design such things, but non of them seems to give me the option to ...
4
votes
2answers
941 views

Using one counter for different floats?

I'm using two different floats, and I'd like to use the same counter for both. The standard LaTeX format for a new float is: \newfloat{type}{placement}{ext}[outer counter] I tried using this by ...
7
votes
3answers
581 views

Changing the section number to a fraction

In between two sections that really ought to be numbered 23 and 24, I want to add another section, which I would like to call 23.5. The code \setcounter{section}{23.5} \section{...}, however, results ...
5
votes
1answer
379 views

Change colour depending on counter

I have some text that I want to change colour depending on the current state of a counter. But I can't get this file to compile. (This is obviously simplified, since the texcolour command is actually ...
9
votes
3answers
437 views

Making register declarations local, Undefining a register (count, toks, etc.)

Is it possible to make \newcount, \newtoks, etc. respect grouping, so that, e.g., \newcount\temp\temp=2{\newcount\temp\temp=1}\showthe\temp gives 2 (instead of 0)? Relatedly, is it possible to ...
5
votes
1answer
965 views

Beamer overlay and counter

I have a counter that I want to use for the beamer \onslide command. Using \newcounter{coun} %.... % \onslide<\coun ->{ ....} doesn't work. What is the correct way to do this?
7
votes
2answers
1k views

Building labels out of counters

There is a simple version to my question, and a complex version. First, the simple version: I want to generate label names by combining a constant string with a counter's value, something like what is ...
9
votes
1answer
1k views

Refer to customized `enumerate` counter

Background I'm typesetting a list of conditions for a certain mathematical object. There are three conditions. Later on I wish to provide an equivalent condition for the third. Therefore, it would be ...
20
votes
2answers
3k views

Wrong (hyper-)references after resetting chapter counter

The following MWE produces a PDF whose TOC has two entries: “Foo” and “Bar” with correct page numbers. So far, so good. However, upon clicking on the link to “Bar”, I am taken to the page for “Foo” ...
3
votes
2answers
507 views

Unexpected tikz/counter behaviour

What I've been trying to do, futilely, is to use the foreach[counter=\xi] x in {1,2,3} statement in tikz/pgf with LaTeX. This fails, every time. Whatever. So I moved on to trying to use a counter, ...
4
votes
1answer
464 views

Booleans fail in tabular environment

I've got a workaround for this problem, but maybe someone knows a cleaner way to fix it. I'm using the standard packages in TexLive 2009. Here's the code that doesn't work: \documentclass{article} ...
12
votes
3answers
654 views

Setting Initial Page number on command-line

I would like to typeset a LaTeX file and set the initial page number from the command line (as I need to often change it to merge with different documents). I thought that the following would work, ...
-1
votes
1answer
512 views

restating a theorem using theomac.sty

I am trying to restate a theorem environment using theomac.sty which floats around, following a suggestion I received here: how do I refer back to counters? The package I downloaded loads well, but ...
1
vote
0answers
295 views

how do I refer back to counters? [duplicate]

Possible Duplicate: How do I repeat a theorem number? I want to set up a simple macro that would do the following: It would be very similar to \label{XX}, (say, \relabel{XX}) only instead ...
3
votes
1answer
5k views

Setting \setcounter{tocdepth} for an individual chapter

Hiya, Is it possible to set the \setcounter{tocdepth}{..} for one chapter only? The default depth is fine for the entire document, except for the last chapter- I only want the chapter title to appear ...
11
votes
1answer
206 views

How can I do something after the next pagebreak?

I'm writing a document where I say something like "if you look at Figure 1 on the next page, then you will see that blah blah blah". So what I want to do is have latex skip a number when numbering ...
11
votes
2answers
1k views

How to set a marker/counter/label to an arbitrary piece of text?

Is it possible to attach a marker to just a place in text, not to section, sub-section, etc.? This is what I'm trying to achieve: \begin{document} Alex (see~\ref{alex}) is a boy, Jessica ...
10
votes
2answers
2k views

Listings: different counters for different listing environments

How do I create two lstlisting environments that each have its own counter? If I use for example \lstnewenvironment{algorithm}[2]{ \renewcommand\lstlistingname{Algorithm} \lstset{ ... } } ...
5
votes
1answer
173 views

How to output the final value of some counter, like number of figures or tables in the middle of the document?

I need to put some formal statistics on the document itself somewhere in the middle, like "This document contains XXX figures and YYY tables (and may be even ZZZ formulas and PPP theorems)". Is there ...
19
votes
3answers
2k views

footnote counter, would like to restart from '1' each page

I would like the footnote counter to automatically restart from '1' for each page of my document.
12
votes
1answer
942 views

Infinite-depth list

I want to create a command set that allows me to do something like \nestedlist{ \listitem An item \sublist{ \listitem A sub item \listitem Another sub item } } and get An item 1.1 A ...
17
votes
2answers
530 views

Automatically numbering constants

I would like to somehow use LaTeX to automatically number constants. Some background As a mathematician, in my daily work there are a lot of throw-away constants which are not extremely important ...