/usr/local/Slides/1_Disciplines/4_Latex/04/03_Command/#1.tex not found! SmtC: Show me the Code!
SmtC: Show me the Code
Ole Peter Smith
Instituto de Matemática e Estatística
Universidade Federal de Goiás
http://www.olesmith.com.br

$\LaTeX$ IV
Quando eu dou de comer aos pobres
Me chamam de santo
Quando eu pergunto por que eles são pobres
Me chamam de comunista
Dom Helder Câmera

Defining new commands

  1. \def\Exclamation{Please always enjoy!}
  2. On top of \def:

    \newcommand[number-of-arguments]{\command-name}
    {
       %command-body
    }
  3. \newcommand[1]{\Vector}
    {
       \underline{ \mathbf{#1} }
    }
    ...
    $\Vector{a}$.
  4. \newcommand[1]{\Matrix}
    {
       \underline{\underline{ \mathbf{#1} }}
    }
    ...
    $\Matrix{A}$.
  5. Alternatively:
    \renewcommand{\command-name}
    {
       %command-new-body
    }
  6. \renewcommand[1]{\phi}{       \varphi   }
    \renewcommand[1]{\epsilon}{   \varepsilon   }
    ...
    \phi(\epsilon)

    phi: $\phi$, varphi: $\varphi$, epsilon: $\epsilon$, varepsilon: $\varepsilon$.
  7. \newcommand{\Figure}[3]
    {
      \begin{figure}[H]
      \label{#3}
      \centering #1
      \caption{#2.}
      \end{figure}
    }
    ...
    \Figure
    {\includegraphics{figure.pdf}}
    {Title of figure}
    {fig:figure}
LaTeX Listing: Main.tex. PDF   ZIP*  
\documentclass{article}
\usepackage{pgffor}

\newcommand{\MyInclude}[1]
{
   File
   \IfFileExists{#1}
   {
      #1 contents: \input{#1}
   }{
      non-existent: #1
   }   
}

\newcommand{\MyListing}[1]
{
   \begin{itemize}
      \foreach \itm in #1
      {
         \item{\MyInclude{\itm}}
      }
   \end{itemize}
}

\begin{document}
   \newcommand{\MyList}{
      1,2,3,
      Section.1.tex,
      Section.2.tex,
      Section.3.tex,
   }

   \MyListing{\MyList}
   
   
\end{document}
Messages:
0 secs.