Hi Thom,
Welcome to the LaTeX community!
I must confess I don't get what you want these commands for. Manual setting of a counter somehow dismisses LaTeX's principle of
not having to set things by hand. I also have a feeling that this approach is error-prone. But maybe it actually makes sense in the context you're using it...
Anyway:
thomderainette wrote:[...]Can we do something like:
Code: Select all
\newcommand\wrappall[3]{
\setcounter{#1}{#2}
%[...]
\#1{#3} %is ther a way to use #1 as a command
%[...]
}
\wrappall{levelname}{counter-1}{name of section}
[...]
You're probably looking for
\csname ...\endcsname
or LaTeX's wrapper
\@nameuse{}
:
Code: Select all
\newcommand\wrappall[3]{%
\setcounter{#1}{#2}%
\csname#1\endcsname{#3}%
}
or
Code: Select all
% make @ a letter so it can be used in command names:
\makeatletter
\newcommand\wrappall[3]{%
\setcounter{#1}{#2}%
\@nameuse{#1}{#3}%
}
\makeatother
Note that you should end lines with
%
if you want to avoid spurious spaces in your command definition.
Regards