General ⇒ Is there a "providecommand"-like cmd for counter & length?
Is there a "providecommand"-like cmd for counter & length?
thank you in advance.
regards,
Yuko
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
-
- Site Moderator
- Posts: 814
- Joined: Tue Jul 01, 2008 2:19 pm
Is there a "providecommand"-like cmd for counter & length?
Code: Select all
\makeatletter
\newcommand*\providecounter[1]{%
\@ifundefined{c@#1}%
{\@definecounter{#1}}%
{}%
}
\makeatother
Re: Is there a "providecommand"-like cmd for counter & lengt
The counter works well.

I tried to modify your code for the length but it did not work.
Thank you in advance.
regards,
Yuko.
-
- Site Moderator
- Posts: 814
- Joined: Tue Jul 01, 2008 2:19 pm
Is there a "providecommand"-like cmd for counter & length?
Code: Select all
\makeatletter
\newcommand*\providelength[1]{%
\begingroup
\escapechar\m@ne
\xdef\@gtempa{\string#1}%
\endgroup
\@ifundefined{\@gtempa}%
{\newskip#1}%
{}%
}
\makeatother
Re: Is there a "providecommand"-like cmd for counter & lengt
The code works well.

I am sorry, actually I have one more

I need \providesavebox associated with \newsavebox.
Should I create a new topic for this question?
Thank you in advance.
regards,
Yuko.