GeneralDynamic global variable definition

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
MoJan
Posts: 1
Joined: Sun Oct 27, 2024 5:02 am

Dynamic global variable definition

Post by MoJan »

Hi,

I want to define a global variable whose name is dynamic and assigned by using a counter.
This is my code but it does not work. Moreover, I do not know how to ask latex to write the in the aux file the current value of the counter and not just \themycounter because the value of the counter changes through the document.

Code: Select all

\documentclass{article}
\usepackage{globalvals}

\begin{document}

\newcounter{mycounter}
\setcounter{mycounter}{10}

\useVal{key10}

% somewhere else
\defVal{key\themycounter}{test test \themycounter}

\end{document}
Thank you for your time.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

Post Reply