# A question about arguments to a LaTeX macro

Several weeks ago, I asked a question about a LaTeX macro to insert an image in a document using an IF statement. The solution worked perfectly. Now I have a similar issue. I have the following macro:

\newcommand{\notebook}[1]{
\newpage
\begin{center}
\fbox{\includegraphics[scale=0.50]{\nb#1.png}}
\end{center}
}


where

\newcommand{\nb}{"Text Analytics Using Python_Page_"}


is the the image to be inserted in the document. I use this in the document as, for example:

\notebook{"01"}
\notebook{"12"}


I want to modify this so that to be:

\notebook{1, This is an example notebook.}
\notebook{12, You can see from this notebook that XXX.}


Basically, I want to omit the double quotes around the image number (the "01" and "12") and I want to add some text below the image in the document. For the latter, I tried adding a second argument in the macro definition, but it didn't work. Any help with is is appreciated.

Walt Paczkowski

I'm using LaTeX on a Windows 10 laptop.

\newcommand{\notebook}[1]{
\newpage
\begin{center}
\fbox{\includegraphics[scale=0.50]{\nb#1.png}}
\end{center}
}


use a simpler call:

\notebook{1, This is some text.}
\notebook{12} Somme example text.}


## migrated from stackoverflow.comJun 7 at 10:32

This question came from our site for professional and enthusiast programmers.

• Can you make a minimal working example (MWE) that shows which packages you use? – user36296 Jun 6 at 22:12
• In general you would save yourself from many problems if you would not use special characters like spaces or underscores in image names. – user36296 Jun 6 at 22:13
• Why are you adding the quotes? – egreg Jun 7 at 10:42

• the usual tex method to pass multiple arguments to a macro is \macroname{arg1}{arg2} rather than a comma separated list.

• the "" around 01 should not be necessary because the problematic characters (spaces and _) are in the part of the filename, which is stored in \nb. It should be enough to enclose this part in quotation marks. Of course the much better approach would be not use such characters in filenames...

\documentclass{article}

\usepackage{graphicx}

\newcommand{\notebook}[2]{%
\newpage%
\begin{center}%
\fbox{\includegraphics[scale=0.50]{\nb#1.png}}%

#2
\end{center}%
}

\newcommand{\nb}{"test test_"}

\begin{document}

\notebook{01}{This is an example notebook.}
\notebook{12}{You can see from this notebook that XXX.}

\end{document}

• This worked perfectly. Thanks for the help. Walt – Walt Jun 7 at 15:06