Go to page:

Search:   Help

Navigation

Groups

LyX documentation

Edit

Shared groups

Links

Tips

Categories: Tag me, Bibliography, Tips
<< Emacs' bibtex-mode | Page list | Tips and Tricks for using Jurabib >>

Encoding

Bibtex has many difficulties with files encoded in UTF-8 which is nowadays the default file encoding on many GNU/Linux systems and text editors. On should therefore try to use latin1 (ISO-8859-1) as file encoding. In JabRef this can be set in the Options-Menu.

Change bibliography heading

You can change the heading of your bibliography by inserting a ERT element (Insert→TeX) right before the bibliography with the following command: \renewcommand\refname{New References Header} or \renewcommand\bibname{New Bibliography Header}, depending on whether you use an article or a report/book class.

Cf. the FAQ for a more general explanation.

Cross references vs. explicit references

BibTeX adds cross-referenced entries to the bibliography even if they are not explicitly referenced when those entries are cross-referenced by two or more citations. The -min-crossrefs option can be used to disable or customize this behavior.

In LyX 1.4, you can customize the way bibtex is called (in Preferences→Output→LaTeX). Add the -min-crossrefs option there, e.g.

bibtex -min-crossrefs=200.

With LyX < 1.4, the bibtex call was hardcoded. To customize -min-crossrefs, you will have to create a shell script containing the following:

/path/to/bibtex -min-crossrefs=200 "$@"

Name the script 'bibtex' and make sure it appears on the search path before the real bibtex executable.

Examples of BibTeX-files

  • xampl.bib — The .bib-file that came with teTeX 1.07

Multiple and sectioned bibliographies

LyX 1.4 has native support for the bibtopic package, which produces sectionated bibliographies (please note that bibtopic does not support unsorted bibliographies. The simplest way to impliment this involves exporting your LyX files to LaTeX and then changing the files to implement sectionbib/chapterbib). To use bibtopic, go to Layout→Document→Bibliography and select Sectionated bibliography. Then you can just insert several Bibtex Insets (Insert→Lists&TOC→BibTeX Reference). See section 3.1.2 of Help→Extended Features for details.

With LyX < 1.4, you have to use ERT as described in the bibtopic manual. N.B.: You have to call the package in the preamble with the command

  \usepackage[dot]{bibtopic}

Without the dot-option, LyX won't find the auxiliary files, hence the bibliography will be empty.

Multiple bibliographies, e.g. bibliographies for each chapter, can be produced with the packages chapterbib, bibunits, and also with bibtopic.

  • bibtopic works, provided that you are taking care on what is described above (and with some extra ERT).
  • bibunits works with ERT and if you are writing the following to the preamble (this is basically the same as bibtopic's dot-option):
    \makeatletter
    \renewcommand{\@bibunitname}{\jobname.\the\@bibunitauxcnt}
    \makeatother
Also cf. this bibunits example
  • chapterbib: works, but involves some workarounds. First, it is important that you \include (not \input!) all chapters (or sections, for that matter) in a master file. In case of sections, use the option sectionbib (cf. the file chapterbib.sty for details).
    Additionally, you need to install the python wrapper script bibtexall. It is needed because LyX does not process bibtex on all of chapterbib's auxiliary files. Place the script somewhere in the path and make sure it is executable. Then go to Tools→Preferences→Output→LaTeX and change the bibtex command from bibtex to bibtexall (only possible as of LyX 1.4).

Tag me

Creating your own style file with custom-bib

Sometimes it is necessary to change the format of the reference list. Most journals require a certain style; often there are recommendations how to style the reference list when doing a thesis.

The easiest way to accomplish this task is to use natbib plus the latex package custom-bib from the same author. You can get it in via CTAN.

Once installed, the command line "latex makebst" launches an interactive dialogue. Just keep patiently answering the questions, and you end up with a style file that should come close to your needs. Save that style file in a directory where LaTeX can find it (in your TEXMF directory in the folder /bibtex/bst/), run texhash to update the LaTeX file database, and in LyX, hit "Rescan" in Tools→TeX Information. After that your new style file is usable in listed in the BibTeX dialog).

When this is done, use natbib (Format→Document→Bibliography→Use natbib). Insert the reference list where you want it to appear (usually at the end of the document). Then select your .bst file as Style.

Creating hyperlinks within a document

Sometimes you might want to employ, say, the natbib numbered style and have hyperlinks from your citations in the document's body text to the appropriate reference in the bibliography. Here's how.

To create hyperlinks within your document, put

  \usepackage{hyperref}

at the very end of the preamble -- make sure that it is the very last package. Make also sure that you use pdflatex in LyX to view the pdf output.

Simply including this command will make all hyperlinks in your document work, including citations. However, a reader may not notice that the links in your PDF file are clickable. If you wish to color the hyperlinks to increase legibility, use something like

  \usepackage{hyperref}
  \hypersetup{colorlinks=true,citecolor=blue}

where you can use the color specific options of the \hypersetup command, such as

  • colorlinks= true or false
  • linkcolor= red for the color of internal links to sections, pages etc.
  • citecolor= blue for the color of citation links to the bibliography
  • filecolor= green for the color of file links
  • urlcolor= cyan for the color of URL links like web or mail addresses

You can put in any of LaTeX's default colors, i.e. white, black, blue, red, green, yellow, cyan and magenta.

If you still want to do more, combine the commands with other color schemes or packages. For example, add

  \usepackage{xcolor}

to the preamble. With xcolor you can access several kinds of colors, tints, shades, tones and mixes of colors.

  • urlcolor={blue!50} results in URLs being displayed blue but only with 50 percent color intensity
  • citecolor={blue!20!green!10} will result in citations being displayed as a mixture of 20 percent blue and 10 percent green

Categories: Bibliography, Tips

Edit - History - Print - Recent Changes - All Recent Changes - Search
Page last modified on 2008-05-26 23:05 CEST