[Tex/LaTex] Fractions with `\dfrac` cause compile error


I'm new to LyX. I'm writing my next homework with it to give it a try. My example code is below:

% Preview source code

%% LyX created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
This is an expression with dfrac:

\[ f(x) = \dfrac{2}{x} \]

Under another question, they offered me to use \dfrac fractions for a better view. However, using dfrac causes compiler error like below:

Compiler Error

I thought this error with dfrac may be due to not using the amsmath package. I went to Menu > Document > Settings > Math Options, I unchecked Use AMS math package automatically and I checked Use AMS math package. LyX added \usepackage{amsmath} and \usepackage{amssymb} lines into the source code. Now when I try to preview my article in PDF format, it gives LaTeX Error: File 'amsmath.sty' not found. error.

I used to use online Latex editors, then copy screen shot of their output and paste it into MS Word. It was so simple doing that way. Now all these packages, uneditable source code, and all these complexity for writing a simple fraction is making me too frustrated. I have started to question if I did the right thing with switching to LyX. Because those online editors perfectly displaying that dfrac fraction in my example.

How do I write a simple dfrac fraction after opening a new article from Menu > File > New in a fresh LyX installation?

Best Answer

go to documents->settings->math-> enable amsmath