LyX is a wysiwyg LaTeX editor that I find useful to write exercises fast instead of TextMate that I use for long-term projects. So the below shows an exercise that I would like to print as PDF: however I am getting the following errors Undefined control sequence that are very vague. I cannot see any \begin{document} or other LaTeX commands in LyX in the view which makes debugging harder than in text-based editors. So

How can I compile a document in LyX?

enter image description here

  • 3
    the fact that \mathbb is what's unidentified means that amsfonts (or if you need more symbols, amssymb, which loads amsfonts) isn't loaded. so try adding that to your job. (but i don't know how, not being a lyx user.) – barbara beeton Mar 4 '16 at 17:51
  • @barbarabeeton thank you for the observation: I realized from that to search for packages and I found a solution, provided below for new LyX users, nice software :) – hhh Mar 4 '16 at 18:06
  • What options do you have set in Document > Settings > Math Options? – scottkosty Mar 4 '16 at 18:35
  • @scottkosty thank you for the observation, added the alternative method here. – hhh Mar 5 '16 at 16:20
  • @hhh looks good. I would add that there is an advantage of doing it the LyX way because that way LyX knows about the packages that are being used. This way LyX can load them in the best order (sometimes this makes a difference in LaTeX, although in this case I doubt it). – scottkosty Mar 5 '16 at 16:57

Document > Settings > LaTeX Preamble

and add your preamble such as \usepackage{amsmath,amsfonts,amssymb,amsthm} so

enter image description here

and CMD+R to get the document compiled like in TextMate -- it works without writing any \begin{document}.

Document > Settings > Math Options

More graphical method as pointed out by the comment is to tongle the settings in Math Options like the below and in this case you don't need to add the mathematical packages to LaTeX Preamble.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.