0

I am new to latex. I am able to define symbols for instance:

\newcommand{\imageA}{\includegraphics[width=3em,valign=c]{image_01}}

I can call this symbol (\imageA) multiple times thus greatly simplifying my code.

How can I define a function that is similar to the symbol above except that it can take the name of an image as an argument \functionA{image_01}?

Question

How do I define a latex function that takes as an argument the name of an image (image_01.png) and outputs:

\includegraphics[width=3em,valign=c]{image_01.png}

So that I can call this function multiple times with different arguments in math mode:

\[ \functionA{image_01.png} \functionA{image_02.png} \functionA{image_03.png} \]
Conor
  • 349
  • 2
  • 7
  • 2
    \newcommand\functionA[1]{\includegraphics[width=3em,valign=c]{#1}}. Or better, \newcommand\functionA[2][]{\includegraphics[width=3em,valign=c,#1]{#2}} so that you can use options if you need, like \functionA[width=4em]{image_01.png}. – Phelype Oleinik Jan 21 '20 at 12:39
  • 2
    Off topic: observe that \[ \] is for displayed math mode, so it is strange to use it only to insert a graphic. Instead, use figure environment, for example. – Sigur Jan 21 '20 at 12:43
  • Thanks @phelypeoleinik. Your first comment answered my question completely! – Conor Jan 21 '20 at 12:51

0 Answers0