Extend and improve name list handling

This allows to generate different name lists depending on the need and
context.

Also addresses #8489.
This commit is contained in:
Juergen Spitzmueller 2017-01-09 17:54:56 +01:00
parent 322808281f
commit a751c5b846
9 changed files with 824 additions and 85 deletions

View File

@ -162,7 +162,11 @@ CiteFormat default
!smartsep {%second%[[{%next%[[%_namesep%]][[%_pairnamesep%]]}]][[{%next%[[%_namesep%]][[%_lastnamesep%]]}]]}
# "Author et al." or "??"
!abbrvauthor {%abbrvauthor%[[%abbrvauthor%]][[??]]}
!abbrvciteauthor {%abbrvciteauthor%[[%abbrvciteauthor%]][[??]]}
# "Author, ..." or "??"
!fullciteauthor {%fullciteauthor%[[%fullciteauthor%]][[??]]}
# Handle starred command: abbr. or full author list
!makeauthor {%ifstar%[[%!fullciteauthor%]][[%!abbrvciteauthor%]]}
# "prenote "
!textbefore {%textbefore%[[%textbefore% ]]}
# ", postnote"
@ -181,7 +185,7 @@ CiteFormat default
!fullcite %bibentry%%!nextfullcite%
# "...; Author..."
!nextauthor {%next%[[%!sep% %!startlink%%!abbrvauthor%%!endlink%%!nextauthor%]]}
!nextauthor {%next%[[%!sep% %!startlink%%!makeauthor%%!endlink%%!nextauthor%]]}
# "..., CiteKey..."
!nextkey {%next%[[%!sep% %key%%!nextkey%]]}
# ".., Year..." (including extra label, as in 2017a)
@ -202,7 +206,7 @@ CiteFormat default
#
# "cf. Author; NextAuthor, p. xx"
citeauthor %!textbefore%%!startlink%%!abbrvauthor%%!endlink%%!nextauthor%%!textafter%
citeauthor %!textbefore%%!startlink%%!makeauthor%%!endlink%%!nextauthor%%!textafter%
# "cf. Year; NextYear, S. xx" [Authoryear] / "cf. Year, NextYear, S. xx" [Numerical]
citeyear %!textbefore%%!startlink%%!myear%%!endlink%%!nextmyear%%!textafter%
# "cf. Year; Nextyear, p. xx" (without any extra label)
@ -228,16 +232,16 @@ CiteFormat authoryear
!close )
# "Author et al. (cf. Year..."
!makecitet %!startlink%%!abbrvauthor%%!endlink% %!open%%!textbefore%%!makeyear%%!nextcitet%
!makecitet %!startlink%%!makeauthor%%!endlink% %!open%%!textbefore%%!makeyear%%!nextcitet%
# "cf. Author et al. Year..."
!makecitealt %!textbefore%%!startlink%%!abbrvauthor% %!makeyear%%!endlink%%!nextcitealt%
!makecitealt %!textbefore%%!startlink%%!makeauthor% %!makeyear%%!endlink%%!nextcitealt%
# "Author et al., Year..."
!makecitealp %!startlink%%!abbrvauthor%, %!makeyear%%!endlink%%!nextcitealp%
!makecitealp %!startlink%%!makeauthor%, %!makeyear%%!endlink%%!nextcitealp%
# "...), [and] Nextauthor (Year..."
!nextcitet {%next%[[%!close%%!smartsep%%!startlink%%!abbrvauthor%%!endlink% %!open%%!makeyear%%!nextcitet%]]}
!nextcitet {%next%[[%!close%%!smartsep%%!startlink%%!makeauthor%%!endlink% %!open%%!makeyear%%!nextcitet%]]}
# "...; NextAuthor et al. Year..."
!nextcitealt {%next%[[%!sep% %!startlink%%!abbrvauthor% %!makeyear%%!endlink%%!nextcitealt%]]}
!nextcitealt {%next%[[%!sep% %!startlink%%!makeauthor% %!makeyear%%!endlink%%!nextcitealt%]]}
# "...; NextAuthor et al., Year..."
!nextcitealp {%next%[[%!sep% %!makecitealp%]]}
@ -281,14 +285,14 @@ CiteFormat numerical
!close ]
# "Author [cf. ID..."
!makecitet %!abbrvauthor% %!open%%!textbefore%{%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!nextcitet%
!makecitet %!makeauthor% %!open%%!textbefore%{%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!nextcitet%
# "ID..."
!makecitealt {%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!nextcitealt%
# "ID..."
!hashkey {%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%%!nexthashkey%]]}
# "...], [and] NextAuthor [ID..."
!nextcitet {%next%[[%!close%%!smartsep%%!abbrvauthor% %!open%%!textbefore%{%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!nextcitet%]]}
!nextcitet {%next%[[%!close%%!smartsep%%!makeauthor% %!open%%!textbefore%{%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!nextcitet%]]}
# "..., ID..."
!nextcitealt {%next%[[%!sep% %!makecitealt%]]}
# FIXME: What is this?
@ -296,7 +300,7 @@ CiteFormat numerical
# "..., NextID..."
!nexthashkey {%next%[[%!sep% %!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%%!nexthashkey%]]}
# "...); Nextauthor [ID..."
!nextcitet {%next%[[%!close%%!smartsep%%!abbrvauthor% %!open%{%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!nextcitet%]]}
!nextcitet {%next%[[%!close%%!smartsep%%!makeauthor% %!open%{%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!nextcitet%]]}
#
# ACTUAL STYLE DEFINITIONS

View File

@ -150,7 +150,7 @@ CiteFormat default
!dummymod [a]
# "...; Nextauthor ..."
!nextauthor {%next%[[%!sep% %!startlink%%!abbrvauthor%%!endlink%%!nextauthor%]]}
!nextauthor {%next%[[%!sep% %!startlink%%!abbrvciteauthor%%!endlink%%!nextauthor%]]}
# Handle starred command: abbr. or full author list
!makenextauthor {%next%[[%!sep% %!startlink%%!makeauthor%%!endlink%%!makenextauthor%]]}
# "...; [NextID] ..."
@ -167,11 +167,11 @@ CiteFormat default
!nextfullcite {%next%[[%!sep% %bibentry%%!nextfullcite%]]}
# "Author et al." (if > 3 authors) or "??"
!abbrvauthor {%abbrvauthor%[[%abbrvauthor%]][[??]]}
!abbrvciteauthor {%abbrvciteauthor%[[%abbrvciteauthor%]][[??]]}
# "Author et al." (always) or "??"
!forceabbrvauthor {%forceabbrvauthor%[[%forceabbrvauthor%]][[??]]}
!forceabbrvciteauthor {%forceabbrvciteauthor%[[%forceabbrvciteauthor%]][[??]]}
# Handle starred command: force of abbr. author list, independent of maxcitenames
!makeauthor {%ifstar%[[%!forceabbrvauthor%]][[%!abbrvauthor%]]}
!makeauthor {%ifstar%[[%!forceabbrvciteauthor%]][[%!abbrvciteauthor%]]}
# "prenote "
!textbefore {%textbefore%[[%textbefore% ]]}
# ", postnote"
@ -220,14 +220,14 @@ CiteFormat authoryear
!close )
# "cf. Author et. al Year..."
!makecite %!startlink%%!abbrvauthor% %!year%%!endlink%%!nextcite%
!makecite %!startlink%%!abbrvciteauthor% %!year%%!endlink%%!nextcite%
# Author et al. (cf. Year...
!maketextcite %!startlink%%!abbrvauthor%%!endlink% %!open%%!textbefore%%!year%%!nexttextcite%
!maketextcite %!startlink%%!abbrvciteauthor%%!endlink% %!open%%!textbefore%%!year%%!nexttextcite%
# "...; Nextauthor Year..."
!nextcite {%next%[[%!sep% %!makecite%]]}
# "...); Nextauthor (Year..."
!nexttextcite {%next%[[%!close%%!smartsep%%!startlink%%!abbrvauthor%%!endlink% %!open%%!year%%!nexttextcite%]]}
!nexttextcite {%next%[[%!close%%!smartsep%%!startlink%%!abbrvciteauthor%%!endlink% %!open%%!year%%!nexttextcite%]]}
# Add a year if it exists (else title, else "??") and possibly a modifier (as in 2017a)
!yeartitle {%year%[[%year%{%modifier%[[%modifier%]][[{%export%[[]][[%!dummymod%]]}]]}]][[{%title%[[%title%]][[??]]}]]}
@ -273,12 +273,12 @@ CiteFormat numerical
!close ]
# "Author [cf. ID..."
!maketextcite %!abbrvauthor% %!open%%!textbefore%{%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!nexttextcite%
!maketextcite %!abbrvciteauthor% %!open%%!textbefore%{%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!nexttextcite%
# "ID"
!makekey {%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%%!nextkey%]]}
# "...); Nextauthor [ID..."
!nexttextcite {%next%[[%!close%%!smartsep%%!abbrvauthor% %!open%{%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!nexttextcite%]]}
!nexttextcite {%next%[[%!close%%!smartsep%%!abbrvciteauthor% %!open%{%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!nexttextcite%]]}
# "..., NextID..."
!nextkey {%next%[[%!sep% %!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%%!nextkey%]]}

View File

@ -137,7 +137,7 @@ CiteFormat authoryear
!endlink {!</a>!}
# "ShortAuthor", "Author" or "??"
!shortauthor {%shortauthor%[[%shortauthor%]][[{%abbrvauthor%[[%abbrvauthor%]][[??]]}]]}
!shortauthor {%shortauthor%[[%shortauthor%]][[{%abbrvciteauthor%[[%abbrvciteauthor%]][[??]]}]]}
# "... ShortTitle"
!shorttitle {%shorttitle%[[ %shorttitle%]][[{%dialog%[[ <%_shorttitle%>]][[%!makejurashorttitle%]]}]]}
# Title or "??"

View File

@ -124,11 +124,11 @@ CiteFormat default
!endlink {!</a>!}
# "Author et al." or "??"
!abbrvauthor {%abbrvauthor%[[%abbrvauthor%]][[??]]}
!abbrvciteauthor {%abbrvciteauthor%[[%abbrvciteauthor%]][[??]]}
# "Author, ..." or "??"
!fullauthor {%fullauthor%[[%fullauthor%]][[??]]}
!fullciteauthor {%fullciteauthor%[[%fullciteauthor%]][[??]]}
# Handle starred command: abbr. or full author list
!makeauthor {%ifstar%[[%!fullauthor%]][[%!abbrvauthor%]]}
!makeauthor {%ifstar%[[%!fullciteauthor%]][[%!abbrvciteauthor%]]}
# "prenote "
!textbefore {%textbefore%[[%textbefore% ]]}
# ", postnote"

View File

@ -22322,7 +22322,7 @@ cite*
\begin_layout Itemize
\change_inserted -712698321 1483868404
\change_inserted -712698321 1483978485
\begin_inset Flex Code
status collapsed
@ -22358,7 +22358,7 @@ status collapsed
, else the false part (e.g., in a citation definition:
\begin_inset Flex Code
status open
status collapsed
\begin_layout Plain Layout
@ -22371,6 +22371,600 @@ status open
\end_inset
)
\end_layout
\begin_layout Itemize
\change_inserted -712698321 1483978548
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1483978499
{%ifmultiple:<authortype>%[[true]][[false]]}
\end_layout
\end_inset
: process the
\begin_inset Quotes eld
\end_inset
true
\begin_inset Quotes erd
\end_inset
if the current author type (author, editor etc.) has multiple authors, else
the false part (e.g., in a bibliography definition:
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1483978571
{%ifmultiple:editor%[[eds.]][[ed.]]}
\end_layout
\end_inset
)
\change_unchanged
\end_layout
\begin_layout Standard
\change_inserted -712698321 1483978958
We said that
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1483978693
%author%
\end_layout
\end_inset
prints the author key as it is recorded in the bibliography file.
This might not be what you want, since it will result in a string such
as
\begin_inset Quotes eld
\end_inset
Miller, Peter and Smith, Mary and White, Jane
\begin_inset Quotes erd
\end_inset
(since
\begin_inset Quotes eld
\end_inset
and
\begin_inset Quotes erd
\end_inset
is used by Bib\SpecialChar TeX
to delimit authors).
\SpecialChar LyX
therefore provides some methods to get properly formatted name lists (which
will also get translated).
The following keys are provided:
\end_layout
\begin_layout Enumerate
\change_inserted -712698321 1483979807
For name lists with pre- and surname, suitable for the main authors/editors
of a bibliography item.
The
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1483979800
<nametype>
\change_unchanged
\end_layout
\end_inset
part denotes the kind of list that is requested (e.g.
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1483979807
<nametype:author>
\change_unchanged
\end_layout
\end_inset
):
\end_layout
\begin_deeper
\begin_layout Itemize
\change_inserted -712698321 1483979186
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1483979743
%abbrvnames:<nametype>%
\change_unchanged
\end_layout
\end_inset
: Provides a name list which is abbreviated (with
\begin_inset Quotes eld
\end_inset
et al.
\begin_inset Quotes erd
\end_inset
) when
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1483979186
MaxCiteNames
\change_unchanged
\end_layout
\end_inset
is reached.
\end_layout
\begin_layout Itemize
\change_inserted -712698321 1483979527
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1483979748
%fullnames:<nametype>%
\change_unchanged
\end_layout
\end_inset
: Provides a full name list (never abbreviated with
\begin_inset Quotes eld
\end_inset
et al.
\begin_inset Quotes erd
\end_inset
).
\end_layout
\begin_layout Itemize
\change_inserted -712698321 1483979553
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1483980138
%forceabbrvnames:<nametype>%
\change_unchanged
\end_layout
\end_inset
: Provides a name list which is always abbreviated (with
\begin_inset Quotes eld
\end_inset
et al.
\begin_inset Quotes erd
\end_inset
) irrespective of
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1483979535
MaxCiteNames
\end_layout
\end_inset
.
\change_unchanged
\end_layout
\end_deeper
\begin_layout Enumerate
\change_inserted -712698321 1483979413
Alternative name lists with pre- and surname, if the order of pre- and surname
inside the bibliography item differs (as in:
\begin_inset Quotes eld
\end_inset
Miller, John: Some text, in: Mary Smith, ed.: A volume
\begin_inset Quotes erd
\end_inset
):
\change_unchanged
\end_layout
\begin_deeper
\begin_layout Itemize
\change_inserted -712698321 1483979565
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1483979751
%abbrvbynames:<nametype>%
\change_unchanged
\end_layout
\end_inset
: Provides a name list which is abbreviated (with
\begin_inset Quotes eld
\end_inset
et al.
\begin_inset Quotes erd
\end_inset
) when
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1483979565
MaxCiteNames
\end_layout
\end_inset
is reached.
\change_unchanged
\end_layout
\begin_layout Itemize
\change_inserted -712698321 1483979570
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1483979753
%fullbynames:<nametype>%
\change_unchanged
\end_layout
\end_inset
: Provides a full name list (never abbreviated with
\begin_inset Quotes eld
\end_inset
et al.
\begin_inset Quotes erd
\end_inset
).
\change_unchanged
\end_layout
\begin_layout Itemize
\change_inserted -712698321 1483979576
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1483980143
%forceabbrvbynames:<nametype>%
\change_unchanged
\end_layout
\end_inset
: Provides a name list which is always abbreviated (with
\begin_inset Quotes eld
\end_inset
et al.
\begin_inset Quotes erd
\end_inset
) irrespective of
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1483979574
MaxCiteNames
\end_layout
\end_inset
.
\end_layout
\end_deeper
\begin_layout Enumerate
\change_inserted -712698321 1483980219
And finally name lists which consist of family names only, as used in author-yea
r citation labels.
these do not take a
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1483979871
<nametype>
\change_unchanged
\end_layout
\end_inset
part, but always return either an author list or, if this does not exist,
an editor list (as common in author-year labels):
\change_unchanged
\end_layout
\begin_deeper
\begin_layout Itemize
\change_inserted -712698321 1483979715
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1483979700
%abbrvciteauthor%
\change_unchanged
\end_layout
\end_inset
: Provides a name list which is abbreviated (with
\begin_inset Quotes eld
\end_inset
et al.
\begin_inset Quotes erd
\end_inset
) when
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1483979715
MaxCiteNames
\end_layout
\end_inset
is reached.
\change_unchanged
\end_layout
\begin_layout Itemize
\change_inserted -712698321 1483979721
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1483979703
%fullciteauthor%
\change_unchanged
\end_layout
\end_inset
: Provides a full name list (never abbreviated with
\begin_inset Quotes eld
\end_inset
et al.
\begin_inset Quotes erd
\end_inset
).
\change_unchanged
\end_layout
\begin_layout Itemize
\change_inserted -712698321 1483980272
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1483979705
%forceabbrvciteauthor%
\change_unchanged
\end_layout
\end_inset
: Provides a name list which is always abbreviated (with
\begin_inset Quotes eld
\end_inset
et al.
\begin_inset Quotes erd
\end_inset
) irrespective of
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1483979726
MaxCiteNames
\end_layout
\end_inset
.
\end_layout
\end_deeper
\begin_layout Standard
\change_inserted -712698321 1483980314
The order of pre- and surname in the former two lists can be adjusted by
these macros:
\end_layout
\begin_layout Itemize
\change_inserted -712698321 1483980535
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1483980354
!firstnameform %surname%, %prename%
\change_unchanged
\end_layout
\end_inset
(first author in lists of type 1)
\end_layout
\begin_layout Itemize
\change_inserted -712698321 1483980557
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1483980367
!othernameform %surname%, %prename%
\change_unchanged
\end_layout
\end_inset
(other authors in lists of type 1)
\change_unchanged
\end_layout
\begin_layout Itemize
\change_inserted -712698321 1483980550
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1483980373
!firstbynameform %prename% %surname%
\change_unchanged
\end_layout
\end_inset
(first author in lists of type 2)
\end_layout
\begin_layout Itemize
\change_inserted -712698321 1483980570
\begin_inset Flex Code
status collapsed
\begin_layout Plain Layout
\change_inserted -712698321 1483980381
!otherbynameform %prename% %surname%
\change_unchanged
\end_layout
\end_inset
(other authors in lists of type 2)
\end_layout
\begin_layout Standard
\change_inserted -712698321 1483980643
This allows you to configure namings like
\begin_inset Quotes eld
\end_inset
Miller, Peter and Mary Smith: \SpecialChar ldots
, in: John Doe and Pat Green, eds.:\SpecialChar ldots
\begin_inset Quotes erd
\end_inset
.
\change_unchanged
\end_layout

View File

@ -1,31 +1,55 @@
# Standard formats for citations.
#
# Author: Richard Heck <rgheck@comcast.net>
# Jürgen Spitzmüller <spitz@lyx.org>
Format 63
CiteFormat default
# translatable bits
#
# Translatable bits
#
_pptext pp.
_edtext ed.
_edstext eds.
_voltext vol.
_numtext no.
_in in
# The following are handled by BiblioInfo. Note that preceding and trailing spaces matter
_namesep , [[separate author names in citation, except for last name]]
_lastnamesep , and [[separate name of last author in citation]]
_pairnamesep and [[separate two authors in citation]]
#
# Macros
#
# Scheme of the first author in the bibliography
!firstnameform %surname%, %prename%
# Scheme of other authors in the bibliography
!othernameform %surname%, %prename%
# Scheme of the first name in later parts (such as book editor)
!firstbynameform %prename% %surname%
# Scheme of other authors in later parts (such as book editor)
!otherbynameform %prename% %surname%
# pagination
!pages {%pages%[[, %_pptext% %pages%]]}
!authoredit {%author%[[%author%, ]][[{%editor%[[%editor%, %_edtext%, ]]}]]}
# ed. or eds.
!makeed {%ifmultiple:editor%[[%_edstext%]][[%_edtext%]]}
# author or editor, as fullnames, following the schemes above
!authoredit {%fullnames:author%[[%fullnames:author%, ]][[{%fullnames:editor%[[%fullnames:editor%, %!makeed%, ]]}]]}
# "vol. 1, no.
!volnum {%volume%[[ %_voltext% %volume%, {%number%[[%_numtext% %number%]]}]]}
!quotetitle "%title%"
!emphtitle {!<i>!}%title%{!</i>!}
!emphjournal {!<i>!}{%journal%[[%journal%]][[{%journaltitle%[[%journaltitle%]]}]]}{!</i>!}
!location {%address%[[%address%: ]][[{%location%[[%location%: ]]}]]}
#
# Entry types. Note that final punctuation will be added later, if needed.
#
!insomething %fullnames:author%, %!quotetitle%, %_in%{%fullbynames:editor%[[ %fullbynames:editor%, %!makeed%,]]} {!<i>!}%booktitle%{!</i>!}%!volnum%{%edition%[[ %edition%]]} (%!location%%publisher%, %year%)%!pages%{%note%[[. %note%]]}
!insomething %author%, %!quotetitle%, %_in%{%editor%[[ %editor%, %_edtext%,]]} {!<i>!}%booktitle%{!</i>!}%!volnum%{%edition%[[ %edition%]]} (%!location%%publisher%, %year%)%!pages%{%note%[[. %note%]]}
article %author%, %!quotetitle%, %!emphjournal% {%volume%[[ %volume%{%number%[[, %number%]]}]]} (%year%)%!pages%{%note%[[. %note%]]}
article %fullnames:author%, %!quotetitle%, %!emphjournal% {%volume%[[ %volume%{%number%[[, %number%]]}]]} (%year%)%!pages%{%note%[[. %note%]]}
!booklike %!authoredit%%!emphtitle%%!volnum%{%edition%[[ %edition%]]} (%!location%%publisher%, %year%){%note%[[. %note%]]}
book %!booklike%
@ -35,7 +59,7 @@ CiteFormat default
incollection %!insomething%
inproceedings %!insomething%
!theses %author%, %title% (%!location%{%school%[[%school%]][[%institution%]]}, %year%){%note%[[. %note%]]}
!theses %fullnames:author%, %title% (%!location%{%school%[[%school%]][[%institution%]]}, %year%){%note%[[. %note%]]}
thesis %!theses%
phdthesis %!theses%
mastersthesis %!theses%

View File

@ -7,6 +7,7 @@
* \author Herbert Voß
* \author Richard Heck
* \author Julien Rioux
* \author Jürgen Spitzmüller
*
* Full author contact details are available in file CREDITS.
*/
@ -45,51 +46,82 @@ namespace lyx {
namespace {
// gets the "family name" from an author-type string
docstring familyName(docstring const & name)
// gets the "prename" and "family name" from an author-type string
pair<docstring, docstring> nameParts(docstring const & name)
{
if (name.empty())
return docstring();
return make_pair(docstring(), docstring());
// first we look for a comma, and take the last name to be everything
// preceding the right-most one, so that we also get the "jr" part.
docstring::size_type idx = name.rfind(',');
if (idx != docstring::npos)
return ltrim(name.substr(0, idx));
vector<docstring> pieces = getVectorFromString(name);
if (pieces.size() > 1)
// whether we have a jr. part or not, it's always
// the first and last item (reversed)
return make_pair(pieces.back(), pieces.front());
// OK, so now we want to look for the last name. We're going to
// include the "von" part. This isn't perfect.
// Split on spaces, to get various tokens.
vector<docstring> pieces = getVectorFromString(name, from_ascii(" "));
pieces = getVectorFromString(name, from_ascii(" "));
// If we only get two, assume the last one is the last name
if (pieces.size() <= 2)
return pieces.back();
return make_pair(pieces.front(), pieces.back());
// Now we look for the first token that begins with a lower case letter.
// Now we look for the first token that begins with
// a lower case letter or an opening group {.
docstring prename;
vector<docstring>::const_iterator it = pieces.begin();
vector<docstring>::const_iterator en = pieces.end();
bool first = true;
for (; it != en; ++it) {
if ((*it).empty())
continue;
char_type const c = (*it)[0];
if (isLower(c))
if (isLower(c) || c == '{')
break;
}
if (it == en) // we never found a "von"
return pieces.back();
// reconstruct what we need to return
docstring retval;
bool first = true;
for (; it != en; ++it) {
if (!first)
retval += " ";
prename += " ";
else
first = false;
retval += *it;
prename += *it;
}
return retval;
if (it == en) // we never found a "von" or group
return make_pair(prename, pieces.back());
// reconstruct the family name
docstring surname;
first = true;
for (; it != en; ++it) {
if (!first)
surname += " ";
else
first = false;
surname += *it;
}
return make_pair(prename, surname);
}
docstring constructName(docstring const & name, string const scheme)
{
// re-constructs a name from name parts according
// to a given scheme
docstring const prename = nameParts(name).first;
docstring const surname = nameParts(name).second;
docstring result = from_ascii(scheme);
result = subst(result, from_ascii("%prename%"), prename);
result = subst(result, from_ascii("%surname%"), surname);
return result;
}
bool multipleAuthors(docstring const author)
{
vector<docstring> const authors =
getVectorFromString(author, from_ascii(" and "));
return authors.size() > 1;
}
@ -256,8 +288,20 @@ BibTeXInfo::BibTeXInfo(docstring const & key, docstring const & type)
{}
docstring const BibTeXInfo::getAuthorList(
Buffer const * buf, bool full, bool forceshort) const
docstring const BibTeXInfo::getAuthorOrEditorList(Buffer const * buf,
bool full, bool forceshort) const
{
docstring author = operator[]("author");
if (author.empty())
author = operator[]("editor");
return getAuthorList(buf, author, full, forceshort);
}
docstring const BibTeXInfo::getAuthorList(Buffer const * buf, docstring author,
bool full, bool forceshort, bool allnames,
bool beginning) const
{
// Maxnames treshold depend on engine
size_t maxnames = buf ?
@ -277,12 +321,8 @@ docstring const BibTeXInfo::getAuthorList(
return authors;
}
docstring author = operator[]("author");
if (author.empty()) {
author = operator[]("editor");
if (author.empty())
return author;
}
// FIXME Move this to a separate routine that can
// be called from elsewhere.
@ -310,6 +350,17 @@ docstring const BibTeXInfo::getAuthorList(
string const pairnamesep =
buf ? buf->params().documentClass().getCiteMacro(engine_type, "_pairnamesep")
: " and ";
string firstnameform =
buf ? buf->params().documentClass().getCiteMacro(engine_type, "!firstnameform")
: "%surname%, %prename%";
if (!beginning)
firstnameform = buf ? buf->params().documentClass().getCiteMacro(engine_type, "!firstbynameform")
: "%prename% %surname%";
string othernameform = buf ? buf->params().documentClass().getCiteMacro(engine_type, "!othernameform")
: "%surname%, %prename%";
if (!beginning)
othernameform = buf ? buf->params().documentClass().getCiteMacro(engine_type, "!otherbynameform")
: "%prename% %surname%";
// Shorten the list (with et al.) if forceshort is set
// and the list can actually be shorten, else if maxcitenames
@ -333,10 +384,18 @@ docstring const BibTeXInfo::getAuthorList(
retval += buf ? buf->B_(lastnamesep) : from_ascii(lastnamesep);
} else if (i > 0)
retval += buf ? buf->B_(namesep) : from_ascii(namesep);
retval += familyName(*it);
if (allnames)
retval += (i == 0) ? constructName(*it, firstnameform)
: constructName(*it, othernameform);
else
retval += nameParts(*it).second;
}
if (shorten) {
if (allnames)
retval = constructName(authors[0], firstnameform) + (buf ? buf->B_(etal) : from_ascii(etal));
else
retval = nameParts(authors[0]).second + (buf ? buf->B_(etal) : from_ascii(etal));
}
if (shorten)
retval = familyName(authors[0]) + (buf ? buf->B_(etal) : from_ascii(etal));
return convertLaTeXCommands(retval);
}
@ -766,21 +825,75 @@ docstring BibTeXInfo::getValueForKey(string const & oldkey, Buffer const & buf,
ret = modifier_;
else if (key == "numericallabel")
ret = cite_number_;
else if (key == "abbrvauthor") {
// Special key to provide abbreviated author names,
else if (prefixIs(key, "ifmultiple:")) {
// Return whether we have multiple authors
docstring const kind = operator[](from_ascii(key.substr(11)));
if (multipleAuthors(kind))
ret = from_ascii("x"); // any non-empty string will do
}
else if (prefixIs(key, "abbrvnames:")) {
// Special key to provide abbreviated name list,
// with respect to maxcitenames. Suitable for Bibliography
// beginnings.
docstring const kind = operator[](from_ascii(key.substr(11)));
ret = getAuthorList(&buf, kind, false, false, true);
if (ci.forceUpperCase && isLowerCase(ret[0]))
ret[0] = uppercase(ret[0]);
} else if (prefixIs(key, "fullnames:")) {
// Return a full name list. Suitable for Bibliography
// beginnings.
docstring const kind = operator[](from_ascii(key.substr(10)));
ret = getAuthorList(&buf, kind, true, false, true);
if (ci.forceUpperCase && isLowerCase(ret[0]))
ret[0] = uppercase(ret[0]);
} else if (prefixIs(key, "forceabbrvnames:")) {
// Special key to provide abbreviated name lists,
// irrespective of maxcitenames. Suitable for Bibliography
// beginnings.
docstring const kind = operator[](from_ascii(key.substr(15)));
ret = getAuthorList(&buf, kind, false, true, true);
if (ci.forceUpperCase && isLowerCase(ret[0]))
ret[0] = uppercase(ret[0]);
} else if (prefixIs(key, "abbrvbynames:")) {
// Special key to provide abbreviated name list,
// with respect to maxcitenames. Suitable for further names inside a
// bibliography item // (such as "ed. by ...")
docstring const kind = operator[](from_ascii(key.substr(11)));
ret = getAuthorList(&buf, kind, false, false, true, false);
if (ci.forceUpperCase && isLowerCase(ret[0]))
ret[0] = uppercase(ret[0]);
} else if (prefixIs(key, "fullbynames:")) {
// Return a full name list. Suitable for further names inside a
// bibliography item // (such as "ed. by ...")
docstring const kind = operator[](from_ascii(key.substr(10)));
ret = getAuthorList(&buf, kind, true, false, true, false);
if (ci.forceUpperCase && isLowerCase(ret[0]))
ret[0] = uppercase(ret[0]);
} else if (prefixIs(key, "forceabbrvbynames:")) {
// Special key to provide abbreviated name lists,
// irrespective of maxcitenames. Suitable for further names inside a
// bibliography item // (such as "ed. by ...")
docstring const kind = operator[](from_ascii(key.substr(15)));
ret = getAuthorList(&buf, kind, false, true, true, false);
if (ci.forceUpperCase && isLowerCase(ret[0]))
ret[0] = uppercase(ret[0]);
} else if (key == "abbrvciteauthor") {
// Special key to provide abbreviated author or
// editor names (suitable for citation labels),
// with respect to maxcitenames.
ret = getAuthorList(&buf, false, false);
ret = getAuthorOrEditorList(&buf, false, false);
if (ci.forceUpperCase && isLowerCase(ret[0]))
ret[0] = uppercase(ret[0]);
} else if (key == "fullauthor") {
// Return a full author list
ret = getAuthorList(&buf, true, false);
} else if (key == "fullciteauthor") {
// Return a full author or editor list (for citation labels)
ret = getAuthorOrEditorList(&buf, true, false);
if (ci.forceUpperCase && isLowerCase(ret[0]))
ret[0] = uppercase(ret[0]);
} else if (key == "forceabbrvauthor") {
// Special key to provide abbreviated author names,
} else if (key == "forceabbrvciteauthor") {
// Special key to provide abbreviated author or
// editor names (suitable for citation labels),
// irrespective of maxcitenames.
ret = getAuthorList(&buf, false, true);
ret = getAuthorOrEditorList(&buf, false, true);
if (ci.forceUpperCase && isLowerCase(ret[0]))
ret[0] = uppercase(ret[0]);
} else if (key == "bibentry") {
@ -903,13 +1016,13 @@ vector<docstring> const BiblioInfo::getEntries() const
}
docstring const BiblioInfo::getAuthorList(docstring const & key, Buffer const & buf) const
docstring const BiblioInfo::getAuthorOrEditorList(docstring const & key, Buffer const & buf) const
{
BiblioInfo::const_iterator it = find(key);
if (it == end())
return docstring();
BibTeXInfo const & data = it->second;
return data.getAuthorList(&buf, false);
return data.getAuthorOrEditorList(&buf, false);
}
@ -1075,8 +1188,8 @@ namespace {
// used in xhtml to sort a list of BibTeXInfo objects
bool lSorter(BibTeXInfo const * lhs, BibTeXInfo const * rhs)
{
docstring const lauth = lhs->getAuthorList();
docstring const rauth = rhs->getAuthorList();
docstring const lauth = lhs->getAuthorOrEditorList();
docstring const rauth = rhs->getAuthorOrEditorList();
docstring const lyear = lhs->getYear();
docstring const ryear = rhs->getYear();
docstring const ltitl = lhs->operator[]("title");
@ -1164,7 +1277,7 @@ void BiblioInfo::makeCitationLabels(Buffer const & buf)
// the first test.
// coverity[FORWARD_NULL]
if (it != cited_entries_.begin()
&& entry.getAuthorList() == last->second.getAuthorList()
&& entry.getAuthorOrEditorList() == last->second.getAuthorOrEditorList()
// we access the year via getYear() so as to get it from the xref,
// if we need to do so
&& getYear(entry.key()) == getYear(last->second.key())) {
@ -1196,7 +1309,7 @@ void BiblioInfo::makeCitationLabels(Buffer const & buf)
if (numbers) {
entry.label(entry.citeNumber());
} else {
docstring const auth = entry.getAuthorList(&buf, false);
docstring const auth = entry.getAuthorOrEditorList(&buf, false);
// we do it this way so as to access the xref, if necessary
// note that this also gives us the modifier
docstring const year = getYear(*it, buf, true);

View File

@ -55,12 +55,16 @@ public:
BibTeXInfo(bool ib) : is_bibtex_(ib), modifier_(0) {}
/// constructor that sets the entryType
BibTeXInfo(docstring const & key, docstring const & type);
/// \return the an authorlist (short form by default),
/// \return an author or editor list (short form by default),
/// used for sorting.
/// This will be translated to the UI language if buf is null
/// otherwise, it will be translated to the buffer language.
docstring const getAuthorList(Buffer const * buf = 0, bool full = false,
docstring const getAuthorOrEditorList(Buffer const * buf = 0, bool full = false,
bool forceshort = false) const;
/// Same for a specific author role (editor, author etc.)
docstring const getAuthorList(Buffer const * buf = 0, docstring author = docstring(),
bool full = false, bool forceshort = false,
bool allnames = false, bool beginning = true) const;
///
docstring const getYear() const;
/// \return formatted BibTeX data suitable for framing.
@ -179,8 +183,8 @@ public:
std::vector<docstring> const getFields() const;
/// \return a sorted vector of BibTeX entry types in use
std::vector<docstring> const getEntries() const;
/// \return authorlist (abbreviated form by default)
docstring const getAuthorList(docstring const & key, Buffer const & buf) const;
/// \return author or editor list (abbreviated form by default)
docstring const getAuthorOrEditorList(docstring const & key, Buffer const & buf) const;
/// \return the year from the bibtex data record for \param key
/// if \param use_modifier is true, then we will also append any
/// modifier for this entry (e.g., 1998b).

View File

@ -1818,7 +1818,7 @@ Layout const & DocumentClass::htmlTOCLayout() const
string const DocumentClass::getCiteFormat(CiteEngineType const & type,
string const & entry, bool const punct, string const & fallback) const
{
string default_format = "{%author%[[%author%, ]][[{%editor%[[%editor%, ed., ]]}]]}\"%title%\"{%journal%[[, {!<i>!}%journal%{!</i>!}]][[{%publisher%[[, %publisher%]][[{%institution%[[, %institution%]]}]]}]]}{%year%[[ (%year%)]]}{%pages%[[, %pages%]]}";
string default_format = "{%fullnames:author%[[%fullnames:author%, ]][[{%fullnames:editor%[[%fullnames:editor%, ed., ]]}]]}\"%title%\"{%journal%[[, {!<i>!}%journal%{!</i>!}]][[{%publisher%[[, %publisher%]][[{%institution%[[, %institution%]]}]]}]]}{%year%[[ (%year%)]]}{%pages%[[, %pages%]]}";
if (punct)
default_format += ".";