| May 19, 2010 3:52 am

While LaTeX is a powerful way to prepare and typeset many types of publications, there are certain times when it is both more convenient and efficient to have a graphical user interface.  This is why the document processor, LyX, was created.

LyX combines many of the best characterizes of a Word Processor with the strengths of LaTeX; and the result is a program that gives you the power of semantic writing without having to laboriously climb the LaTeX learning curve.

But as wonderful as LyX might be, it isn’t perfect.

One of LyX’s biggest limitations is the relatively small number of LaTeX document classes that can be used with it.  This limitation is due to the fact that even though LyX uses LaTeX to create its final output, it isn’t able to directly read and parse LaTeX styles.  Rather, it requires a special type of file (known as a “layout”) to help translate between what a user sees on the screen and what eventually appears on the printed page.

Unfortunately, creating layout files is a bit of an arcane art; and as a result, many document classes are never adapted to work with LyX.

(For more information about how the relationship between LyX and LaTeX –including an example of how to create a custom layout from an existing document class – please see my earlier article, Customizing LyX: Create an NIH Grant Proposal Template.)

This is not something that I would like to see happen with my custom Curriculum Vitae document class, xetexCV.  I spent a great deal of time developing and debugging the document class and  as a result, I would like to see people using it, including LyX users.  As a result, in this article, I will introduce a layout file that allows you to use xetexCV from inside of LyX and I will show how LyX users can enjoy the same amenities (including an automatically generated bibliography) enjoyed by LaTeX purists.

What I will not discuss, however, are topics that I’ve written about previously.  This includes the overview of xetexCV, its use and installation; the dissection of the LaTeX code and my design choices; or a detailed set of instructions on how to automatically generate a list of references from your BibTeX database.  As some of that information is pertinent to things discussed here, you may wish to read the earlier entries in this series prior to proceeding.

xetexCV Layout File

Downloads and Installation

In order to use xetexCV with LyX, you will need to download and install both the LaTeX document class and the separate LyX layout package.  (Instructions for the former can be found in Part 1 of this series.)  To download a .zip archive that has the layout file and the example files for this article, click here.

To install the layout file, first extract the folder to your hard drive.  Then, copy the “xetexCV.layout” file to the “layouts” directory in the LyX data folder.  When finished, reconfigure LyX (Tools->Reconfigure).

Package Requirements and Configuration

The xetexCV document class has a number of requirements for it to run.  These are:

  • The XeTeX Typesetting Engine.  For users of Mac OS X and Windows, XeTeX is included in the MacTeX and MikTeX distributions (respectively).  Users of Linux, however, will need to install the texlive-xetex package.
  • Fontspec package (included with MacTeX, MikTeX, or texlive-xetex).
  • Appropriate OpenType Expert Fonts.  By default, the document classes uses the Fontin and Fontin Sans fonts, which should be installed in the fonts folder for your system.

In addition to these steps, you will also need to configure LyX to work XeLaTeX.

  • Versions 2.0 and later of LyX support XeLaTeX without any additional setup.  To enable the feature, all you need do is go to Document -> Settings -> Output, and then enable the “Use XeLaTeX” feature.
  • For users of LyX 1.6.5 and earlier, however, you will need to crate a new file format (PDF XeTeX) and LyX -> XeTeX converter.  (Detailed instructions can be found on the LyX wiki.)

xetexCV Usage

LyX Example Document

image

Available Styles

The xetexCV layout file includes custom insets and specialized styles that give you access to all of the features of the underlying document class.  These include specialized styles for your demographic information: name, institution, address, phone, fax, email, and website.  The styles can be accessed via the drop down box in the upper right hand corner of the LyX window.  They should only be used once in your document.

LyX - WYSIWYM

Styles are also available for for the \cvsection and \cvsubsection macros and can be found in the same place.  cvsection and cvsubsection may be used as many times as needed.

Custom Insets

The xetexCV layout includes a custom inset that can be used for the \years macro.  This inset is available from the Insert -> Custom Insets menu.

image

For spacing purposes, the years inset should be used at the end of content lines; otherwise, it may cause problems with the left alignment.

image

Adding a Photo

You can add a photo to the CV through the use of the \cvimage macro, which should be added to the LaTeX preamble (Document -> Settings -> LaTeX Preamble).  Due to the way that LyX compiles LaTeX files, you should include the full path to the image.  This path cannot have any spaces in it.

\cvimage{/path/to/images/JRR-Tolkien.jpg}

Automatic Bibliography

xetexCV provides a way to automatically generate a “Publications” list from a BibTeX database via the cvsplitbib package.  In LyX, this is a four step process:

  1. Include the cvsplitbib package in your LyX document preamble.
  2. Add a BibTeX bibliography and associate the appropriate BibTeX database.
  3. Specify reference categories and citations you would like to include using the category environment and \SBentries macro (also done in the LyX document preamble).
  4. Using LaTeX commands, rename the bibliography section and add an appropriate \nocite command.
imageStep 1: Include cvsplitbib package

Unlike when using LaTeX, to use cvsplitbib with LyX, it must be installed in a directory that is included in your LaTeX path.  (For instructions, see Step 2 of this article.)

Once installed, simply add the following command to your LyX document preamble (Document -> Settings -> LaTeX Preamble):

\usepackage{cvsplitbib}

Step 2: Add BibTeX Bibliography and Associate the Appropriate Database

Next, you need to add a BibTeX bibliography to your document. To do this, simply click on Insert -> List/TOC -> BibTeX Bibliography.  Then, click on the bibliography, which will load the BibTeX database dialog.

To add a BibTeX database, press the “Add” button and then the “Browse” button.  Locate your BibTeX file on your hard drive and press “Open”, and then “Add”.

When you’ve added all of the necessary databases, press the “Ok” button.

Step 3: Specify Reference Categories (LyX Preamble)

To work correctly, cvsplitbib requires that you create at least one reference category.  This is done via the use of the \SBentries macro and “category” environment (again, placed in the LyX preamble).  The example below creates a single category called Books:

\begin{category}[A]{Books}
\SBentries{Tolkien2005,Tolkien1965,Tolkien2008,Tolkien1997,
Tolkien2008a,Tolkien2004, Tolkien2009}
\end{category}

Note: Citation keys should be entered as a list separated by commas, any spaces will result in an error.

Any reference that is not included in a specified category will be added to another group, titled: “Miscellaneous.”  (For additional information about cvsplitbib, please see Part 3 of this series.)

Step 4: Rename Bibliography Section and Add \nocite Command


Once you have categorized the references, the final step is to choose which references you would like to include in the list (and to rename the resulting list to something other than “Bibliography”).  These two tasks are done via the \nocite and the \renewcommand macros.

The example code below (which should be added near the end of your document as LaTeX code, Insert -> TeX Code) renames the bibliography to “Writings and Publications” and tells BibTeX to include all citations in the database.  I also explicitly define which of the BibTeX styles I would like to use, via the \bibliographystyle command.

\renewcommand{\refname}{Writings and Publications}
\nocite{*}
\bibliographystyle{plain}

LaTeX Examples

For further examples of more advanced xetexCV documents, you might be interested in the following LaTeX files:

______________________________________________________

Acknowledgements and Further Reading

The xetexCV document style is based on work from Dario Taraborelli’s website.  The cvsplitbib package is a modified version of splitbib, by Nicolas Markey.

This article is final entry in a four part series.  Part 1 introduces the xetexCV document class and describes its use.  Part 2 dissects the code and explains how it works.  Part 3 shows how to generate a publications list through the use of a .bib database and custom BibTeX style.

Comments

8 Responses to “Typeset Your Curriculum Vitae – Part 4: xetexCV and LyX”

[…] class and describes its use.  Part 2 dissects the code and explains how it works.  Part 4 describes how to use the document class and a corresponding layout file with […]

Rob Oakes wrote a comment on May 19, 2010

People using TeXLive 2007 (the version of LaTeX that was included with Ubuntu 9.10 and older) have reported problems compiling the example document from LyX. The best solution to this problem seems to be updating to a newer version of TeXLive.

TeXLive 2009 is included with Ubuntu 10.04, if you are able to update your Linux distribution. If not, it is possible to install newer versions of TeXLive alongside an existing install. I am currently working on a blog post that explains how this is done and I will post it when finished.

Youssef wrote a comment on August 10, 2010

Coming back after some time, I adjusted your code a bit so that it will work without a picture. (just changed \leftskip to 0pt)

\newcommand\makecvtitle{
\ifthenelse{\equal{\@cvimage}{\relax}}
{ % Create Without Image
\ifthenelse{\equal{\@cvname}{\relax}}{}
{\textsf{\LARGE\bfseries \@cvname}\decorativeline\vspace{0.3cm}}
—> \leftskip 0pt

Hope this works for other people (like me) who don’t need to include their pictures in the CV.

Otherwise, thanks for your great effort.

Jan wrote a comment on January 7, 2012

Hello,
thank you very much for your effort, it is greatly appreciated. However, I have a short question remaining: how would it be possible to vertical align the years to the top? When I now have an entry which spans to lines, the year(s) are aligned to the bottom.
Thanks again,
Jan

Vivek Sharma wrote a comment on June 1, 2012

Excellent contribution. How do you add multiple phones/emails and have them appropriately aligned?
e.g Phones: H: xxxxxx
O: yyyyyy
C: zzzzzzzzzz

MP wrote a comment on August 21, 2012

Massive massive thank you for all of this. Very detailed and very very useful!

PC wrote a comment on December 2, 2012

Hi! Thanks for this work!

Let’s see, I am having a bit of trouble specifying bold fonts in LYX.

1. In Document > Settings > Fonts I selected “Use Non-Tex Fonts”.
2. In the Document > Settings > Preamble I entered \setmainfont and \setsansfont properties

But if I select something to be bold, it does not typeset bold. Is use of bold fonts in the main font being overruled by the xetexCV layout or xetexCV class?

Thanks for any advice!

Pablo

Christoph Burschka wrote a comment on August 29, 2016

Note: The font files have moved to a new site, and are now available at these URLs:

http://www.exljbris.com/fontin.html
http://www.exljbris.com/fontinsans.html

Care to comment?