Advertisement

How to Use LyX on OS X

by

This Cyber Monday Tuts+ courses will be reduced to just $3 (usually $15). Don't miss out.

As a former student, I was (and to some extent, am still) a big fan of TeX -- a wonderful and versatile typesetting system first developed by Donald Knuth in the 1970s and still in widespread use today across the academic and scientific fields. The problem with TeX, though, is that it comes with a fairly steep learning curve -- you can't just start writing a document straight away in it and you need to learn the basics before you can start.

That's where LyX comes in. It's a document processor that uses TeX to render your documents, meaning you get pretty much the same results as if you'd written the document in pure TeX code, but it comes with a more user-friendly interface and apart from some advanced formatting (which is beyond the scope of this tutorial), you don't have to learn a single line of TeX code. In this tutorial, I'm going to cover LyX in some detail and show you how you can use it to easily create simple yet professional-looking documents.


Before You Start

LyX requires a TeX distribution to be installed on your Mac before you can start. There are plenty to choose from (as TeX is open-source) however for Mac users, the one that I would recommend is MacTeX, which is specifically designed for OS X and supports all official releases (including Mountain Lion -- as of July 2013 there is no word on support for Mavericks).

MacTeX is a custom-built TeX distribution for OS X.

MacTeX is a custom-built TeX distribution for OS X.

For most users, the package I would recommend installing is the full MacTeX package. It's approximately 2.3 GB in size and takes up around 4.5 GB on your hard disk drive. This may sound a lot but it also installs a lot of useful additional programs, such as a bibliography manager and the important TeX Live Utility, which allows you to install important updates. The file is a PKG installer file, which you simply click on to install.

You install MacTeX like you would any other OS X program through the built-in installer.

You install MacTeX like you would any other OS X program through the built-in installer.

There is a smaller MacTeX installer, available for people with slower internet connections, which clocks in at around 86 MB. This will install the skeleton of the TeX distribution and although you'll still be able to write documents in LyX using TeX, you won't get any additional extras. If you're serious about working with LyX, then I'd highly recommend to go with the full installation package.

TeX Live Utility is where you install any updates for your distribution.

TeX Live Utility is where you install any updates for your distribution.

Updating your TeX distribution is relatively simple -- simply click on the TeX Live Utility program within the TeX folder in your Applications folder. The program doesn't check for updates automatically, so I'd recommend firing it up every couple of weeks or so just to make sure you're running the latest software.

Now you've got your distribution sorted, it's time to install LyX and thankfully this is a lot easier (and doesn't take as long!). Simply head over to the LyX website, click on Download on the left-hand side and select 2.2. Mac OS X binaries (direct link to version 2.0.6). On Mountain Lion, you may need to allow the installation of software from unverified developers -- to do this, head over to your System Preferences, click on Security & Privacy, make sure the General tab is selected and click on the padlock in the bottom left-hand corner and enter your password. Make sure that the Anywhere radio button is selected underneath Allow applications downloaded from:.

You may need to allow installation from unidentified developers for LyX to install properly.

You may need to allow installation from unidentified developers for LyX to install properly.

You install LyX as you would any other OS X program -- simply mount the DMG file then drag the LyX icon into your Applications folder.


Creating Your First Document

When you first fire up LyX you'll be presented with the splash screen. Click on the New Document in the top-left hand corner of the screen (or alternatively hit Command + N to start a new document -- LyX will then create a new document in the article class (more on this in a second).

Creating a new document in LyX.

Creating a new document in LyX.

Before we get started properly, it's worth me giving you a quick tour around LyX's interface.

The two toolbars within LyX.

The two toolbars within LyX.

The two default toolbars are pretty much all you need within LyX. Most of the icons are pretty self-explanatory -- two useful ones are the drop-down formatting box (more on this in a moment) and the "eyes" symbol directly below it -- this renders your document in TeX (a bit like Print Preview), and displays the result as a PDF file in your default viewer (mine is Preview, for example) -- alternatively, you can hit Command + R.

LyX works according to the principle of WYSIWYM (or What You See Is What You Mean), as supposed to the WYSIWYG approach adapted by most other word processors. This means you can just type away without having to worry about the formatting -- all that is done for you when you render your document.

The default layout (or class, as it's known as in LyX-speak) is article. I've uploaded a quick example to show you what it's like. For most documents this will suffice, though you may want to change it from time to time. To do so, click on Document then Settings from within LyX, then select a new class from the drop-down menu.

The Document Settings is an extremely useful panel – here you can customise a number of different aspects to your document.
The Document Settings is an extremely useful panel – here you can customise a number of different aspects to your document.

Whilst we're in the document settings pane, I'll give you a couple of useful tips. Like iWork's Inspector view, all the main tweaks to your LyX document are done from within this pane. My three most used settings here are:

  • Text Layout: here you can choose the default paragraph indentation (in a variety of units) plus customise the line spacing.
  • Page Layout: set the size of your paper (by default it's US Letter) and its orientation (portrait or landscape), plus you can choose the headings that appear on each page.
  • Page Margins: set the page margins (again in a variety of units). To mimic a standard Pages or Microsoft Word document, choose 2 cm for the top, bottom, inner and outer margins.

The Fonts section is also pretty useful, but we'll get on to this in the Formatting section below!


Formatting Your Document

Formatting any document in LyX is pretty much the same as in any standard word processor, though there are a few little quirks that take some getting used to.

Fonts are one of the aforementioned quirks. Unlike other word processors, where you can choose from all the fonts installed on your Mac, LyX (or rather, TeX) comes with 3 built-in -- Roman, Sans Serif and Typewriter -- I've included examples of these below.

The three default fonts within TeX (and LyX)
The three default fonts within TeX (and LyX)

 

To change the font of your work, first highlight it (blue arrow), then click on the Text Style button (pink arrow) then change the Family to whichever font you want (green arrow) and click on OK. You can also change the shape, colour, language and size of the text from here as well.

Changing the font of your text.
Changing the font of your text.

 

To be honest, I prefer both the Roman and Sans Serif fonts that are included with TeX but if you want to use the fonts that are already installed on your Mac, then you'll have to use a couple of additional packages, XeTeX and LuaTeX. Don't worry, though, as these were installed when you installed your TeX distribution back in the first step of this tutorial. To enable them, go to the Document menu, click on Settings then select the Font pane and put a little check in the box next to: Use non-TeX fonts (via XeTeX/LuaTeX).

XeTeX allows you to use all the fonts that are installed on your Mac within LyX.
XeTeX allows you to use all the fonts that are installed on your Mac within LyX.

All standard formatting gestures are supported in LyX, including making your font bold (simply highlight the text and press Command + B) and underlined (yep, you guessed it: Command + U). One little peculiarity, though, is italics -- in LyX it's called Emphasis -- and for this you'll have to hit Command + E (for some reason, Command + I is disabled).

Tip: The Enter key doesn't work the same within LyX. Hitting it once will start a new line, however if you want to create some space within your document (i.e. where you would normally hit Enter several times, you'll need to enter what's called a ragged line break by hitting Command + Enter.

To change the justification of your text, highlight the sentence(s) in question then click on the Paragraph Settings icon in the toolbar (the blue arrow). From this view, you can also choose the line spacing and whether or not the paragraph should be indented.

Changing the paragraph settings
Changing the paragraph settings

Much like paragraph styles in both Microsoft Word and Pages, LyX also includes layouts, which allows you to insert headings, quotes, titles and so on into your document. Layouts are tied to the document class -- so the article class that I'm using for this tutorial supports most of the commonly-used ones -- however some classes support more. To create a new layout, select the one you'd like to use from the drop-down list and type away.

Working with layouts within your LyX document.
Working with layouts within your LyX document.

 

Headings are known as sections within LyX and can either be numbered or unnumbered. The Part option is the most important heading (this corresponds roughly to H1 in HTML) running down to Subparagraph (i.e. H7). You can also create lists, quotes, titles, addresses and so on in exactly the same way -- just choose which layout you'd like to use from the drop-down list -- when you render your document (which I'll look at in a moment) everything will be formatted correctly.


Working With Images

Images in LyX can, unfortunately, be a bit of pain to work with (and within TeX in general), however once you've mastered a couple of tips they become relatively straightforward. Unlike other word processors, you can't simply insert an image straight into your document -- you have to actually tell LyX you are putting an image in. How? Let's find out.

The easiest way to do this is via a float. This is a special environment within LyX where you can insert images -- and inserting a float also tells LyX how to handle the image within the TeX code (which is done on the backend). To insert a float, click on the Insert menu, point your mouse to Float and select Figure. A red float box should now appear within your document.

Through trial and error, I've found that floats are the best way to work with images.
Through trial and error, I've found that floats are the best way to work with images.

By default, LyX will let you include a caption with your image, however you can delete this by simply hitting the Backspace key. Now, to insert an image, click anywhere within the float box then select the Insert Graphics icon on the toolbar, or alternatively go to the Insert menu and select Graphics.

To add a new image, click on the Graphics icon in the toolbar.
To add a new image, click on the Graphics icon in the toolbar.

Now select your image using the Browse button from your hard disk drive (LyX supports most common image formats, including those in PDF) and click on OK. I prefer not to see a preview of my image whilst working in LyX -- to do this click on the LaTeX and LyX options tab and uncheck the Show in LyX box. Your image will then appear within the float box, where it can be justified as normal using the Paragraph Settings pane we looked at earlier. You can even resize your image within LyX -- just click on the image and select the two boxes Set width and Set height then type in your preferred dimensions.

You can resize your image directly within LyX.
You can resize your image directly within LyX.

 

I'll freely admit it here: working with images inside LyX is a bit of a pain in the backside, though if you follow my tricks with float boxes, you won't go wrong. Although some users prefer to insert images directly into their document (without using figure floats), I personally wouldn't recommend it as it can mess up the formatting of the rest of your document!


Exporting Your Document

I've found through trial and error that the best way to export your LyX document is to render it, where it will pop up in Preview then export it from there. Although LyX does feature exporting to a variety of different formats, including DVI (a file format associated with TeX), plain text, Postscript and RTF, for most users you'll want your document in a PDF file.

Rendering your document as a PDF file.
Rendering your document as a PDF file.

To render your document, either click on the eyes icon in the LyX toolbar or simply hit Command + R. Your document will then appear as a PDF within Preview (or whatever the default PDF reader is on your Mac), where you can either save it to your hard drive or open it in another program for further processing.


Conclusion

Although LyX does come with a slightly steeper learning curve than other word processors, I still believe it to be one of the most pain-free ways of writing long documents for whatever purpose. In this tutorial I have demonstrated to you how to use LyX to create a simple, yet professional-looking document and I would highly encourage you to have a play around with it -- it is a vast program with loads of features built-in (and too many to cover in one tutorial!) but you'll soon find that with a bit of practice you'll get your documents looking spot on every single time.

If you've got any questions about LyX (or want to share any useful tips) then please post them in the Comments section below -- I'll be happy to help out!

Advertisement