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
2
votes
1answer
73 views

\thetable returns a value that is off by 1 if used in longtable environment

I noticed that the \thetable command returns the wrong number for longtable environments. I'm including the phrase "Continued from the previous page" in my table header and prepend it with \tablename\ ...
1
vote
1answer
147 views

loops on columns inside tabular environment

What is the proper way to use loops inside the tabular environment? The context of my question is generating tables using the datatool package. I need the following features: In each row, I want to ...
0
votes
0answers
21 views

Can't simultaneously have superscripted footnotes in text and footnote counter not cycling back to 1 with each chapter

I want my footnotes superscripted in the text and numbered continuously in the text of my book from 1 to n, without restarting at 1 with each chapter. In the MWE below, if I comment out the \chngcntr ...
3
votes
1answer
116 views

Wrong hyperref with repeated counter

I'm having an interesting problem with hyperref. Apparently, when a counter is reset by \setcounter{mycounter}{0} then hyperref always links to the first possible instance of the counter and not the ...
1
vote
0answers
235 views

How to count section pages in LaTeX and display them in a progress bar?

I am currently writing a student work in latex as a scrartcl. I would like to make an overview in my document of how many pages I still have to write in each section. So like an actual/target ...
5
votes
1answer
147 views

Changing a tcolorbox listing option based on the number of lines of its listing

Consider the following code which produces listings: % ---------------------------------------------------------------------------- % % Preamble \documentclass[12pt]{article} % -----------------------...
2
votes
2answers
202 views

How to enumerate figures in sync with another counter?

I when I create a command for (for example) the examples in my article, I do it in this way: \newtheorem{teo}{Theorem}[section] \newtheorem{ex}[teo]{Example} So the enumeration is consecuent to what ...
2
votes
1answer
2k views

Get value of a counter

Consider this code: \documentclass{report} \newcounter{counterA} \newcounter{counterB} \begin{document} ... \setcounter{counterA}{2} \setcounter{counterB}{3} \addtocounter{counterB}{counterA} \end{...
2
votes
2answers
151 views

Problem with Counters and Cleveref

I like using amsthm for my theorems, etc, but to highlight their importance, I like exercises to be in tcolorboxes. I want the exercises in the boxes to share the same counter as my theorems. I ...
2
votes
2answers
309 views

How to set continue counter from another counter (latex)?

I want to set a counter (auto) like: \newcounter{question} \newcounter{example} Question 1. Question 2. Example 3. Example 4. Question 5. Question 6. Can you help me. Thankyou so much.
4
votes
1answer
46 views

Correctly order float counter (perpage.sty) while sharing eqn/thm counter

Sharing float (fig) and thm counter can be done with \newtheorem{theorem}[figure]{Theorem}. Correctly ordering float (fig) counter based on actual location in the PDF (as opposed to location in ...
1
vote
1answer
135 views

New title class doesn't increase counter

I'm fairly new to LaTeX and need to create a subsubsubsection in a document. After looking around I found that it could be done with titlesec. I've followed all instructions I've been able to find but ...
1
vote
3answers
122 views

Let equation numbers and enumerate use the same counter

I managed to customized the enumeration, so it mimics the format of the math equation number. Now, I would like to replace the math equation counter by the one from the enumerate, (\thechapter.\arabic{...
1
vote
1answer
51 views

Using zref return value as input for counter

I am trying to create a new counter, which is counting the page numbers to store them and reuse them later. I always remove the 3 pages, which are not numbered at the beginning of the document and I ...
1
vote
1answer
53 views

Stop resetting question counter after a new part

I use the exercise package for typesetting exercises and questions. After a new part the (sub)question counter is reseted. I would to avoid this but I don't know how. MVE \documentclass[11pt]{...
1
vote
1answer
61 views

Page double counter problem: theHpage undefined

I have a problem with links placed by a package (glossaries-extra) inside the preamble of my thesis. In this preamble I want to use roman numbers (i,ii,iii,...) as pages. This is done by my class file ...
3
votes
1answer
96 views

How can I get a frame to show the number of its own slides? (beamer)

I am trying to write a code that shows the number of slides in each frame. However, the code seems to write the slides number of slides in the previous frame In the MWE, the code reports frame 2 ...
2
votes
1answer
122 views

Question on Beamer Counter

I'm trying to create a new numbered definition environment based on exampleblock, but it doesn't work as is expected. My code: % !TEX program = xelatex \documentclass[serif, compress]{beamer} \...
0
votes
1answer
51 views

Lines of code counter

Is there a way to automatically count the lines of code of a TeX document? And if yes, is there a way to include that in the document? I would like to have something like "this document is n lines of ...
4
votes
2answers
201 views

Is there a way to make cleveref distinguish two environments with the same counter?

I believe that usually you explicitly tell cleveref what to call your label using \crefname{type}{singular}{plural}, this doen't work however as here "type" has to be the name of the counter (I ...
0
votes
0answers
45 views

How to add custom numbering to sections or subsections?

I would like to have subsections with "parts" like the following code but possibly managed automatically. \documentclass{article} \begin{document} \section{Lorem} \subsection{Ipsum part 1: Foo} \...
0
votes
0answers
33 views

One latex source producing several pdf files with continuing counters

I am looking for a way of splitting a textbook into lecturenotes for individual lectures. That is, I have a latex file textbook.tex and I would like to produce pdfs lecture1.pdf, lecture2.pdf. The ...
4
votes
1answer
235 views

Why does the \includeonly command not \stepcounter the chaptercounter for omitted chapters?

I'm a big fan of the \includeonly command, to keep pagecounts intact while only printing specific chapters. But I'm wondering why chaptercounters are not stepped in a scenario such as this one: \...
0
votes
2answers
92 views

Automatic counter with sub counter for table row - referencing

I want something like this: a referrable automatic counter and sub counter for each row in a tabularx environment. I could find a solution for a single counter here, but could not adapt it to tabularx....
5
votes
5answers
466 views

How can I access and store the current value of a counter?

My counter is being updated by a command and I want to save the current value + 1 of this counter at a specific point so that later on I am able to print it out. \newcounter{counterA} \newcounter{...
0
votes
0answers
108 views

Can Even Pages Be Right Pages?

SETCOUNTER in BOOK changes page numbers as well as directions—odd pages are right pages and vice versa. This is an example. \documentclass{book} \title{TEXT} \author{TEXT} \date{TEXT} \begin{document}...
1
vote
2answers
44 views

Exclude numerals from a custom counter environment

I have my document set up so that examples are numbered but I would prefer to be able to add my own number or title. I know I can add the title in square brackets, but how do I remove the numbers? ...
1
vote
1answer
167 views

Need LaTeX to automatically update a reference number within a table

I'm need to assign a reference number inside a table such that it automatically updates the number at the end and restarts the counter when the initial part of the reference number changes. For ...
5
votes
1answer
530 views

What does the asterisk (*) do in \arabic*?

I was wondering what the '*' (asterisk) does in the command \arabic*? My code: \usepackage[inline]{enumitem} \begin{enumerate*}[label=\textbf{\arabic*})] \item Text 1 \item Text 2 \item ...
2
votes
1answer
100 views

How to define counter for problems and examples of a text?

This is the first time that I'm going to prepare a book with Latex. I am not so familiar with advanced options of Latex, and in particular with typography. The book includes a lot of examples and ...
2
votes
1answer
45 views

Set the counter for multiple equations of the same kind

I want equations (2) and (3) to be labeled as (1a) and (1b) \documentclass[12pt,a4paper,table,usenames, dvipsnames]{book} \usepackage[table]{xcolor} \definecolor{def}{RGB}{66,103,178} \usepackage{...
7
votes
5answers
270 views

Loop over an optional argument

I'd like to use the command \foo with an optional argument to step and print the counter value iterated according to the number passed. So, for example, \foo[5] should step the counter 5 times, one ...
0
votes
0answers
109 views

How do I reset the setcounter for a custom lstlistingname in latex?

I am fairly new to the world of LaTeX and am currently working on a report. Throughout the report there are several tables, figures and commands. For the figures and tables I found the working code ...
2
votes
1answer
54 views

Problem with condition in a table by using counters

I'm trying to make a conditional dynamic table that uses counter for comparison but i got a irrational error, Please see the following code: % !TEX TS-program = xelatex \documentclass[hidelinks]{...
1
vote
1answer
171 views

The construction of Rooty helix, code explanation

Could someone please explain some parts of this code? I'm newbie on LaTeX and could not understand some parts. What does this \foreach \y in {86,38,15} means? Could you explain with details what is ...
4
votes
3answers
305 views

Custom numbering style using the number of Symbols instead of Numbers

Is there any possible way to count by the number of a symbol ? For instant, if I want to print 4 versions of a letter, I assigned \arabic{#1} numbers which shows: 1 2 3 4 What I want is to ...
5
votes
2answers
373 views

How to do calculations with a LaTeX counter in a newtcolorbox environment?

I created a course summary box. In order to distinguish the summaries by school year, I have put an optional argument that displays the latter in the upper left corner (highlighted in yellow on the ...
0
votes
1answer
228 views

mcexam a custom type question

I'm trying to create an exam using the code provided by him. Here is the code: \documentclass[twoside]{article} \usepackage[english]{babel} % set fonts \usepackage[utf8]{inputenc} \usepackage[T1]{...
0
votes
0answers
114 views

Custom counter for oddside and evenside margins

When using the twoside in the article class, resetting the page counter creates an issue in regards to the odd and even side margins. Is it possible to declare a custom counter that article considers ...
2
votes
3answers
121 views

Use of \p@COUNTER

When a new counter is defined via \newcounter, e.g. \newcounter{mycounter} then a command \p@mycounter is also defined. I can see this again popping up when setting the \@currentlabel in \...
0
votes
1answer
319 views

Organize counter (newtheorem)

I'm writing some notes and I have a problem with the organization. I defined the theorems as follows: \documentclass[12pt,a4paper]{book} \theoremstyle{plain} \newtheorem{teo}{Teorema}[chapter] \...
3
votes
1answer
126 views

Use same reference count for lstlisting and figure/graphics

I have the following code on overleaf: \begin{lstlisting}[caption={Código inicial para o sistema de arquivos},label={lst:Figura1}] abstract sig FSObject { } sig File, Dir extends FSObject { } sig ...
0
votes
2answers
156 views

beamer: finding out if there is content in the appendix

I am trying to determine if there are pages in the appendix. If there are I want to show a separation page/frame as indicator but in the handout mode only. In my current setup (due to some ...
1
vote
1answer
96 views

Removing an additional Counter from Table of contents

I have created two custom counters scireq and scisubreq as I'm working on a document specifying requirements and couldn't find any requirements package. Unfortunately, the requirements come up in the ...
2
votes
1answer
246 views

Using exam question counter as an argument

I am trying to use the exam class to create a study guide for my students that has all of the answers at the end of the document. I would like to have the answers automatically labeled by question ...
2
votes
1answer
44 views

How to define two labels inside an environment to compute the number of pages the environment spans?

I would like to count the number of pages that a certain environment (named myenv) spans. In principle, I set two labels, one in the beginning and one in the end of the environment. These labels ...
2
votes
1answer
728 views

How to display chapter/section counter value?

I'm building a \documentclass[...]{book} latex file. Each chapter has some sections. Each section has some exercises. The exercises are displayed on \exercise command. In the preamble I did: \...
2
votes
1answer
242 views

Global counter as argument

I am in a need of a global counter which I can be used as argument to a method. When it is used as an argument, I just want the current value of it... so what the method receives is a number, not the ...
3
votes
1answer
2k views

Accessing the current frame number in beamer

I know how to manually reset the page counter using a fix value. In the MWE below this fix value 0. Now I wonder how to use a variable value like \framenumber - 1. In this question it was asked for ...
0
votes
2answers
46 views

multiple section contexts in document which each has its own counter

I try to create a latex template for a homework where I need two section counters running parallel. I have an example here: As you can see I'd like to separate the main article from the ...

1
3 4
5
6 7
24