Showing posts with label latex. Show all posts
Showing posts with label latex. Show all posts

Monday, July 23, 2012

Inserting a comma after first of two authors with apalike citation in Lyx

Using apalike style, when there are only two authors Lyx does not put a comma after the first author's initials (before the "and"), to fix this, I had to edit the .bst file:
cd /usr/share/texmf-texlive/bibtex/bst/apalike
sudo gedit apalike.bst

save as apalike2.bst
change lines 214-222
 { namesleft #1 >
     { ", " * t * }
     { numnames #2 >
  { "," * }
  'skip$
       if$
       t "others" =
  { " et~al." * }
  { " and " * t * }
to
 { namesleft #1 >
     { ", " * t * }
     { t "others" =
  { " et~al." * }
  { ", and " * t * }
After this we might need to run the command
 sudo texhash
In Lyx, click on bibliography, browse to new (apalike2.bst) style file.

Changing Submitted to Defended date in CIT thesis title page

To change the line on the cover page from, say, "(Submitted June 26, 2012)" to "(Defended June 1, 2012)" one needs to follow these steps:
Go to Document>Settings...
Under Document Class section, add the word "defended" to the line for Custom Class options.
At the beginning of the document (I put it right between Copy Year and TechReport #) insert a Date section (using dropdown menu in top left of toolbar) that contains the string you want to appear after "Defended" on the title page.

Wednesday, June 27, 2012

Pybtex - useful tool for dealing with bibliographies in Python

http://pybtex.sourceforge.net/

sudo apt-get install python-setuptools
sudo apt-get install bzr

(bazaar is a version control system like svn. Apparently the bzr branch in the most up-to-date and stable version of pybtex.)
cd Downloads/
bzr branch lp:pybtex cd pybtex sudo python setup.py develop

Monday, June 25, 2012

Using Elyxer to convert from Lyx to html

To create a html version of my thesis, I found Elyxer to be extremely convenient. I believe the only steps were as follows:
  1. Download Elyxer from here. (The current version when I downloaded it was 1.2.3)
  2. In a terminal, run
    cd elyxer-1.2.3/
    sudo ./install.py
  3. If you used \emph{<species name>} in your .bib file, see NOTE below.
  4. Go to the directory containing your lyx document (here I use "document.lyx") and create a subdirectory for elyxer to save output images (I used htmlImages).
  5. In a terminal, run
    elyxer.py --destdirectory "htmlImages" --title "<title of html page>" document.lyx <name of the output>.html
  6. Move the html file to the destination directory.
  7. Double click the html file to view a nicely formatted and linked version of your lyx file!
NOTE: Elyxer cannot handle \emph{...} in the bibtex bibliography files. It was a bit of a pain to fix this, as the output html file eliminates the second }, making searching and replacing with <i> and </i> tags impossible. To overcome this, I followed these steps:
  1. Download the plugin for regular expression search and replace using gedit from here:
    1. Download and extract the files (found here).
    2. Move those files to ~/.gnome2/gedit/plugins/ :
      cd .gnome2/gedit/
      mkdir plugins
      cd plugins/
      mv /home/peter/Downloads/regex_replace ./
      mv /home/peter/Downloads/regex_replace.gedit-plugin ./
    3. Close gedit
    4. Open gedit, choose Preferences from the Edit menu. On the plugins tab, you should see Regular Expression Replace in the list. Check to enable. Now, you should have a "Regular Expression" item in the Search menu.
  2. open your bibtex file(s), and save a new copy (this will mess up the pdf output of your lyx document).
  3. In the regular expression search box, search for \\emph\{([a-zA-Z_1-9 ]*)(\}) and replace with <i>\1</i>
  4. This will probably miss some cases of \emph{...}, so do a final search for \emph using gedit's search feature and fix them by hand. (The [a-zA-Z_1-9 ] term only finds those characters, so expressions with linebreaks or other odd characters get skipped. This could be fixed if it is too big of a problem.)
  5. Open your lyx document, save as a new copy (again, we don't want to screw up the working pdf output) and change the bibtex files to our new versions. (Click on BibTeX Generated Bibliography, delete the existing bibtex files, then add the new ones.)

Setting up a Lyx template to write a Caltech thesis

I wrote my thesis using Lyx, a wonderful Latex-based document processor that made organization and citations easy. I used Ling Li's Caltech thesis template. Here are the notes to myself I made while installing it:

Getting Lyx to work with Caltech thesis

  1. install Lyx using Synaptic
  2. From http://www.work.caltech.edu/~ling/tips/cit_thesis.html download
    1. cit_thesis.cls
    2. cit_logo.eps*
    3. cit_logo.pdf*
    4. cit_ntheorem.std
  3. Run
    sudo mkdir -p /usr/local/share/texmf/tex/latex
    sudo cp Downloads/cit_thesis.cls /usr/local/share/texmf/tex/latex/
    sudo cp Downloads/cit_logo.eps /usr/local/share/texmf/tex/latex/
    sudo cp Downloads/cit_logo.pdf /usr/local/share/texmf/tex/latex/
    sudo cp Downloads/cit_ntheorem.std /usr/local/share/texmf/tex/latex/
    sudo texhash
    
  4. open Lyx
  5. run Tools>Reconfigure
  6. close Lyx
  7. reopen Lyx
  8. run File>New from Template
  9. choose cit_thesis.lyx
*Later I actually removed these files and replaced them with the current preferred Caltech logo from http://styleguide.caltech.edu/logo/logogallery. Then I copied this into the latex directory:
sudo cp cit_logo.png /usr/local/share/texmf/tex/latex/
sudo texhash

I can't remember if I needed to change format to .png or not.