Go to page:

Search:   Help

Navigation

Groups

LyX documentation

Edit

Shared groups

Links

Tips

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

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:

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.

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.

Abbreviation of author name in text

Bibtex-Entry Example:

@techreport{FEMA350,

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

}

Defining the alias at the beginning of the LyX file in ERT \defcitealias{FEMA350}{FEMA}

At the location of the citation use in ERT \citetalias{FEMA350}

Followed by a normal LyX citation reference to FEMA350 with Citation Style selected to only give the date

The result is "FEMA 2000" in the text and "Federal Emergency Management Agency (FEMA)..." in the bibliography

see:

  • More Info:
	* http://www.mail-archive.com/lyx-users@lists.lyx.org/msg43232.html
	* http://thread.gmane.org/gmane.editors.lyx.general/50138
  • Feature request
	* http://bugzilla.lyx.org/show_bug.cgi?id=5266

good material thanks

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

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).
  • biblatex: biblatex provides its own methods both for mutliple and subdivided bibliographies. If you use biblatex, you will have to use those, since biblatex is not compatible with bibtopic, chapterbib and friends. See the biblatex manual for details.
    For multiple bibliographies with biblatex, you also need to install the python wrapper script bibtexall in order 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 bibtexall (only possible as of LyX 1.4). If you need bibtex8 or biber instead of bibtex, adapt the script accordingly.

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 2014-10-18 15:15 CEST