Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question
    
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 tex.stackexchange.com/q/13866/15925 –  Andrew Swann Aug 3 '13 at 14:55

1 Answer 1

up vote 3 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.