1

I want to print a different logo sequentially for 4 years, and then resuse them. My script is not working... any idea?

\documentclass{article}
\usepackage{pgf,calculator,ifthen}
\MODULO{\year}{4}{\ye}
\newcommand{\autologo}{\ifcase\ye\relax logotp0.pdf\or logotp1.pdf\or logotp2.pdf\else logotp3.pdf\fi}
\newcommand{\auteloge}{\ifcase\ye\relax example-image-a\or example-image-b\or example-image-c\else example-image-d\fi}
\begin{document}
\includegraphics[scale=0.5]{logotp2.pdf}  % works for the 4 image files...
\includegraphics[scale=0.5]{\auteloge}   %works
\includegraphics[scale=0.5]{\autologo}    % error argument of \@firstofone
\end{document}
2

You have spurious spaces appended to the file names:

\documentclass{article}
\usepackage{pgf,calculator,ifthen}
\MODULO{\year}{4}{\ye}
%\newcommand{\autologo}{\ifcase\ye\relax logotp0.pdf \or logotp1.pdf  \or logotp2.pdf  \else logotp3.pdf \fi}
 \newcommand{\autologo}{\ifcase\ye\relax logotp0.pdf\or logotp1.pdf\or logotp2.pdf\else logotp3.pdf\fi}

\begin{document}
\includegraphics[scale=0.5]{logotp2.pdf}  % works...
\includegraphics[scale=0.5]{\autologo}    % but I want something like this
\end{document}

I replaced your image names with example-images and it worked:

\documentclass{article}
\usepackage{pgf,calculator,ifthen}
\usepackage{duckuments}
\MODULO{\year}{4}{\ye}
\newcommand{\autologo}{%
  \ifcase\ye\relax
      example-image-a%
  \or example-image-b%
  \or example-image-c%
  \else example-image%
  \fi}

\begin{document}
\pagenumbering{gobble}
\includegraphics[scale=1]{example-image-duck}  % works...
\includegraphics[scale=0.5]{\autologo}    % but I want something like this
\end{document}

enter image description here

TeX ignores spaces after the control sequence names (\relax, \or, and \else, for example), but not after normal characters, so with your previous code \includegraphics failed because it didn't find a file named logotp2.pdf .<extension>.

Edit:

Since we're apparently stuck here, let me suggest a more robust approach using expl3:

\documentclass{article}
\usepackage{pgf,calculator,ifthen}

% Copy this to the preamble of your document
\usepackage{xparse}
\ExplSyntaxOn
\seq_new:N \jom_logos
\NewDocumentCommand\DefineAutologo
  { m }
  {
    \seq_set_from_clist:Nn \jom_logos { #1 }
  }
\NewExpandableDocumentCommand\UseAutologo
  { m }
  {
    \seq_item:Nn \jom_logos { #1 }
  }
\ExplSyntaxOff

% Use this to set the images you want to use
\DefineAutologo{
  example-image-a,
  example-image-b,
  example-image-c,
  example-image
}

\MODULO{\year}{4}{\ye}

\begin{document}
\pagenumbering{gobble}
\includegraphics[scale=0.5]{example-image}  % works...
% Include the image with `\UseAutologo{<image-number>}`
\includegraphics[scale=0.5]{\UseAutologo{\ye}}    % but I want something like this
\end{document}

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.