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

learn more… | top users | synonyms

6
votes
1answer
455 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
300 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
8k 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
420 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 ...
12
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
258 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
298 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
946 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]{ ...
11
votes
1answer
871 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 ...
4
votes
2answers
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
4k 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
695 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
546 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
307 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
698 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
240 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
563 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
341 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
573 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
337 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
606 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
488 views

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

I think Custom calendar using TikZ is useful!
3
votes
1answer
881 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
950 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 ...
10
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
835 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
952 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
589 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
390 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
438 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
973 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
513 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
470 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
659 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
513 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 ...