Lyx Bibliography Definition

Categories: Bibliography, Tips

<< | Page list | >>


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

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:

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 option there, e.g.


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

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

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 field, which can be used for this task.


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

Multiple and subdivided bibliographies

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


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

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 , and that 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:
      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 not !) 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 to the \usepackage[...]{biblatex} call in the preamble (other available values: , , ).
    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:
  2. Wrap the respective units (chapters, sections etc.) into \begin{bibunit}[<bibstyle>] ... \end{bibunit} in TeX mode, where is your bibliography style without extension.
  3. At the place where the bibliography should occur, enter \putbib[<bibfile>] in TeX mode, where is your bibliography database without 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

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 plus the latex package 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 ), run 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 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 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 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


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

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

Categories: Bibliography, Tips

An Introduction to LyX

LyX is a graphical interface, nearly WYSIWYG, to the LaTeX word processing package. One can use it either to import/export LaTeX files (.tex) files, or else just remain in the LyX domain (.lyx files). In the latter case, the processing is still done by LaTeX, but transparently to the user.

LyX adds convenience to the quality and power of LaTeX. It is particularly useful for documents with significant mathematical content.

Overview of this introduction:

LyX quick start:

If you already have access to a machine with LyX installed, here is how to get started with it quickly.

  • If you have an existing LaTeX file and wish to modify it using LyX, just start LyX, by typing "lyx" on the UNIX command line, and then import your LaTeX file as shown below. (You can later export back to LaTeX if you wish.)
  • If you wish to create a new LyX file, say x.lyx, simply type "lyx x.lyx" on the UNIX command line.

The file is now in your LyX buffer, and you can then add to or modify it in a manner similar to that of any WYSIWYG word processor. It is fairly intuitive, but refer to the above table of contents for any specific type of operation you wish to perform.

How to obtain and install LyX:

If you are using a university computer, LyX may already be installed. Just type "lyx" and see if it runs. If not, or if you want to install LyX on your own machine, read on:

If you use Linux, you may wish to use the autoinstaller in your distribution--yum in Fedora, apt-get in Ubuntu, etc.

Or, you can obtain the package from the LyX home page.

If you get the source code, just go through the usual "configure; make/make install" sequence. You may need to also acquire some libraries.

Note that some of the files may be dispensable, resulting in slow loading (especially for remote execution via a network), e.g. the non-English tutorials in share/lyx/doc.

You will of course also need the LaTeX package itself. Most Linux and Unix systems already have this.

By the way, there is a package which enables you to write in Chinese, Japanese and Korean with LyX, at

Important terms and other information:

I will speak here of the "Environment box," by which I mean the box just below File, Edit, and Layout.

I will also use the term "separate paragraph." This means (at least in the setting I use LyX, which is Skip mode, meaning nonindented paragraphs) text which is both preceded and followed by a blank line.

The LyX documentation uses the notation "M-" for various keystroke commands, with `M' meaning ``meta'' (as in emacs). In typical installations, the meta key is Alt.

Note carefully: Newer versions of LyX may have a slightly different interface than what is described here. I have attempted to keep up with changes, but may not catch them all. You may have to do some experimenting to get at certain commands.

Importing/exporting to/from LaTeX:

Though you can work entirely in LyX and never directly use LaTeX, you may wish to save your work in a LaTeX file, importing into LyX when making a change and then saving back to LaTeX. For example, you may not have LyX installed on all the machines you use, or you may be sharing your work with others who do not have access to LyX, or you may be submitting a research paper to a conference which uses LaTeX. Another reason for exporting to LaTeX is that you may wish to do some fine-tuning to the LaTeX generated by LyX.

(In the latter case, after exporting the file, close the buffer containing the .lyx file, then later re-import it in after modifying the LaTeX file.)

To import a .tex file into LyX, do File->Import->LaTeX. (If, possibly due to your window manager, the File icon is a little "skittish" and opens a file-directory window without your asking for one, hold the mouse button down on the File icon, instead of just briefly clicking the mouse.) Though LyX accommodates most LaTeX constructs, if you have one not covered by LyX, LyX will put it in TeX mode; see "Embedding your own LaTeX commands" below.

To export to LaTex, do File->Export->LaTeX.

Setting document parameters:

Do Layout->Document and set the parameters. For example, to turn off paragraph indentation, choose Skip.

If you wish to add or change some "setlength" or other parameters in the LaTeX preamble, do so vi Layout->Document->LaTeX Premable.

Title/author/date/abstract, table of contents:

Type the title, in a separate paragraph. Then go to the Environment box and choose Title. Do the same for author, date and abstract.

To set up a table of contents, put the cursor right after the title section (after the abstract if any, or else after the date), then hit Enter. Then do Insert->ListsTOC->Table of contents. The table will then appear as a clickable, linking box, and will show up as a real table of contents in the final .dvi file.

Sections, subsections, appendices etc:

To make a section (or subsection, etc.) title, type the title as a separate paragraph, then choose Section from the Environment box.

LyX does not provide direct support for creating appendices. However, you can still create them, as follows.

First, at the point in your document at which the appendix will begin, use the procedure for embedding raw LaTeX code to insert this line of LaTeX code:


Then begin a new section, as shown above. This will be Section A of your appendix, and you create further sections as usual. Note carefully that this will not be displayed properly by LyX, but it will work properly later when you create the .dvi file or print.

Labels and references:

To make a label, move the cursor to the point just before the item to be labeled, and then do Insert->Label. (Assign any unique name to the label; it will not appear in your final output.) Then at each point where you wish to reference that label (e.g. "Section 5," "Page 29," etc.), place the cursor and then do Insert->Cross-Reference. The labels and references will temporarily show up as gray boxes (which are mouse-clickable, which aids in the editing process), and as genuine references in the final document.

Labels and cross references for equations work the same way. However, when inserting a label, make sure you are in the Math Editor box for the expression first (pink box).


E.g. to make an itemized, i.e. bulleted list, choose Itemize from the Environment box; a bullet will appear. Type the item, and hit Enter; each time you type a carriage return, another bullet will appear. If you want to have another paragraph within the same bulleted item, hit ctrl-Enter instead of Enter. To leave Itemize mode, choose Paragraph from the Environment box.

If you want to nest a list within a list, click on Layout and then Change Environment Depth. Or, use the quicker method of clicking on the icon at the top of the LyX screen, which is a picture of a page with arrows on both sides.


Select Insert, then Table. A window will pop up to enable you to set the number of rows and columns. Just use the mouse to drag the indicator to the value you want.

To do the latter, place the mouse pointer in the table at a point where you wish to add/delete a row or column, and then select Layout and Table. Then select Add Row, Delete Row or whatever is appropriate.

To fill in entries in the table, just click the mouse in the entry, and then type the entry. The size of the cell will automatically expand as needed.


Math Mode:

If your document has a lot of math, you'll want to bring up the Math Panel first. Select Insert | Math | Math Panel. You'll see icons for fractions, super/subscripts, matrices, Greek letters and special symbols, and so on.

First enter Math Mode. You can do this by clicking the (a+b/c) icon, or you might find it easier via the keyboard, as M-c m, where M is the Meta key, typically Alt. A box will then appear, inside which you type math. Then you have two choices, each of which is sometimes more convenient than the other:

  • While in the purple box, you can simply type raw LaTeX, e.g. c^2 for c-squared, and LyX will then automatically display it properly.

  • Or you can choose the Math icon and then choose whatever you need, e.g. Fraction. The components of the math item will be drawn as little boxes which you can type in. Use the arrow keys or mouse pointer to move from one of these boxes to another.

I find that it is usually more convenient to take the first approach. For example, to form a fraction, instead of clicking on Math then on Fraction, I get into Math Mode (M-c m), then type "\frac " (including the space), and LyX draws the fraction (two empty boxes and a division bar) for me.

Math Text Mode:

If you wish to type text within a math expression, it will look better if you use Math Text Mode, which you can enter by typing M-m m, where again M is the Meta key. Note that in order to get a blank space, you will need to type ctrl-blank. Also note that if you insert a math symbol, even an equal sign, you will leave Math Text Mode, and must re-enter it if you want to type more text. If you want to leave Math Text Mode, type M-m m again. (However, this apparently will fail if you do it right after typing a blank, an apparent bug. If so, type the blank after) switching out of Math Text Mode.)

Subscripts and superscripts:

A subscript operation is obtained by hitting Index within the Math menu. Superscripts are obtained by hitting Exponent. (For quick subscripts or superscripts, it is easier to just type the raw LaTeX, as mentioned earlier.) After you have filled in a subscript or superscript, use the up- or down-arrow key to return to the base level.

Leaving Math Mode:

Leave Math mode by either moving the cursor or hitting Esc, or simply moving the cursor out of the purple box. Later, if you move the cursor back into a math region, the purple box will reappear, automatically placing you in Math mode.

Greek letters, math symbols, etc.:

Greek letters, summation and integral signs, and so on, are available via Math->Math Panel. Each square within that panel displays a few summary symbols; click on it to see the entire choice of symbols.

To put limits on a summation or integral sign, use Index and Exponent as for subscripts and superscripts above. (Use the arrow keys to make sure the cursor is next to the summation or integral sign first.) If you wish the limits to go "north" and "south" of the integral sign instead of "northeast" and "southeast," use the int, sum, min, max, etc. items in the Functions window within the Math Panel.

Displayed equations:

To display an equation, choose Math then Display. (In newer versions of LyX, click on Insert then Display Formula.) This can be done before typing in the equation, or for an already-existing equation.

To create a multiline displayed equation with the = signs of a lines being aligned with each other, generating the LaTeX \eqnarray command, get into displayed mode first, and hit C-Enter (control-enter). Three boxes will be displayed, one of the left-hand side of your equation, one for the = sign, and one for the right-hand side. You then fill them in. Each time you need a new line, hit C-Enter.


To draw a matrix, first set up the enclosing delimiters (brackets, parentheses, etc.), by choosing the Delimiter icon in the Math Panel (blue square within black brackets). Click on Left, then click on the left delimiter you want, then click on Right and click on the right delimiter you want, then OK. Then in the box within the delimiters you just chose, select the Matrix icon from the Math Panel (blue "3x3 array"), then set your rows and columns, then OK. Now fill in your matrix.

"Cases" construct:

To get the LaTeX \cases construct, with k cases, first set up delimiters (see the entry ``Matrices'' above), with a left brace for the left delimiter and a blank for the right delimiter. Then set up a kx2 matrix; the second column is for the "if" portions of the \cases construct. I recommend (somewhat counter to the LyX manual) that in the Horizontal Align portion of the Matrix popup window you fill in "rl", meaning to right-justify the first column and left-justify the second one. In filling matrix, in the right column you probably will wish to use Math Text Mode.

Overbars, underbars, hats, etc.

Click on Math, then Math Panel, then the square with a tilde over it. Then click on the desired symbol, which will appear along with a box in which you insert the base symbol.

Doing Cut-and-Paste/Copy-and-Paste Operations with Math

An inline math expression can be cut/copied-and-pasted elsewhere. By contrast, in the case of a displayed equation, apparently only the entire equation can be used in this manner. (In the latter case, do not create a math edit box at the destination; simply do the operation into a "blank" destination.)

Bold face, etc.:

Highlight the text you wish to put in bold face, then click on Layout, then Character, then Series (and choose Bold), then Apply, then Close.

Italics can be chosen by clicking on Shape instead of Series.

To revert to standard font, click on Reset instead of Bold or Italics.

Editing and buffer management:

LyX offers the standard (though primitive) editing operations, e.g. cut-and-paste, undo/redo, find/replace and so on.

In addition, LyX offers a really neat feature if you have requested a table of contents for your document. (See "Title/author/date/abstract, table of contents" above.) This allows you to really conveniently move the cursor from one part of your document to another: Simply do Edit->Table of contents, and a box will pop up with your table of contents; you can then click on whatever section or subsection you want to move the cursor to, very handy. In fact, when you get the box, do not click on Close after you are done; simply leave it displayed, ready for you to use repeatedly throughout this LyX editing session.

Use the Documents icon to move from one buffer to another. To delete a buffer, go to the buffer and then do File->Close.

If you wish to do a copy-and-paste operation from another X11 application, first use the mouse the highlight the given text as usual. Then click on Edit and then Paste Primary Selection as Lines/Paragraphs.

Embedding your own LaTeX commands:

To embed sophisticated LaTeX commands which LyX does not handle (for example, the verbatim newpage construct), type the raw LaTeX material, highlight it by dragging the mouse, and then click the TeX icon. The embedded LaTeX material will be shown in red, not WYSIWYG, but will show up correctly in the final .dvi file.

In embedding LaTeX's verbatim command, hit ctrl-Return instead of Return when going from one line to the next, in order to avoid generation of blank lines. Similarly, to get embedded blanks, hit C-Space (control-space bar).

Online help:

Very well done. Click on the Help icon. Use the Documents icon to flip back and forth between your document window and the help window(s).

Note too that the LyX package comes with a man page, in the file, which gives helpful information on search paths, etc.

Further online help is available at

The final product:

LyX will create a .dvi or .ps file (using LaTeX behind the scenes) which you can then print out, or you can simply ask LyX to print for you.

Previewing the final product:

LyX is nearly-but-not-100% WYSIWYG, especially if you have your own embedded LaTeX code in the document. So you may wish to preview the final .dvi file, which you can do by File->View dvi (or View may be displayed in the toolbar at the top of the LyX window).

Note carefully: The first time you run this command, LaTeX or dvips may need to generate some fonts for you, which may take about 5 minutes. Don't worry about the delay, as it is one-time only, since the fonts are kept.

You may get an error message saying something like "Error in LaTeX processing. (Typically this is due to your importing a .tex file into LyX even though the .sty files requested by the .tex file are not present, or due to your inserting your own LaTeX commands via LyX.) To track down the error, you can first click on Edit and Go to Error, and check whether the error is obvious. If it isn't, export the .lyx file to LaTeX, and run LaTeX directly on it, yielding information on the error.

Embedding Postscript figures:

Do Insert->Figure. Various options will be offered. Your figure will indeed show up in the LyX window for your document.

I have found that sometimes LyX will cause problems, by producing LaTeX code like this:

\vspace{0.3cm} \par\centering \includegraphics{Sine5.eps} \par{} \vspace{0.3cm} The ``centering'' command never gets turned off. One way to avoid this is to change it to \vspace{0.3cm} \par\centerline{\includegraphics{Sine5.eps}} \par{} \vspace{0.3cm}

Bibliographies and citations:

To create a bibliography (if you don't have one already via importing your document from a .tex file created earlier), move to the end of your document and then go to the Environment box and choose Bibliography. The screen will show a heading "References" and a box numbered 1, for the first reference. You can then type the reference there. Then click the reference number box (1); a window will then pop up in which you can enter a Key, which will be your own private name for this reference, to be used for the actual citations. Each time you hit the carriage return, you will start a new reference.

Now, wherever you wish to enter a citation in your text portion, simply click the mouse at the point at which you want the citation, then choose Insert and Citation Reference. You will be asked for the key, which you can either type in, or if you have forgotten it, click the arrow and choose from the list of all keys in your entire bibliography. If you want to ask a page or chaapter number for the reference, use the Remark field in the popup window.

The order can also be reversed. You cna put in the citations first, with keys, and then later add the bibliography, as long as you make sure to use the same keys.


It is possible, occasionally, for you to somehow misuse LyX and create a LaTeX error. LyX will tell you so when you try to view the DVI file, print, etc., and it will display a red-letter box labeled "Error" at the beginning of the offending line. Often, though, the nature of the error may be unclear. If so, you could just delete the entire line and retype it (sometimes the error is due to unseen characters), or export to LaTeX, run LaTeX and then see more detail on the nature of the error.

Conversion to HTML:

If you are interested in creating an HTML document from your LyX file, there are many LaTeX-to-HTML converters available, some of which are listed on my LaTeX tutorial Web page. The LyX home page mentions an integration of LyX with one of those packages, tth. but you could just use tth separately, without this integration.

You can embed a URL link in your .lyx file, for eventual use in an HTML version of the file, by doing Insert->URL. Just type in the URL; the name is optional. The LaTeX \url construct will be generated, which in .tex will merely display the URL, but when processed by tth (or other converters), will produce a link whose anchor is the same as the URL itself.

Other software Web sites by Norm Matloff:

0 Replies to “Lyx Bibliography Definition”

Lascia un Commento

L'indirizzo email non verrà pubblicato. I campi obbligatori sono contrassegnati *