[Tex/LaTex] Compare strings

strings

I have some troubles by comparing strings in my beamer theme.

I would like to compare the "techno" argument with a string (iOS, Android, Java,…):

if techno =="iOS" logo_path = "some_image" else if techno == "android" logo_path = "some_other_image"

and so on,

I take an argument from the main .tex files and I would like to compare it do define an image to include :

\def\beamer@ALE@iOSLogo{ios.png}
\def\beamer@ALE@AndroidLogo{android_logo.jpeg}

\DeclareOptionBeamer{techno}{\def\beamer@ALE@Techno{#1}}
\ProcessOptionsBeamer

\IfStrEq{\def\beamer@ALE@Techno}{iOS}{{\def\beamer@ALE@TechnoLogo{\beamer@ALE@DiOSLogo}}{{\def\beamer@ALE@TechnoLogo{\beamer@ALE@DefaultLogo}}

Then I include a graphics :

\includegraphics[width=1cm]{\beamer@ALE@TechnoLogo}

When I compile it tolds me : image `ios' (back quote + value + quote) is not found.

I have to declare a macro to solve the problem :

\def\beamer@ALE@iOS{iOS}

Do someone have some explanations?

Best Answer

It is hard to guess from the code fragment which strings you want to compare but I think you want to compare \beamer@ALE@Techno (The option value) with \beamer@ALE@iOSLogo which you can do with

\ifx\beamer@ALE@iOSLogo\beamer@ALE@Techno
   ... ios case
\else
  ... other case
\fi

Your question has

\IfStrEq{\def\beamer@ALE@Techno}{iOS}

It is hard to guess what the intention of that is as \IfStrEq is intended to compare strings (lists of characters) but you have passed it a definition.

However I don't think you nwant to do a compare at all, just define

\def\logoimage{mydefaultimage}
\@namedef{tech-image-ios}{\def\logoimage{ios.png}}
\@namedef{tech-image-android}{\def\logoimage{android_logo}}

\DeclareOptionBeamer{techno}{\csname tech-image-#1\endcsname}}
\ProcessOptionsBeamer

\includegraphics{\logoimage}

then it will include an image mydefaultimage unlesss techno=ios or techno=android in which case you get teh specified files, more \@namedef could be added as required.

Related Question