# 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 2.0.5.1 created this file.  For more info, see http://www.lyx.org/.
%% Do not edit unless you really know what you are doing.
\documentclass[english]{article}
\usepackage[T1]{fontenc}
\usepackage[latin9]{inputenc}
\usepackage{babel}
\begin{document}
This is an expression with dfrac:

$f(x) = \dfrac{2}{x}$
\end{document}


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

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 2.0.5.1 installation?

## 1 Answer

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

• When I try to preview it says "LaTeX Error: File 'amsmath.sty' not found.". – hkBattousai Mar 21 '13 at 21:10
• @hkBattousai: See How do I update my TeX distribution? – Werner Mar 21 '13 at 21:12
• @hkBattousai: the \dfrac in your example has no effect, the equation is alread set in displastyle. However, I cannot believe that amsnmath isn't installed. What system do you have? – user2478 Mar 21 '13 at 21:14
• My OS is Windows 7 Ultimate x64. I installed LyX a few days ago. It installed packages during installations from a default online repository. I'm updating packages by MiKTeX update tool again at the moment. – hkBattousai Mar 21 '13 at 21:20
• Result: It only found update to a package named "fontspec". Then my code suddenly started to work. I don't know why but it now works. I did make any change in a bit other than running the update tool. I have a hard time understanding this LyX editor... – hkBattousai Mar 21 '13 at 21:28