10
votes
2answers
122 views

Save counter value inside command?

I'm trying to automatically generate commands based on the value of a counter: \documentclass{article} \newcounter{count} \newcommand\generator[1]% {% \stepcounter{count}% ...
4
votes
1answer
68 views

Using counters in macros to manage Beamer overlays

I have a very complex Tikz figure that is uncovered piece by piece during my presentation. While tweaking the presentation I decided to change the order of things being uncovered and due to the large ...
6
votes
2answers
147 views

Counters and macros?

Not sure how I should post my question but here it is: I've seen that in plain TeX, \newcount is illegal inside a macro \definition. Is there a way to allocate a register inside a macro? Also, if I ...
10
votes
1answer
79 views

Use node name with arithmetic counter expression

I want to call a PSTricks macro with a node name which involves the result of an arithmetic expression with counters. Consider the following, not working example: \documentclass{article} ...
6
votes
1answer
84 views

\alph without counters

When I iterate numbers with TikZ \foreach, they are stored in a macro. Now, when I need the letter corresponding to this macro, I can only convert it by saving it to a counter and then receiving it ...
6
votes
2answers
143 views

How to store a counter value at some point in the document?

I'm beginning to learn LaTeX and I need some help with counters. My goal is to store the value a certain counter reaches at some point in the document and use it later. This is my attempt: ...
13
votes
1answer
193 views

Dos and Don'ts of \countdef\mycount=<number> and \newcount vs \newcounter{} in LaTeX

Let's clarify that countdef\mycount=<number> is a bad idea in LaTeX, then clarify appropriate usage of \newcount\mycount vs \newcounter{mycount} in LaTeX. Background: I only started with TeX ...
4
votes
2answers
70 views

How can I obtain total number of points?

I defined the command: \newcommand{\shcpoint}[1]{% \ifnum #1<2 (\emph{#1 point})\quad\phantom{s}% \else (\emph{#1 points})\quad% \fi } and I use it in the ...
3
votes
2answers
66 views

Determining spacing by a number that is a multiple of a counter

I have \hspace and I have a stepcounter xyz \documentclass[12pt]{article} \usepackage[top = 1in, bottom = 1in, left = 1in, right = 1in]{geometry} \usepackage[T1]{fontenc} ...
8
votes
4answers
167 views

How can I reference the current (sub)section number?

I want to create a macro that dynamically returns the current chapter, section, subsection (etc.) I'm in. I've created a macro called \getCurrentSectionNumber that does this, but it lacks the ability ...
7
votes
1answer
74 views

Is there a switch to turn off LaTeX counters from inside a box?

I know that amsmath typesets at least twice its material, the first one for measurement and that it takes measures (sic) to avoid some counters being updated twice. Is there a switch a macro writer ...
6
votes
2answers
119 views

Use of a macro to set counter value in another macro

I am trying to simply set the value of the counter try which I defined previously to the value of the output of the \foo command. However this does not work. I guess that the problem is coming from ...
4
votes
2answers
107 views

The package zhnumber without xeCJK

I need to use the function zhdigits from the package zhnumber to typeset a counter the way I want, i.e. convert 235 to 二三五. This package requires the package xeCJK to work properly, but xeCJK messes ...
2
votes
1answer
70 views

Add prefix command(s) - counter of todos

I would like to see the number of todos I have left. Therefor I tried to redefine the todo command as follows: \newcounter{todocounter} ...
7
votes
1answer
556 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
77 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 ...
6
votes
1answer
163 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 ...
9
votes
3answers
525 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 ...
6
votes
1answer
450 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} ...
18
votes
5answers
309 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} ...
0
votes
0answers
107 views

TeX, LaTeX capabilities in counting occurrences in text of chars defined in a given list

I am asking this question in part because I am not completely aware of TeX, LaTeX capabilities. Imagine that I want to count the number occurrences of charecters defined in a certain list. The usage ...
4
votes
2answers
333 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 ...
6
votes
2answers
151 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 ...
23
votes
3answers
685 views

@tempdima, reserved@a, @tempcnta, what else?

I'm aware that some "temporary" LaTeX dimensions etc. exist. I would, however, like to know all of them. I know \reserved@a (macro), \@tempdima (dimension) and \@tempcnta (counter).
1
vote
1answer
124 views

Creating and using commands/counters which name depends on other counter

I would like to know how can I use a counter for defining other new counters. Something like this: \newcounter{foo} \stepcounter{foo} %% Perhaps more increments, this depends of the user. %% And ...
12
votes
1answer
132 views

Custom “counter” as page number substitute

I'm trying to typeset a book, covering a world trip. Instead of standard page numbers, I want each page to correspond with a digit representing driven kilometers. Of course I can't manually set that ...
1
vote
0answers
120 views

Resetting a macro counter to 0 [closed]

I have a macro that is disabled after one use. The worksheet works fine until I need to clean the entire sheet and reuse it the next week. How do I reset the macro counter to zero so that I can use ...
7
votes
1answer
198 views

Savebox equivalent of \csname?

I would like to define a command which would increment a counter, and create a new savebox whose name is generated from the counter value. Something like: \documentclass{article} ...
5
votes
1answer
339 views

Is there something like \renewcounter or \providecounter?

Is there a command that creates a counter or, if it already exists, redefines it? Thing is that I'm working with nested loops. The second loop is however in a command. This means if I want to use a ...
7
votes
1answer
318 views

Macro vs counter: How to store and operate with numbers in TeX without using (too many) counters

I need to store and use a large amount of integers (a little bit of "programming with TeX"), but I know that TeX has a limited (up to 256) number of counters that can be used simultaneously. How to ...
11
votes
3answers
1k views

How to save variables

I need to change 'hyphenpenalty' in some parts of my document, but I have no idea how to properly restore a previous value after that. For example: \hyphenpenalty=10000% \@starttoc{toc}% ...
5
votes
1answer
254 views

Is it possible to remove length, counter, dim, etc that have been declared?

Let's see the following screenshot taken from an answer of Efficient ways to anonymize a document and the given comment. Is it possible to remove length, counter, dim, etc, that have been declared ...
6
votes
2answers
1k views

Save current value of counter in a command

I would like to define kind of an own index, that collects certain information and one counter value - in the following small example the \addstuff-command that may get the value of a counter as its ...
4
votes
1answer
331 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 ...
14
votes
2answers
948 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 ...