While the export filter only needs to consist of a single .layout file, which in this case could be called html.layout, you may also want to add two files called html.begin.layout and html.end.layout. The former contains the header part of the output, and the latter the footer part. JabRef will look for these two files whenever the export filter is used, and if found, either of these will be copied verbatim to the output before or after the individual entries are written.
Note that these files must reside in the same directory as html.layout, and must be named by inserting .begin and .end, respectively.
In our example export filter, these could look like the following:
html.begin.layout:
<HTML>
<BODY> text="#275856">
<basefont size="4" color="#2F4958" face="arial">
html.end.layout:
</BODY>
</HTML>
The file html.layout provides the default template for exporting one single entry. If you want to use different templates for different entry types, you can do this by adding entry-specific .layout files. These must also reside in the same directory as the main layout file, and are named by inserting .entrytype into the name of the main layout file. The entry type name must be in all lowercase. In our example, we might want to add a template for book entries, and this would go into the file html.book.layout. For a PhD thesis we would add the file html.phdthesis.layout, and so on. These files are similar to the default layout file, except that they will only be used for entries of the matching type. Note that the default file can easily be made general enough to cover most entry types in most export filters.
An arbitrary word preceded by a backslash, e.g. \author
, \editor
,
\title
or \year
, will be interpreted as a reference to the corresponding field,
which will be copied directly to the output.
Often there will be a need for some preprocessing of the field contents before output. This is done using a field formatter - a java class containing a single method that manipulates the contents of a field.
A formatter is used by inserting the \format
command followed by the formatter name in
square braces, and the field command in curly braces, e.g.:
\format[ToLowerCase]{\author}
You can also specify multiple formatters separated by commas. These will be called sequentially, from left to right, e.g.
\format[ToLowerCase,HTMLChars]{\author}
will cause the formatter ToLowerCase to be called first, and then HTMLChars will be called to format the result. You can list an arbitrary number of formatters in this way.
The argument to the formatters, withing the curly braces, does not have to be a field command. Instead, you can insert normal text, which will then be passed to the formatters instead of the contents of any field. This can be useful for some fomatters, e.g. the CurrentDate formatter (described below).
JabRef provides the following set of formatters, some of which depend on the others:
HTMLChars
: replaces TeX-specific special characters (e.g. {\^a} or {\"{o}})
with their HTML representations.
HTMLParagraphs
: interprets two consecutive newlines (e.g. \n \n) as the beginning of a new paragraph and creates paragraph-html-tags accordingly.
XMLChars
: replaces TeX-specific special characters (e.g. {\^a} or {\"{o}})
with their XML representations.
CreateDocBookAuthors
: formats the author field in DocBook style.
CreateDocBookEditors
: to be documented.
CurrentDate
: outputs the current date. With no argument, this formatter outputs the
current date and time in the format "yyyy.MM.dd hh:mm:ss z" (date, time and time zone). By giving a
different format string as argument, the date format can be customized. E.g.
\format[CurrentDate]{yyyy.MM.dd}
will give the date only, e.g. 2005.11.30.
AuthorFirstFirst
: formats author/editor fields with the first names first.
AuthorFirstFirstCommas
: formats author/editor fields with the first names first, and deliminated by commas.
AuthorFirstAbbrLastCommas
: to be documented.
AuthorFirstAbbrLastOxfordCommas
: to be documented.
AuthorFirstLastOxfordCommas
: to be documented.
AuthorLastFirst
: formats author/editor fields with the last names first.
AuthorLastFirstAbbreviator
: abbreviates first and middle names of all authors. This formatter requires AuthorLastFirst
to have been run earlier.
AuthorLastFirstCommas
: to be documented.
AuthorLastFirstOxfordCommas
: to be documented.
AuthorLastFirstAbbrCommas
: to be documented.
AuthorLastFirstAbbrOxfordCommas
: to be documented.
AuthorAndsReplacer
: replaces "and" between names with ";", and "&" between the last two.
AuthorAndsCommaReplacer
: replaces "and" between names with ",", and "&" between the last two.
AuthorOrgSci
: first author is in "last, first" all others in "first last". First names are abbreviated.
AuthorAbbreviator : to be documented.
NoSpaceBetweenAbbreviations
: spaces between multiple abbreviated first names are removed.
FormatPagesForHTML
: replaces "--" with "-".
FormatPagesForXML
: replaces "--" with an XML en-dash.
RemoveBrackets
: removes all curly brackets "{" or "}".
RemoveBracketsAddComma
: to be documented.
RemoveWhitespace
: to be documented.
RemoveLatexCommands
: removes LaTeX commands like \em
, \textbf
, etc. If
used together with HTMLChars
or XMLChars
, this formatter should be called last.
ToLowerCase
: turns all characters into lower case.
CompositeFormat
: to be documented.
GetOpenOfficeType
: to be documented.
RTFChars
: to be documented.
ResolvePDF
: to be documented.
If none of the available formatters can do what you want to achieve, you can add your own by implementing
the net.sf.jabref.export.layout.LayoutFormatter
interface. If you insert your class
into the net.sf.jabref.export.layout.format
package, you can call the formatter by its
class name only, like with the standard formatters. Otherwise, you must call the formatter by its fully
qualified name (including package name). In any case, the formatter must be in your classpath when running
JabRef.
With JabRef 2.2 it is now possible to define custom name formatters using the bibtex-sty-file syntax. This allows ultimate flexibility, but is a cumbersome to write
You can define your own formatter in the preference tab "Name Formatter" using the following format and then use it with the name given to it as any other name formatter
<case1>@<range11>@<format>@<range12>@<format>@<range13>...@@
<case2>@<range21>@... and so on.
This format first splits the task to format a list of author into cases depending on how many authors there are (this is since some formats differ depending on how many authors there are). Each individual case is separated by @@ and contains instructions on how to format each author in the case. These instructions are separated by a @.
Cases are identified using integers (1,2,3,etc.) or the character * (matches any number of authors) and will tell the formatter to apply the following instructions if there are a number of less or equal of authors given.
Ranges are either <integer>..<integer>
, <integer>
or the character *
using a 1 based index for indexing
authors from the given list of authors. Integer indexes can be negative to denote them to start from
the end of the list where -1 is the last author.
For instance with an authorlist of "Joe Doe and Mary Jane and Bruce Bar and Arthur Kay":
The <format>
-strings use the Bibtex formatter format:
The four letter v, f, l, j indicate the name parts von, first, last, jr which are used within curly braces. A single letter v, f, l, j indicates that the name should be abbreviated. If one of these letters or letter pairs is encountered JabRef will output all the respective names (possibly abbreviated), but the whole expression in curly braces is only printed if the name part exists.
For instance if the format is "{ll} {vv {von Part}} {ff}" and the names are "Mary Kay and John von Neumann", then JabRef will output "Kay Mary" (with two space between last and first) and "Neuman von von Part John".
I give two examples but would rather point you to the bibtex documentation.
Small example: "{ll}, {f.}"
will turn "Joe Doe"
into "Doe, J."
Large example:
To turn:
"Joe Doe and Mary Jane and Bruce Bar and Arthur Kay"
into
"Doe, J., Jane, M., Bar, B. and Kay, A."
you would use
1@*@{ll}, {f}.@@2@1@{ll}, {f}.@2@ and {ll}, {f}.@@*@1..-3@{ll}, {f}., @-2@{ll}, {f}.@-1@ and {ll}, {f}.
If somebody would like to write a better tutorial about this: Write a mail to one of the JabRef mailinglists!
(Ed.)
. This can be done with the following text:
\format[HTMLChars,AuthorFirstFirst]{\editor} (Ed.)
However, if the editor
field has not been set - it might not even make sense for the entry
being exported - the (Ed.)
would be left hanging. This can be prevented by instead using the
\begin
and \end
commands:
\begin{editor}
\format[HTMLChars,AuthorFirstFirst]{\editor} (Ed.)
\end{editor}
The \begin
and \end
commands make sure the text in between is printed if and
only if the field referred in the curly braces is defined for the ently being exported.
Note: Use of the \begin
and \end
commands is a key to creating
layout files that work well with a variety of entry types.
For example, let's assume I wish to group by keyword. Before exporting the file, make sure you have sorted your entries based on keyword. Now use the following commands to group by keyword:
\begingroup{keywords}New Category: \format[HTMLChars]{\keywords}
\endgroup{keywords}