Code: Select all
\newcommand\chupleft{\fontfamily{ptm}\selectfont 1}
\newcommand\chupcenter{\fontfamily{ptm}\selectfont 2}
\newcommand\chupright{\fontfamily{ptm}\selectfont 3}
...
\newcommand\chlowerright{\fontfamily{ptm}\selectfont 8}
Code: Select all
\documentclass[12pt]{article}
\usepackage{color,ifthen}
\newcommand*\mchar{\fontfamily{ptm}\fontsize{24}{24}\selectfont\color{red}}
\newcounter{cname}\setcounter{cname}{0}
\makeatletter
\newcommand\createcommands[1]{%
\@for\@myarg:=#1\do{
\stepcounter{cname}
\ifthenelse{\arabic{cname}=1}{\newcommand\chupleft{\mchar \@myarg}}{}
\ifthenelse{\arabic{cname}=2}{\newcommand\chupcenter{\mchar \@myarg}}{}
\ifthenelse{\arabic{cname}=3}{\newcommand\chupright{\mchar \@myarg}}{}
\ifthenelse{\arabic{cname}=4}{\newcommand\chleft{\mchar \@myarg}}{}
\ifthenelse{\arabic{cname}=5}{\newcommand\chright{\mchar \@myarg}}{}
\ifthenelse{\arabic{cname}=6}{\newcommand\chlowerleft{\mchar \@myarg}}{}
\ifthenelse{\arabic{cname}=7}{\newcommand\chlowercenter{\mchar \@myarg}}{}
\ifthenelse{\arabic{cname}=8}{\newcommand\chlowerright{\mchar \@myarg}}{}
}
}
\makeatother
\begin{document}
\createcommands{1,2,3,4,5,6,7,8}
% 1,2,3,4,5,6,7,8 are in fact eight border characters to make a framed text box, so they can be anything, 'a,b,c,d,e,f,g,h', etc. That's why I set up a counter `cname' and did silly ifthenelse comparisons.
\chupleft
\end{document}
Code: Select all
! Undefined control sequence.
\@myarg ->\@nil
l.24 \chupleft
?
BTW, I've used another approach with package `tokenizer' and had similar result. I've read about some topics on variable expansion (\expandafter, \csname, \endcsname) without success.
Please instruct, thanks!