1

I want to define a macro that takes two inputs

\Make{a}{b~\theint}

where the macro defined by

```
\newcounter{int}
\newcommand{\Make}[2][]{
\thispagestyle{empty}
\par\medskip{
\textbf{\small #2 -- Fall 2020} \par
    \setcounter{int}{1}   
    \loop
    \input{#1}
  \newpage
 \addtocounter{int}{1}\ifnum\value{int}<8
    \repeat
 } \rmfamily}{\medskip}
```

but I'm getting the error that the file in the input command is not found

Bernard
  • 271,350
Diana
  • 1,285
  • 7
  • 12
  • 1
    ~ is a non-breaking space (a command to produce a space in the PDF) and it doesn't work as a “general string”. Use {b \theint} instead – Phelype Oleinik Jan 20 '21 at 18:41
  • @PhelypeOleinik You sure that's the issue? I'd rather say that the macro is defined to take one optional parameter (the file name) which defaults to empty... – campa Jan 20 '21 at 19:16
  • @campa Ah, right, ignore me. (regardless, a b~\theint wouldn't work in the file name as seems to be the intent here) – Phelype Oleinik Jan 20 '21 at 19:21

1 Answers1

0

\Make is defined to take two arguments, the first of which is optional, since it has the following structure:

\newcommand{\Make}[2][]{%
  % <your definition>
}

As such, calling it with two mandatory arguments \Make{<a>}{<b>} will effectively ignore <b> as part of \Make, and assign #1 (the optional argument) an empty/blank value and #2 = <a>. Change your definition to the following:

\newcommand{\Make}[2]{%
  % <your definition>
}

Also note the use of % here. See What is the use of percent signs (%) at the end of lines? (Why is my macro creating extra space?)

Werner
  • 603,163