Search:   Help

Navigation

Groups

LyX documentation

Edit

Shared groups

Links

Tips

Categories: Bibliography, Tips
<< | Page list | >>

1.  Encoding

BibTeX does not support files encoded in UTF-8 (i.e., Unicode), which is nowadays the default file encoding on most OSes. The reason is that current BibTeX (v. 0.99c) was released in 1988 and thus predates the advent of unicode. Unless the long-announced BibTeX v. 1.0 or one of the many planned potential successing applications are ready, latin1 (ISO-8859-1) or another 8-bit encoding has to be used for the bib file (this does not affect the LaTeX encoding, which still can be utf8).

If you rely on UTF-8, you might try biblatex-biber, a BibTeX replacement program written in Perl. Biber can handle unicode, however, as the name indicates, it only works in conjunction with biblatex. Please look here for some instructions.

Decent bib file editors take care about the correct encoding, which usually can be set in the Preferences or Options dialog of the bib file editor. However, you might have to take care yourself about special characters. Particularly, characters not included in the bib file encoding need to be inserted via LaTeX macros. (Some editors automatically do this conversion for you, e.g. Pybliographic and BibDesk. In the latter application, you need to check "Convert accented characters to TeX when exporting or pasting BibTeX" in the "Opening and Saving" preferences.)

Existing utf8-encoded bib files can be converted by means of the command line tool recode. The following command (with an adapted bib file name) should do the trick (however, please backup your bib file before trying):

recode -d u8..ltex myfile.bib

This re-encodes the file to 7-bit ASCII.
If you want another target encoding, change the syntax. For ISO-8859-15 (= latin9), the command would read:

recode -d u8..l9 myfile.bib

Please check the recode man page for more options.

Some background information:

2.  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.

3.  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.

As of 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.

4.  Abbreviation of author name in text

If you want to abbreviate an author (or most likely institutional) name in the citation while having it in full form in the bibliography, the procedure depends on the citation approach.

Biblatex and jurabib have the shortauthor field, which can be used for this task.

Example:

@techreport{FEMA350,
        author = {{Federal Emergency Management Agency (FEMA)}},
        shortauthor = {FEMA},
        title = {Recommended seismic design criteria for new steel moment-frame buildings},
        year = 2000,
        number = {FEMA-350},
        address = {Washington, D.C.}
}

With natbib, things are more complicated. You need to define a cite alias.

  1. At the beginning of the LyX file enter as TeX code: \defcitealias{<citekey>}{<alias>}
    (e.g., for the above example: \defcitealias{FEMA350}{FEMA}
  2. At the location of the citation enter in TeX code \citealias{<key>}
    (e.g., \citealias{FEMA350} followed by a normal LyX citation reference to this item using the style that only outputs the year.

5.  Multiple and subdivided bibliographies

5.1  Subdivided bibliographies

As of LyX 1.4, subdivided bibliographies are natively supported via the bibtopic package:

  1. Go to Layout→Document→Bibliography and select Sectioned bibliography (or Subdivided bibliography, as of LyX 2.3).
  2. Now you can just insert several Bibtex Insets (Insert→Lists&TOC→BibTeX Reference).

Note, though, that bibtopic does not support unsorted bibliographies.
See section 3.1.2 of Help→Additional Features for details.

With LyX < 1.4, you have to use TeX code 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.

Biblatex provides its own means to produce subdivided bibliographies (via keywords, filter tags, and categories). These are described on the biblatex manual, section Subdivided bibliographies

5.2  Multiple bibliographies

Multiple bibliographies will be supported as of LyX 2.3 (using, depending on the setting, either the bibtopic or chapterbib package, or biblatex):

  1. Go to Layout→Document→Bibliography and select the relevant unit from Multiple bibliographies.
  2. Now you can just insert several Bib(la)tex Insets (Insert→Lists&TOC→Bib(la)TeX Reference).

See section 3.1.2 of Help→Additional Features for details.

Up to LyX 2.2, you can produce multiple bibliographies with bibtopic, chapterbib or biblatex as follows:

  • bibtopic:
    1. Go to Layout→Document→Bibliography and select Sectioned bibliography
    2. Wrap the respective units (chapters, sections etc.) into \begin{btUnit} ... \end{btUnit} in TeX mode.
    Note that all references need to be in a btUnit, and that btUnits must not be nested. Note further that bibtopic does not support unsorted bibliographies (as mentioned above).
  • chapterbib:
    1. Add the following to Document→Settings...→Preamble:
      \usepackage{chapterbib}
      In case of sections, use \usepackage[sectionbib]{chapterbib} instead.
    2. All chapters or sections need to go to separate child documents, which are included (with \include not \input!) to a master document.
    3. You are not supposed to have a bibliography in the master file. BibTeX would yield an error in that case.
    4. Install the python wrapper script bibtexallx. 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 bibtexallx (only possible as of LyX 1.4).
  • biblatex: biblatex provides its own methods both for multiple and subdivided bibliographies. If you use biblatex, you will have to use those, since biblatex is not compatible with the aforementioned packages.
    1. See this page for general instructions to use biblatex with LyX < 2.3.
    2. To get a bibliography per chapter, add the package option refsection=chapter to the \usepackage[...]{biblatex} call in the preamble (other available values: part, section, subsection).
    3. If you do not use biber, but bibtex or bibtex8, you need to install the python wrapper script bibtexallx to let LyX process bibtex on all of biblatex'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 bibtexallx (only possible as of LyX 1.4). If you need bibtex8 instead of bibtex, adapt the script accordingly. However, it is generally advised that you use biber with biblatex.
    See the biblatex manual for details.

If the aforementioned approaches do not fit your needs, you can produce multiple bibliographies with some extra code, using the package bibunits:

  1. Add the following to Document→Settings..→Preamble:
    \usepackage{bibunits}
    \renewcommand{\@bibunitname}{\jobname.\the\@bibunitauxcnt}
  2. Wrap the respective units (chapters, sections etc.) into \begin{bibunit}[<bibstyle>] ... \end{bibunit} in TeX mode, where <bibstyle> is your bibliography style without *.bst extension.
  3. At the place where the bibliography should occur, enter \putbib[<bibfile>] in TeX mode, where <bibfile> is your bibliography database without *.bib extension.
  4. In order to access the citations from the citation dialog, put a BibTeX inset in a note inset.
Also cf. this bibunits example

6.  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.

7.  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, go to Document→Settings...→PDF options and check Enable Hyperref Support.

Make sure that you use pdflatex in LyX to view the pdf output.

Simply checking this option 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, add something like colorlinks=true,citecolor=blue in the Additional Options field of that dialog pane.

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 2017-02-05 07:47 UTC