I'm trying to define new counter lnum and display the counter number in circle.
I found circled command from here tex.stackexchange but I have a problem.
Here's my test code:
\documentclass{article}
\usepackage{tikz}
\newcommand*{\circled}[1]{\tikz[baseline=(char.base)]{%
\node[shape=circle,fill=blue!20,draw,inner sep=2pt] (char) {#1};}}
\newcounter{lnum}
\renewcommand{\thelnum}{\circled{\arabic{lnum}}}
\begin{document}
\thelnum % fine
\refstepcounter{lnum}\thelnum % error here
\end{document}
As you can see from the comment, without \refstepcounter, it works fine. However, with \refstepcounter, it doesn't work. Here's error message:
! Undefined control sequence.
\tikz@deactivatthings ->\def ;
{\tikz@nonactivesemicolon }\def :{\tikz@nonact...
l.11 \refstepcounter{lnum}
\thelnum
?
Why this doesn't work? And, how can I fix it?
\renewcommand{\thelnum}, it is self-recursive. – Symbol 1 Jun 21 '17 at 14:01\refstepcounterthe\thelnumis expanded into a label definition. That is, it must be possible to write\edef\test{\thelnum}and that will not work as a Tikz node. – StefanH Jun 21 '17 at 14:49\thelnumas long as it is expandable inside TeX. For example\renewcommand\thelnum{LNUM: \arabic{lnum}}should work. I do not see how it is self-recursive. – StefanH Jun 21 '17 at 14:58\thelnumsuggests that this command is already defined and can be used anywhere, anytime. Just because\arabic{lnum}works well does not mean that you are safe. In fact,\refstepcounterdoes invoke\thelnumand that is where everything goes wrong. – Symbol 1 Jun 21 '17 at 15:24