A control sequence is a sequence of characters that has special meaning to LaTeX - in other words, it tells the program to do something more interesting than just putting the corresponding characters into your document. Typically, they are written as a backslash followed by some letters (though there are some exceptions). Control sequences have to be defined at some point so that the LaTeX compiler knows what they mean; for example,
\newcommand{\onehalf}{\frac{1}{2}}
is one way to define the control sequence \onehalf
to represent the fraction 1/2.
When LaTeX complains about an "undefined control sequence", it means you have used a control sequence that never got defined. The compiler "helpfully" shows you the control sequence that was not defined in the error message; for example:
! Undefined control sequence.
l.4 q_k(p)= f(x_k) + \nablaf
(x_k)^Tp + \frac{1}{2}p^T\nabla{^2}f(x_k)p
Look at the next line following "Undefined control sequence." The l.4
means that the control sequence in question was found on line 4 of your .tex
file, and the specific control sequence shows up at the very end of that line. In this case, it's \nablaf
. So that is the thing you need to change. Depending on the specific circumstances, you might need to define the control sequence using something like \newcommand
, or you might need to load a package that defines it, or you might just have made a typo, as is the case here.
\nabla{^2}
is a bit wrong. Your{...}
should go around the thing being superscripted, as\nabla^{2}
. As it happens, if your superscript consists of one and only one element, e.g.\nabla^2
this will work, but\nabla^2i
will give you ∇² i, what you need is\nabla^{2i}
. It's a good habit to get into always putting{...}
around the whole thing being superscripted – Au101 Dec 18 '16 at 18:39{...}
are paired you can sort of put them around whatever you like, and they will be ignored,{a}
=a
, however it can really upset spacing and is properly used to isolate something that might not otherwise be isolated. You could also probably get some crazy unexpected results and definitely if you gox^{{a + b} foo bar baz}
you will find the whole thing is superscripted. The superscripting will keep going until TeX has matched all of the{
s with}
s so don't use{...}
frivolously. But that is why you can get away with\nabla{^2}
– Au101 Dec 18 '16 at 18:46\documentclass
andbegin/end{document}
lines. It also helps to post the error that comes out. In this case, that error would put\nablaf
at the beginning of a line, which would indicate that the problem. But TeX errors are notoriously vague, so learning to read them can be difficult. – Teepeemm Dec 18 '16 at 19:44