3

I have looking for TeXT Placement movememnt in the class file. Requirement is store the value and print in another places.

My LaTeX code is:

\documentclass{threecolumn}
\usepackage{ifthen}
\begin{document}
\jnl{5}
\end{document}

and my class file is

\def\jnl#1{\protected@edef\@jnl{#1}}
\def\@jnl#1{%
\ifthenelse{\equal{#1}{1}}{Sample 1}{}%
\ifthenelse{\equal{#1}{2}}{Sample 2}{}%
\ifthenelse{\equal{#1}{3}}{Sample 3}{}
\ifthenelse{\equal{#1}{4}}{Sample 4}{}
\ifthenelse{\equal{#1}{5}}{Sample 5}{}
}

If \jnl{2} is found need to change the \jnl{Sample 2} and like to place in after \maketitle. How do achieve this in class file?

Balaji
  • 2,282
  • It is not clear to me what you are asking. Is it general conditional setting of macros, or a construction for case statements or ...? Note that the macros provided by etoolbox are to be preferred over those from ifthen, see http://tex.stackexchange.com/q/13866/15925 – Andrew Swann Aug 03 '13 at 14:55

1 Answers1

3

You want to use \protected@edef in a different way; with that code the definition of \@jnl will never be used. Moreover, \ifthenelse cannot be used in \protected@edef.

\documentclass{article}

\makeatletter % this shouldn't be used in the class file
\newcommand{\jnl}[1]{%
  \protected@edef\@jnl{%
    \ifcase#1%
     \relax\noexpand\threecolumn@error@jnl{#1}\or
     Sample 1\or
     Sample 2\or
     Sample 3\or
     Sample 4\or
     Sample 5\else
     \relax\noexpand\threecolumn@error@jnl{#1}\fi
  }
}
\newcommand\threecolumn@error@jnl[1]{%
  \ClassError{threecolumn}
    {Invalid argument to \protect\jnl}
    {The argument to \protect\jnl\space should be
     between 1 and 5 (included)}%
}
\makeatother % this shouldn't be used in the class file

\jnl{0}
\jnl{1}
\jnl{5}
\jnl{6}

In the first and last case, \@jnl will raise an error.

egreg
  • 1,121,712