LyX How-Tos

Spring 2014 LyX Training

Download this zip file to complete the LyX training for the Spring 2014 class! In the file you will find the LyX training document (which is a LyX file itself) as well as a zipped file that Heidi created as an example of what your completed assignment should look like.

Check out the Wiki Page for LyX 

This site has a some good information on how to do things in LyX.

Making Figures

Many figures come from PowerPoint diagrams and Excel or Mathcad graphs, and getting these figures to look good in the LyX pdf, with nice crisp lines and clear text, is somewhat difficult. The only language LyX, Excel, Mathcad, and PowerPoint all speak is pdf. Here is the recommended procedure:

  1. Open your image in the program you made it in.
  2. Print the image (e.g. by selecting File >> Print for just one PowerPoint slide) and select "Adobe PDF" as your printer.
  3. Go to "Properties" for the printer, and select "ASCE pdf figures" to use an ASCE driver that makes high-quality pdfs when you print files.  Also, uncheck the box in the printer properties window that says "Rely on system fonts only; do not use document fonts."  This will make the text look better.  The ASCE driver can be downloaded from the Web-o-net, but Cmail won't let me attach the .exe installer file to an email.
  4. Sadly, the pdf you made by making printing your file will have large white spaces around it.  There is nothing you can do in the printer settings to change this.  Instead, take your pdf image files on a flash drive over to Carpenter Hall (or some other computer that has Adobe Acrobat and not just Reader), and use the "Crop" tool (under View >> Tools >> Page in Adobe Acrobat) to crop out the white spaces around your image.
  5. Once your images have been cropped, they are ready for insertion into LyX.  You can add pdf images using the Insert >> Graphics command like you would do with any image file.
  6. When you make your LyX file into a pdf, the figures will look really good.  They will retain their character as vector images and will be "crisp" and not pixellated at any level of zoom.

A note on centering figures: to center any figure insert a LaTeX code box containing the text \centering in the float box that contains the figure you wish to center. 

Stuff You Can't Do in Menus

An overarching theme of the next few sections is that there are many things in LyX and its associated programs (chiefly BibTeX) that you cannot change easily in menus or other user controls.  LyX makes a lot of decisions for you, and some of them will inevitably not make your document look good.  Your page numbering defaults to starting at 1, putting your title page on page 1 and your table of contents awkwardly around page 10.  If you cite a source like a report by "American Society of Civil Engineers," your in-text citations will be (Engineers, 2009) and your bibliography will assume that the author is a person named, "Engineers, A.S.C."  If there is an article in your references list with a title that includes a word like "Honduras," it will show up in lower case letters automatically.  And if you were tempted to have a references list at the end of each chapter of your thesis, you can add two database files ... but a lot of your references will disappear. 
All of these examples have two things in common:  (1) It may take you many hours to fix each of them, and (2) there is nothing you can do in the menus, user options, etc. in LyX that make any of these problems go away.  To fix these problems you need to learn a bit of the nuts and bolts of LaTeX and BibTeX coding to complete thesis, or other complex document.   LyX pretends to be a totally user-friendly program that eliminates the need to use LaTeX coding, however this is not entirely true.

Page Numbering

It is possible to get Roman numerals on your pages before and up to your table of contents, and Arabic numerals starting on the first page of your actual text.  You need to do this by inserting LaTeX code boxes in the right places:  

and 

 right before your title does two things:  it gets rid of page numbering on your title page, and starts using Roman numerals for the beginning of the document and until further notice.  Then, after your Table of Contents, List of Figures, and List of Tables (each spaced by a page break), add another page break before Chapter 1 of the actual text and add another LaTeX command to switch to Arabic numerals: 

Making Bibliographies I - formatting references and citations

A good way to start is to put together your bibliography in RefWorks online, then export a BibTeX file from RefWorks.  This step is not too difficult, but does require one important step:  the file that RefWorks sends you, even though it is meant for BibTeX, has the .txt (text file) extension.  You have to change this to .bib before it will work.  Different operating systems have different ways to do this.  Once your file is in the .bib form, you are often far from done.  The online libraries and indices have many inconsistencies in the way they enter references, so some of your journal articles will come back with:

  • symbols like "&" that you have to delete because LyX cannot display them
  • journal titles in all caps, which you have to change
  • authors' first names, which must be changed to initials
  • authors' first and last names reversed, so (Mintz et al., 2008) might become (E et al., 2008)

Theoretically it is possible to get rid of all this stuff in RefWorks, but it is hard to catch everything.  One easy way to do this is to open the BibTeX database file and make all of these changes by hand to be sure that it is all correct.  The other key lesson is that you can use an extra set of braces to "fix" the text of a reference to make it appear EXACTLY as you want it to look.  Here is a typical examples of a BibTeX entry where the double braces method is used to get things to show up correctly - in this case, to capitalize things as I wanted them to appear in the article title because it defaults to lower case (please note that here the title should have double braces around it).

@article{RefWorks:58,

        author={C. B. Yang and Y. L. Cheng and J. C. Liu and D. J. Lee},

        year=
,

        title=Treatment and reuse of backwash water in Taipei water treatment plant, Taiwan,

        journal= ,

        volume=,

number=,

        pages=

Making Bibliographies II - non-traditional authors

Here is a method for citing a report where the author is something like ASCE or US EPA.  It consists of two basic steps - the BibTeX entry and the in-text citations.  We will use the example of the "Report Card for America's Infrastructure" by the American Society of Civil Engineers, 2009.  Here is how it is formatted in BibTeX with the "fixed braces" method (please note that here the author and title should have double braces around them):

@misc{RefWorks:34,

      author=American Society of Civil Engineers (ASCE),

       year= ,

       title=2009 Report Card for America's Infrastructure,

       journal= ,

       month= ,

       url={http://www.infrastructurereportcard.org/report-cards{color:#222222}}
This is using the "ascelike" convention, and bizarrely it is the case that the "Journal" line is needed in order for quotes to properly appear around the title of a misc or online reference.  Written this way, it will show up fine in a bibliography.
Now, here is how to make it appear correctly for in-text citations.  Lets say we want it to appear as (ASCE, 2009).  The first step is to add some code to the LaTeX preamble (Document >> Settings >> LaTeX preamble) for each reference whose default in-text citation we want to change.  The syntax is:  \defcitealias .  In order to use this, you cannot simply add a citation from the menu as you would with other references.  Instead, where you want (ASCE, 2009) to show up in the pdf file, you need to make the citation in LaTeX code.  For this example, the syntax is:  \citepalias

Making Bibliographies III - sectioning

The final challenge with bibliographies is getting them to section.  If you want a unique list of references at the end of each chapter of a document, that ends up requiring a few steps:

  1. Make a BibTeX file for each chapter by tagging your RefWorks entries with Paper 1, Paper 2, etc. and generating a file that includes only the references for each chapter
  2. Add the appropriate BibTeX file corresponding to each chapter at the end of that chapter, by using Insert >> List/TOC >> BibTeX Bibliography. 
  3. Change the settings in your document to a sectioned bibliography, using Document >> Settings >> Bibliography and selecting the box that says "Sectioned bibliography."  Also, change the Processor option from Default to BibTeX.  Note that you are now almost there, but it will not yet work if you are using a computer that does not have the required BibTeX package installed to handle a sectioned bibliography (in this case, it's called bibtopic)
  4. Install or activate the texmf-texlive\bibtex package.  This has been done on the Linux computer in B60A- it was there but inactive - so it should now work at least on this machine.
  5. Add two lines of code to your LaTeX preamble that say:  \usepackage[dot] and \usepackage .  This convinces LyX to use the packages you need.

Text, Equations etc. running off the page

Many times in LyX you might run into the problem of your text running off the page.  If it is simply text (in an author list, or a super long website) then all you need to do is add a LaTeX box with two backslashes in it where you want the hard return to happen.  If that doesn't work for some reason another command to try is \newline.  You can also use this method for breaking up equations, but it might be somewhat messy. We are currently trying to figure out ways to fix this problem with equations. 

  • No labels