2

I am generating reports, like this...

\clearpage

\section{Gold and SPY}
\noindent
\begin{minipage}{0.60\textwidth}
    \centering
    \includegraphics[width=1.0\textwidth]{graphs/goldport.pdf}
\end{minipage}
\begin{minipage}{0.25\textwidth}
    \scriptsize
    \input{tex/goldport.tex}
\end{minipage}

\vskip1ex

\begin{minipage}{0.90\textwidth}
    \scriptsize
    \input{tex/goldmonthly.tex}
\end{minipage}

\vskip1ex

\begin{minipage}{0.90\textwidth}
    \scriptsize
    \input{tex/goldref.tex}
\end{minipage}

You see that the name "gold" pops up at numerous places. I would like to call something like \input{template(gold)}... Would that pe possible? Many thanks

  • 1
    \newcommand{\goldinput}[1]{\input{tex/gold#1}} and then \goldinput{ref} – egreg Feb 14 '17 at 14:19
3

Off cause you can declare your own command (not tested):

\newcommand{\subreport][1]{%
    \begin{minipage}{0.60\textwidth}
        \centering
        \includegraphics[width=1.0\textwidth]{graphs/#1port.pdf}
    \end{minipage}
    \begin{minipage}{0.25\textwidth}
        \scriptsize
        \input{tex/#1port.tex}
    \end{minipage}

    \vskip1ex

    \begin{minipage}{0.90\textwidth}
        \scriptsize
        \input{tex/#1monthly.tex}
    \end{minipage}

    \vskip1ex

    \begin{minipage}{0.90\textwidth}
        \scriptsize
        \input{tex/#1ref.tex}
    \end{minipage}
}

\clearpage

\section{Gold and SPY}
\noindent
\subreport{gold}
2

Define a command close to what egreg said in a comment:

\newcommand\Temp[2][tex]{#1/gold#2}

Then the default path is tex/ but can be changed with the optional parameter. Use it as

\includegraphics[width=1.0\textwidth]{\Temp[graphs]{port}}

and

\input{\Temp{monthly}}

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.