Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [counters]

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

2
votes
2answers
95 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 ...
0
votes
0answers
31 views

How can I number examples in the previous section?

How can I number the examples like the picture I attached?
2
votes
1answer
88 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
33 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 ...
3
votes
1answer
136 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
35 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
26 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
2answers
38 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
18 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
23 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
20 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 ...
2
votes
1answer
30 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
25 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
29 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
107 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
36 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
28 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
138 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
36 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....
4
votes
5answers
127 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
48 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
41 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
46 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
411 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
63 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
31 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
181 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
35 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
34 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
134 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
80 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
231 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
72 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
36 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
70 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
30 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
35 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
67 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
53 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
99 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
37 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
124 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
46 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 ...
2
votes
1answer
169 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
36 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 ...
3
votes
2answers
218 views

Convert all counters to base 6

Is it possible to change the numeration base of LaTeX? Actually I am looking for base 6. I would like this change to apply to all counters (TOC, pages, chapters..). I found this topic How can I make ...
2
votes
1answer
32 views

The name of a cleveref reference is missing when the reference is inside a subsubsection of an appendix

The following KOMA-Script/LuaLaTeX document: \documentclass{scrbook} \usepackage[nameinlink]{cleveref} \setcounter{secnumdepth}{4} \begin{document} \appendix \chapter{Chapter} \section{Section} \...
3
votes
1answer
44 views

Changing listing numbers

I want to change the numbers of a listing based on certain rules: Line 10: no number Line 11 onwards: the number that corresponds to the line+5 The displayed numbers should thus be: 1, 2, 3, 4, 5, 6,...
3
votes
1answer
101 views

ConTeXt passing current counter value to lua

I've been experimenting with ConTeXt and have been trying to create an exam using it. I would like to have an array in lua that holds the weight of each question, and a custom enumeration called "...
8
votes
3answers
296 views

Use counters value after it appears in the code

Is there a way to use a counters value at one point in the code, but with the counters state of a line, that comes somewhat after the corresponding use of the counters value? E.g. Define the counter ...