Questions tagged [counters]

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

Filter by
Sorted by
Tagged with
16
votes
2answers
12k views

How to reset section counter

This is the barebones of my document: \documentclass[12pt]{article} \begin{document} \begin{center} \textbf{\LARGE{Topic I}} \end{center} \section{Section I} content \section{Section II} ...
4
votes
1answer
892 views

Problem with counter and \pause

I am trying to create a manual continuation annotation for my presentations (because I need more flexibility than provided by the automatic splitting feature of beamer). What I thought of is, for ...
11
votes
1answer
8k views

LaTeX Error: Command \c@T already defined

this is an easy question, but I couldn't find the answer just from other similar questions. A lot of people often get an error in the form: LaTeX Error: Command \XYZ already defined. ...
2
votes
1answer
284 views

Customised counter macro in fancyvrb

I am using the fancyvrb package in LaTeX2e. I have chosen to display line numbers as I am displaying some code. (The code I am displaying is Maple, which unfortunately is not supported by the ...
5
votes
1answer
795 views

How to repeat a block of code and increment a variable by one each time?

I have many images which I would like to include in a latex document. \begin{figure}[h] \centering \includegraphics[scale=0.15]{DSC_0001.jpg} \end{figure} This block of code only differs in the ...
6
votes
2answers
242 views

How to create a fixed counter?

How can I create a counter which is fixed once it has been set? The idea is to insert some kind of remarks into a text which should be numbered, but increasing with the date of actual implementation ...
5
votes
2answers
441 views

`xr` - temporarily redefine `\label` for exporting section counter to sister document?

The goal My objective is to have continuous page (and possibly section) counters for several independent documents. The purpose is a cumulative dissertation where each paper should retain the journal'...
1
vote
1answer
61 views

Is there any way to hook onto the advancement of a counter?

Question title really says it all - can you hook onto \stepcounter{mycounter} which probably boils down to (I may very well be wrong) \advance \mycounter by 1 Is this a hookable thing? Edit: I'm ...
10
votes
3answers
5k views

Using counters and \ifthen in a macro: what's wrong?

I have (made, actually) a graphic of the forepaw-print of a bear that I want to use as a flourish mark at the end of chapters and a few other places. After finishing with the image, I created a mirror ...
7
votes
1answer
2k views

How to use \ifnum for arguments (expanding macros)?

I want to count my section's, figure's etc. using the totcount package. To get a general useable template I want to show only counters which are larger than zero. But it seems that total{counter} ...
2
votes
0answers
350 views

Equation counter automatically resets after using \tag [closed]

I am currently writing my master thesis, and I have just noticed that I have a problem, that I don't know how to solve. My thesis is divided into several chapters. In the first chapter I have an ...
2
votes
1answer
167 views

How to put a counter ``This page has been viewed … times'' on PDFLaTeX output?

I asked a similar question on tracking codes. which was migrated to SO. This is a bit different. Can a PDFLateX output have a counter? Can a link on a PDFLaTeX output have a counter associated with ...
8
votes
2answers
326 views

Shared counter between enumerate and equations

I'm currently writing some math stuff in LaTeX and I've encountered the following problem: I'd like to have "shared" counters in equations and specific lists, s.t. for example \begin{equation} a +...
3
votes
1answer
506 views

How do I Auto-Label Hyperref Fillable Forms \TextField?

Is there any way to put an automatic label into the hyperref package's \TextField parameters field like this: \newcounter{lexemeCounter} \newcommand\lexemeCount{\stepcounter{lexeme}\...
6
votes
1answer
1k views

Counter problem with tabulary

EDIT: As the example below was quite long, I made a minimal example below to make it easier to see the problem: In the example below, the expected values of the counters should be 0, 1 and 2, but its ...
6
votes
1answer
268 views

Using ntheorem's counter inside theorem statement

I'm using ntheorem package and I would like to use the theorem's counter within the theorem's statement. This is useful when you're defining a special object you wish to reference elsewhere, like: \...
4
votes
1answer
2k views

Making global footnotes inside a minipage with hyperref support

I would like to make footnotes inside a minipage that use the global footnote counters and the hyperref package. I'm having trouble getting hyperref to make the correct references. I imagine I need ...
4
votes
1answer
493 views

How to incorporate counter in list label [duplicate]

I want to label my enumeration like SOMETEXT01, SOMETEXT02, ..., SOMETEXT10, etc. I read through a couple of questions and know how to create a counter that adds in leading zeros. \newcounter{counter}...
8
votes
2answers
688 views

Complex Count in \foreach for number line

I am looking to create simple number lines. I have asked a similar question: Resetting numerical labels in \foreach commands on a numberline. But now I am in a different situation. I know how to ...
7
votes
2answers
1k views

Counting pages of sections

After building a second page counter that is reset for every section, I wonder how to get the number of pages of a section. Every section starts on a new page. How can I calculate the number of ...
12
votes
2answers
1k views

Cross-referencing between files and equation counters

I am using package xr to cross reference between two files. Is there a way to make the equation numbers in one of the files follow the ones in the other? What I mean is, if the last equation in file ...
0
votes
0answers
35 views

Listings: total line number count [duplicate]

Is there a way to determine how many lines a listings-environment has (included via \lstinputlisting) and display it in a text or caption? I found the counter \thelstnumber. But if it is used before a ...
18
votes
7answers
1k views

Making calculations using counter

I need to use the counter to make some computations inside loops. For instance, I want to write a for loop to get the following:            &...
19
votes
5answers
397 views

How retrieve items in a list of words by number?

I'm working on a character sheet for the Fate RPG, which rates its skills with a numerical scale that corresponds to an adjective scale. I've been trying to write a macro that will take \skillAdj{4} ...
5
votes
3answers
1k views

Labeling problems with exam class usage when using multiple chapters

Using the exam document class I'm trying to create a questions/answers-sheet for a book. When working on the first chapter, everything worked nicely. When I came to the second chapter, I realized I ...
1
vote
1answer
395 views

Alternative numbering for theorem

I am using thmtools as a front end to amsthm and I have a definition environment as follows. \declaretheorem[ style=mydefinitionstyle, name=Definition, numberwithin=chapter ]{definition} ...
3
votes
2answers
252 views

Lemma numbering by first instance of referencing

My document is long with proofs broken into several lemmas and many of them are in the appendix. However, it seems odd when I am using Lemma 25 (which should ideally be Lemma 1) to prove Lemma 2. It ...
4
votes
2answers
3k views

Change theorem counter in Springer template

I used Springer template for my book, more concrete I used svmono. Here is a MWE, that is the shortened version of my template file. \documentclass[graybox,envcountsec,sectrefs,vecarrow,...
3
votes
1answer
95 views

How to find out how many chapters are in a part?

Is there some counter that holds the number of \chapter that are in a \part? Or do I need to define and run my own counter?
7
votes
1answer
2k views

Cross-refencing a custom counter in \Alph style?

I made a 'hypothesis' custom counter in order to let LaTeX handle my hypothesis reference. My code is \newcounter{hypothese} \refstepcounter{hypothese}\label{hypo:lenght_of_words} \refstepcounter{...
2
votes
1answer
194 views

Completely disable automatic incrementing of section and subsection counters?

I'm using LaTeX as a final build step from a specific legal source (a code of laws) that already has numbering - which is not entirely logical. So, the auto-stepping section & subsection numbering ...
6
votes
2answers
232 views

My own page number from file {counters}

I would like to add my own page number in my publications. I have file: numerki.tex zzzero jEden dWa trZy cztery ... dwadzIescia etc...... How I can add counter \counter\cyferki from file. each ...
7
votes
3answers
569 views

Part numbering with suffixes: I, II, IIIa, IIIb, IV,

I would like to have my parts numbered like this: I, II, IIIa, IIIb, ... , IV, ... I have written some code which works fine. But when using hyperref, I get this warning: destination with the same ...
9
votes
2answers
882 views

How to refer to the count value of number of lines in a lstlisting

I need to refer to to the count value of the number of lines in a listing. Is there a way to do that ? \lstinputlisting[caption={SPARQL query used...},label={lst:sqry}]{codes/sparql_query.sparql} ...
7
votes
3answers
323 views

How to adjust a counter depending on whether or not we are inside a section or subsection

I want to create an exercise environment that can be used in either section, subsection, etc. As an illustration, consider the following: when in section 1, the third example should be titled as ...
2
votes
1answer
523 views

How to implement two figure counters with proper hyperlinks in hyperref in latex?

I want to typeset a book with a quiz in it. I want to have two types of figures: text figures: These are indexed i, ii (roman) quiz figures: These figures are related to the quiz, and should have ...
9
votes
2answers
146 views

Do assignments need to be appended by % to remove the trailing white spaces?

The following shows code snippet taken from multido.tex. I noticed assignments are not ended with %. See \dimen@=#1\advance\dimen@#2 in \def\multido@step@d#1#2{% \dimen@=#1\advance\dimen@#2 \...
3
votes
1answer
1k views

Counting figures, tables and citations in a document

My idea is to use TeXcount to scan my document and output the number of words, figures, tables, equations and citations. I've been looking at the documentation for TeXcount and it seems that words ...
5
votes
1answer
577 views

Resume option similar to enumitem package for paralist package

I would like to know if it is possible to generate a resume option similar to that in the enumitem package for the paralist package. Note that it is not possible to add something like [resume] or [...
1
vote
1answer
558 views

Adding half points/marks to question counter

I would like to be able to add half marks to my questions, but I don't know how to handle these with\stepcounter. Below is part of my style file, please could you help? I essentially want to say \mrks{...
8
votes
2answers
760 views

Defining TeX count in a group

I thought that TeX counts were local definitions, but that is not what I am seeing. I was expecting that if I used \newcount within a group, that the etoolbox \ifdefcounter would say that the counter ...
2
votes
1answer
878 views

Numbering exceeding the 26 letter alphabet

After reading this answer https://tex.stackexchange.com/a/52604/10898 I am unable to employ the alphalph package to replace the counter in either levels. See the code below: \documentclass[...
8
votes
3answers
397 views

Counting index entries

Is there a way to count the number of entries in an .idx file? Currently I'm using the following to accomplish the job but I'm wondering if there is an all TeX/LaTeX way to accomplish the same thing. ...
4
votes
2answers
804 views

Write a \setcounter command to a file

I try to write a setcounter command to a file (using the newfile package) by something like the following \addtostream{mystream}{\protect\setcounter{mycounter}{\myvariable}} However, since the whole ...
1
vote
1answer
4k views

How can I change the counters of tables in the appendices? [duplicate]

I have multiple appendices and in some appendices I have tables. What I want is that each appendix itself has a letter as a number (e.g. Appendix A: title). A second thing that I want to achieve is ...
4
votes
2answers
291 views

How do I create a forward reference to a user-defined counter?

I have created a counter to count enclosures: \newcounter{enclosure}{0} At the bottom of each enclosure I put: \addtocounter{enclosure}{1}\vfill\hfill\Enclosure \arabic{enclosure}\clearpage And ...
1
vote
0answers
100 views

enumitem-shortlabels: How to change the counter of items? [duplicate]

I use the enumitem package with shortlabels. \usepackage[shortlabels]{enumitem} Now I've got \begin{enumerate}[(L 1)] \item blablabla \item blablabla \end{enumerate} and it goes like (L ...
6
votes
2answers
204 views

Complex parsing of arguments in new environments

I am trying to build an invoice generation system in LaTeX which will be easy and maintainable. Right now we are using longtable and a preprocessing layer. I would like to change this to a .sty and ...
11
votes
2answers
735 views

Counter increase with new page

How can I increase my counter with every new page and reset to 0 again when it comes to a new chapter? I know that I can link my counter to a chapter so that it can be reset on every new chapter by: ...
3
votes
1answer
1k views

Manual exercise question numbering

I am using exercise package to list exercises/questions. I am defining exercise list like this: \begin{ExerciseList} \Exercise{Exercise title} \ExeText Some exercise introduction \Question{...