[Tex/LaTex] How to use \watt in lyx

lyxUbuntu

I am trying to use \watt in LyX, but I find that although it is a very simple case, I have spent 1 week to solve it but in vein.

First, I found out that if I want to use watt then I must use the siunits package, so I tried to add this in LyX 'Document-Setting-LaTeX Preamble' with \usepackage{siunits} but when I typed in \watt (according to siunits documentation) in LyX, it appears as \watt still, without changing into 'W' symbol, and when I see the pdf file, it is also 'watt'

Second, I find that, maybe my TexLive does not have the siunits package, so I tried to install this package in TexLive on Ubuntu 14.04, but I find that it is another complicated issue, as I didn't directly install TexLive in my system, instead, I install it by installing TeXMaker, during which, the Texlive was installed automatically, but I noticed that someone said that this installation might lose some useful packages….but I really have no idea how to check that if my Texlive had installed the package siunits.

It's a little complicated, but, anybody has some idea?
Thank you!

Best Answer

To use LaTeX code directly in a LyX document, you need to write this in a TeX Code box (often called an ERT), which is inserted with Insert -> TeX code, or the shortcut Ctrl+L (Cmd+L on a Mac). Write \watt inside such a box, and it should show up as expected.


Unrelated note: I would recommend taking a look at the siunitx package instead of siunits, which I think is more powerful. With \usepackage{siunitx} added to the preamble, you can write a number with a unit as \SI{10}{\watt}, or a unit alone with \si{\watt}. Look at the manual for a lot of examples.