|How to create beautiful documents under Linux using LyX
||[Feb. 18th, 2012|02:26 am]
LaTeX academic typesetting system. LyX provides a front-end to LaTeX, making it potentially easier to use than most commercial word processors (at least if you want to create publication-quality output). This remarkable combination, in conjunction with the underlying operating system likewise being free and open source, means that the ability to produce documents meeting the highest professional standards is within the reach of literally anyone with access to a computer.Despite sincerely trying, so far I've never quite succeeded in creating a printed document using ordinary word processing software which is as elegant as that produced by the venerable |
The following contains my suggestions for setting up a Linux system for the sake of running LyX, and recommends a series of free and open source graphics and mathematics tools which complement LyX.
- I chose to install the Debian distribution of Linux, with the GNOME desktop. Most users might prefer to install the more popular Ubuntu distribution, so in what follows I'll try to note where there might be a difference.
- To make the Debian installation DVD appropriate for most hardware, just go here and download the file named "debian-X.Y.Z-i386-DVD-1.iso". For Ubuntu, download this instead. [Note: Under Windows 7, you can burn ISO files like these to a blank DVD by right-clicking it and selecting Open With->Windows Disk Image Burner.]
- Browse your Windows partition and see if any user files (particularly large collections of media files) could be either deleted or permanently moved to an external drive. Once you've done as much of that as you can, make a full backup of your Windows partition to an external drive.
- If you're using Debian, follow these instructions to install it on the same physical drive as Windows, such that you'll be able to select whether you want Debian or Windows every time the computer boots. Under Ubuntu the process may be even easier. [Note: In either case, consider taking advantage of the installer's "Configure encrypted volumes" feature if you intend to store anything sensitive - you're unlikely to notice any significant difference in performance.]
- During the installation process, be sure to indicate that you want a "desktop environment" (in the Debian install procedure, for example, you make this choice on the "tasks" screen).
- Direct your preferred package management tool to install "recommended" packages just as if they were "dependencies": in Debian's "Synaptic Package Manager," for example, this option is found in Settings->Preferences->General.
- Next, configure your printer (under Debian's GNOME desktop, for example, this can be done via System->Administration->Printing). If your printer is connected directly to your computer via a USB cable, and nobody should be printing to it remotely, then there is no need for this printer to be "shared." If your printer is capable of duplexing and you choose to enable double-sided printing, then you may need to turn on the "Ending Banner" in order for documents with an odd number of pages to print properly (this was my experience, at any rate, and I was unable to find a more elegant solution).
- Given how much time you're likely to spend using your web browser, trying out all of the practical options before making your choice would be time well-spent. At present, the two most popular browsers are Firefox (which Debian calls "Iceweasel" and which is installed by default under both Debian and Ubuntu) and Google Chrome (the 32bit or 64bit Debian, Ubuntu, Fedora, or openSUSE package for which can be downloaded here): these are also the only two browsers through which you can read your Kindle ebooks under Linux via the Amazon Cloud Reader, so for that reason alone many users will want to chose one of those two. Even though the majority of its code is drawn from Google's open source Chromium browser, Google Chrome itself is not open source: so, if you are committed to a 100% open source desktop, Google Chrome may not be an option for you. On the other hand, at least under Debian "Squeeze," the version of Firefox/Iceweasel installed by default is too old to work with Amazon Cloud Reader, meaning under this distribution you would probably need to compile a more recent version of Firefox from source if you choose not to go with Google Chrome. Google Chrome also has Adobe's flash player built-in and enabled by default, which takes care of at least one long-standing source of hassle and poor performance for Linux users. In any case, the choice is obviously yours.
- I strongly recommend installing the ntp package, so you can have confidence the timestamps written to any files you create or edit are absolutely correct.
Installing and Using LyX:
- Install the following packages: texlive-full, latex2rtf, unrtf, chktex, rcs, elyxer, inkscape, and lyx.
- If you intend to create documents with bibliographies, and particularly if you may end up creating different documents which share some of the same references, you should get in the habit of using reference management software. The three free and open source options for Linux which currently offer LyX integration via the lyxpipe mechanism are jabref (a Java application), kbibtex (a KDE application), and pybliographer (a GNOME application). Of those three jabref appears to be the most feature-rich, though if you don't need the additional features and run either KDE or GNOME, you should compare it with one of the other two before making a final decision. If the tool you would prefer to use can't handle a particular bibliographic data input format that you need, then consider installing bibutils, a package of command line utilities for converting between a variety of them.
- If you will need to merge or split pdf files, install pdfsam.
- Open System->Preferences->Keyboard->Layouts->Options->Compose Key Position (or the equivalent if you're using a desktop environment other than GNOME), and check "Right Win" (or something else if your keyboard doesn't have those mysterious Windows logo keys). You can then press and release this key, followed by two other keys according to this chart, to type special characters.
- If you're using US "letter" sized paper (i.e. 8 1/2" x 11") rather than the slightly larger European "A4" sized paper, then LyX may need to be told this. Start LyX, make the change to "US letter" paper in Tools->Preferences->Output->LaTeX, and select Save.
- Open a new document in LyX (via File->New). First, go to Document->Settings->Page Layout: if you're using US "letter" sized paper, then change the paper format to "US Letter" and click on "Save as Document Defaults". Next, go to Document->Settings->Fonts, change Roman to Latin Modern Roman, Sans Serif to Latin Modern Sans, and Typewriter to Latin Modern Typewriter, and once again click on "Save as Document Defaults."
- The fact that you installed "latex2rtf", "chktex" and "rcs" enables a few more features in LyX (if you don't see them right away run Tools->Reconfigure and then restart LyX): you can use File->Export to export a LyX file as Rich Text Format (which Microsoft Word and almost all other word processing software can understand), the "Check TeX" command in the Tools menu helps you find typographical problems with your document, and "Version Control" in the File menu lets you track your writing progress and revert to any earlier version of your document (for more details on using version control see Help->Additional Features->Table of Contents->LyX Features needing Extra Software->Version Control in LyX).
- If you'll be exporting as Rich Text Format, and then importing into Microsoft Word, any LyX documents which contain equations, then go to Tools->Preferences->File Handing->Converters and remove the "-p" and "-S" switches from the command which invokes latex2rtf (after saving this change you'll need to run Reconfigure and restart LyX).
- It bears mentioning that the only reason you should ever have to export a LyX document as Rich Text Format is if the person you'll be sending that RTF file will be taking over from you the job of editing it: if the recipient only needs to read your document, then you should save it in standard PDF (pdflatex) format, which unlike RTF format will present your document exactly as it is supposed to look.
- If you're required to use double-spacing with a 12 point font, then go to Document->Settings->Text Layout to set "Line spacing" to Double, and go to Document->Settings->Document Class to enter "12pt" as a Custom Class Option.
- If the version of LyX installed by the above procedure isn't recent enough for you (which is likely the case if you're running Debian "Squeeze"), then after going through the above steps follow this procedure to compile the most recent version of LyX from source. To those instructions, I would add that if you specify a "LyXServer pipe" in Tools->Preferences->Paths, use a different path to that pipe in the version of LyX you just compiled, and want to take advantage of that pipe when using separate reference management software, then you'll want to change the location of that pipe in your reference management software as well (e.g. for pybliographer in Settings->Preferences->Base->Lyxpipe).
I also found it necessary, in addition to the other configuration changes mentioned in this guide, to change "Thesaurus dictionaries" to /usr/share/myspell/dicts in Tools->Preferences->Paths, and also switch the Spellchecker engine to "Enchant" in Tools->Preferences->Language Settings->Spellchecker.
- You will almost certainly want to install some (if not all) of the software packages mentioned in the following two sections on graphics and mathematics. After you're done, start LyX and issue the Tools->Reconfigure command so that LyX can take advantage of any of the new tools which can be utilized as either converters, editors, or viewers.
Creating attractive graphics for your LyX documents:
- Be sure to save your graphics in the most appropriate format: JPG for the final version of photographs (ideally you should use a lossless format during the editing process), PNG for non-photographs which weren't created by vector-based software (e.g. a screenshot), and either PDF or SVG for everything else. [Note: The one rare exception is if you're collaborating with someone who not only isn't using LyX, but isn't even using the modern "pdflatex" compiler for LaTeX - in this case the only reliable option is for the graphics to all be in EPS format and to export your document as "LaTeX (plain)."]
- Installing inkscape, as should already have been done, is basically essential due to the number of other tools which depend on it. Inkscape is also one of the first tools you'll probably want to master (though in the specific case of needing to make a quick geometry diagram you might save time by using geogebra in its place). If you'd like to work from a book while learning, try The Book of Inkscape.
- Installing the gnuplot tool is likewise essential: it's one of the two most popular methods for making data plots from the command line (the other being pyxplot), and even if you don't invoke it directly many other software packages require that it be installed. If you'd like to learn to use gnuplot directly the new book Gnuplot in Action might be a good place to start, but before going down this path you should first compare gnuplot with pyxplot before deciding which to learn: the goal of the latter is to make creating publication-quality plots even easier. [One miscellaneous gnuplot tip: unlike the "postscript" or "svg" gnuplot terminal types, with "pdfcairo" if you're using gnuplot interactively then depending on the gnuplot version your plot may not actually be written until you exit.]
- If you need to edit photographs the most fully-featured option is gimp, but if you don't need to do anything complicated and only edit photographs occasionally, pinta might be a better choice. If you'd like to learn gimp from a book, then consider GIMP 2.6 for Photographers.
- If you need to create diagrams similar to those from Microsoft Visio, then install dia-gnome (or simply "dia" if you're not using the GNOME desktop). If this application proves unsuitable for you, then for certain specific types of diagrams you might be able to obtain higher-quality results (and after ascending the learning curve obtain even faster results) via the command line tools in the graphviz package.
- If you need to create illustrations involving world maps, then install the gmt collection of command line tools. Note that at least under Debian, this package installs the collection of gmt binaries in /usr/lib/gmt/bin/ rather than /usr/bin/, and expects you to call them via the /usr/bin/GMT wrapper. So, if you install the gmt-examples package and want to try one of the examples, then you'll need to either edit the example script and add "GMT " before each gmt command, or else temporarily put /usr/lib/gmt/bin/ on your path.
- Hopefully this won't come up often, but if you need to create a new graph from an old one which is only available in print, and have no way of getting the underlying data that was used to create it, then make the best scan of it you can and install the engauge-digitizer tool to reduce it back to data points.
Mathematics tools for producing graphable data:
- If you're proficient in Excel, or any other spreadsheet program, then install gnumeric (a GNOME application). [Note: this software is well-regarded by statisticians for its numerical accuracy, and it has basically no learning curve, but you might need to export its results to something like gnuplot or R if you need to produce publication-quality graphs.]
- If you're proficient in S or S+, or else work with statistics professionally, then install an R environment by first installing r-cran-rcmdr followed by the rstudio IDE (the latter of which must be installed by manually downloading and installing the package file rather than through your package manager). This will give you a choice of three environments in which to work with R: the command line (invoked with "R"), the R Commander GUI (invoked by issuing "library(Rcmdr)" after starting R via the command line), and the RStudio IDE (invoked with "rstudio" and what most users will likely prefer). It's worth noting that R has become a de-facto standard amongst professional statisticians, it provides high-quality graphing capabilities of its own independently of gnuplot, and many books have been published on how to use it (I recommend R Cookbook if you're familiar with statistics and Using R for Introductory Statistics if you aren't). One last suggestion: particularly if you're using a 2.x version of LyX, I strongly recommend implementing this time-saving "sweave" procedure for including R output in your LyX document on the fly.
- If you're proficient in Matlab, install qtoctave (which uses gnuplot for graphing). One example of a textbook which demonstrates how to perform each computation in Octave is Scientific Computing Using MATLAB and Octave (this book takes care to only use functions common to both MATLAB and octave so each example will work under both).
- If you're proficient in SigmaPlot or Origin, install scidavis. [Note: like R, this software provides its own graphing capabilities independently of gnuplot.]
- If you're proficient in Mathematica or Maple, install wxmaxima. [Note: this software invokes gnuplot for graphing.]
- If you're proficient in SPSS, install pspp. [Note: you'd need to export its data to something like gnuplot or R if you need to produce publication-quality graphs, and long-term you'd probably want to migrate from pspp to R.]