How to reuse LaTeX commands (\newcommand{}) in Quarto documents to avoid rewriting repetitive sections?

Hello community!

Is there a way to avoid rewriting certain sections in Quarto documents (especially in the "book" format) by using the LaTeX \newcommand{} functionality? For example, I would like to define commands for formulas and plots just once and reuse them throughout the document, without needing to create multiple .tex files for each piece of data.

Example of a formula command:

\newcommand{\formulaz}[1][display]{
  \ifthenelse{\equal{#1}{inline}}{
    $\sum_{i=1}^{n} f(x,y) \cdot g(x,y)$
  }{
    $$
      \sum_{i=1}^{n} f(x,y) \cdot g(x,y)
    $$
  }
}

Usage throughout the document:

Text before inline formula: 
\formulaz[inline] 
text after inline formula.

Text before display formula: 
\formulaz
Text after display formula.

Example of a plot command:

\newcommand{\nomeGraficox}{
\begin{figure}[H]
    \centering
    \begin{tikzpicture}
    \begin{axis}[
        title={Example Plot 1},
        xlabel={X-axis label},
        ylabel={Y-axis label},
        xmin=0, xmax=10,
        ymin=0, xmax=10,
        xtick={0,2,4,6,8,10},
        ytick={0,2,4,6,8,10},
        legend pos=north west,
        ymajorgrids=true,
        grid style=dashed,
    ]
    \addplot[
        color=blue,
        mark=square,
    ]
    coordinates {
        (0,0) (1,1) (2,4) (3,9) (4,16) (5,25)
        (6,36) (7,49) (8,64) (9,81) (10,100)
    };
    \legend{Data}
    \end{axis}
    \end{tikzpicture}
    \caption{Example Plot 1}
    \label{fig:example1}
\end{figure}
}

Is there any limitation or recommendation for defining these commands once in the Quarto document and using them whenever necessary, without relying on separate .tex files? What is the best practice to avoid rewriting repetitive sections?

Thank you!