0

I have the following code which I am using to input a formula into a begin equation. I have the package amsmath being used.

\newcommand{\formula}[2]{\begin{equation} #2 \end{equation}}
\formula{z=f(x_0,y_0)+f_x(x_0,y0)(x-x_0)+f_y(x_0,y_0)(y-y_0)}

It is not working in my program, and it says

! TeX capacity exceeded, sorry [input stack size=5000].
\end #1->\csname end#1
                      \endcsname \@checkend {#1}\expandafter \endgroup \if@e...
l.94 \end
         {document}

Do you have any thoughts why its not working?

Post Edit

\newcommand{\norm}[1]{\lvert \lvert #1 \rvert\rvert}
\newcommand{\formula}[1]{\begin{equation} #1 \end{equation}}
\maketitle
\begin{center}
\textbf{13.8 Maxima and Minima of Functions of Two Variables} \par
Theorem 13.8.6 Page 875 11th Edition
\end{center}
\begin{equation}
D=f_{xx}(x_0,y_0)f_{yy}(x_0,y_0)-f^2_{xy}(x_0,y_0)
\end{equation}
$
\begin{array}{c|c|c|c|c}
f_{xx}(x_0,y_0) & f_{yy}(x_0,y_0) & f^2_{xy}(x_0,y_0) & D & \text{Stationary Point Type} \\
\hline - & - & + & - & \text{ Saddle Point}\\
\hline - & - & + & +& \text{Relative Maximum} \\
\hline - & + & + & -& \text{Saddle Point} \\
\hline +& - & + & - & \text{Saddle Point} \\
\hline + & + & + & -& \text{Saddle Point} \\
\hline +& + & + & +& \text{Relative Minimum}
\end{array}
$
\par
\par
\textbf{Note:} You are subtracting the second term so it is negative ulitmately.
\begin{center}
\textbf{13.7 Tangent Planes and Normal Vectors} \par
Definition 13.7.1
\end{center}
The normal vector is equivalent to the gradient in other words \begin{equation} \vec{n}= \nabla f(x,y,z) \end{equation} The equation of the tangent plane is then the following: \begin{equation}F_x(x_0,y_0,z_0)(x-x_0)+F_y(x_0,y_0,z_0)(y-y_0)+F_z(x_0,y_0,z_0)(z-z_0) \end{equation} \par
13.7.2 Theorem
\formula{z=f(x_0,y_0)+f_x(x_0,y0)(x-x_0)+f_y(x_0,y_0)(y-y_0)}
\end{document}
4
  • I did another new command that had an input and it worked, I am just curious why this one doesn't work? Apr 20, 2020 at 15:21
  • 1
    Why defining the command with two arguments if you only supply one?
    – egreg
    Apr 20, 2020 at 15:23
  • Your command has two argument but you are giving only one. Apr 20, 2020 at 15:23
  • 1
    The following question might help you understand the syntax of \newcommand better: \newcommand argument confusion
    – Alan Munn
    Apr 20, 2020 at 15:32

1 Answer 1

2

\newcommand{\formula}[2]{\begin{equation} #2 \end{equation}}
means that you will write \formula{arg 1}{arg 2}, and that arg 2 appears in the equation (and arg 1 gets ignored). When you then write \formula{stuff}, TeX keeps going until it finds the next token to be arg 2.

So you probably want
\newcommand{\formula}[1]{\begin{equation} #1 \end{equation}}

8
  • I am re edit and so my whole code, and comment my question Apr 20, 2020 at 15:24
  • So I have to use 1 for 1 argument and 2 for 2 arguments and so on? Apr 20, 2020 at 15:25
  • Yes, the [k] indicates how many arguments your function will take. The other possible form is \newcommand{\command}[k][something]{} which makes use of an optional argument. But I'd get more comfortable with required arguments first.
    – Teepeemm
    Apr 20, 2020 at 15:28
  • This might be a side question do you know if there is a latex math software that I can use define a newcommand, and calculate like a first derivative and second derivative and so on cause that would be cool. Because the newcommands, can be math operations. Apr 20, 2020 at 15:29
  • @EnlightenedFunky – You can try sagetex: ctan.org/pkg/sagetex
    – DG'
    Apr 20, 2020 at 15:37

You must log in to answer this question.

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