0

Can I expand \ifcase to two levels:

\ifcase{1.1} = a            
\ifcase{1.2} = b 
\ifcase{1.3} = c 
\ifcase{2.1} = a
\ifcase{2.2} = b
.
.
.
\ifcase{3.1} = a
\ifcase{3.2} = b
\ifcase{3.3} = c

Naming should follow the second argument as in above.

4

Interpretation: Stripping second part of the number and convert it to a letter

\documentclass{article}

\makeatletter
\newcommand*{\SecondAsAlph}[1]{%
  \@alph{\StripToDot#1}%
}
\def\StripToDot#1.{}
\makeatother

\begin{document}

\newcommand*{\test}[1]{#1 = \SecondAsAlph{#1}\par}
\test{1.1}
\test{1.2}
\test{1.3}
\test{2.1}
\test{2.2}
\test{3.1}
\test{3.2}
\test{3.3}

\end{document}

Result

Interpretation: Second part of the (sub)section number is a letter

\renewcommand*{\thesection}{\thechapter\alph{section}}

or

\renewcommand*{\thesubsection}{\arabic{section}\alph{subsection}}

Interpretation: \ifcase skips the first part of the number

\newcommand*{\MyCaseMacro}[1]{% #1 is the number of the form <x>.<y>
  \ifcase\StripToDot#1 %
    % case <x>.0
  \or
    % case <x>.1
  \or
    % case <x>.2
  \or
    % case <x>.3
  \else
    % case <x>.<y> with <y> equal to or greater than 4 (or negative)
  \fi
}
\def\StripToDot#1.{}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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