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
  • 1
    \newcommand{\goldinput}[1]{\input{tex/gold#1}} and then \goldinput{ref}
    – egreg
    Commented Feb 14, 2017 at 14:19

2 Answers 2

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}}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .