]> git.lyx.org Git - lyx.git/blob - lib/citeengines/biblatex-natbib.citeengine
Cut excessively long author lists before parsing them for the GUI
[lyx.git] / lib / citeengines / biblatex-natbib.citeengine
1 # \DeclareLyXCiteEngine[biblatex.sty]{Biblatex (natbib mode)}
2 # DescriptionBegin
3 #   This Biblatex variety emulates the Natbib citation commands and
4 #   thus is best suited for switching from Natbib (or the pre-LyX 2.3
5 #   Biblatex workaround) to Biblatex.
6 #   The natbib mode supports slightly different and a few more styles
7 #   than normal Biblatex. As with normal Biblatex, the use of 'biber'
8 #   as Bibliography processor is advised.
9 # DescriptionEnd
10
11 # Author: Jürgen Spitzmüller <spitz@lyx.org>
12
13 Format 104
14
15 Requires biblatex
16
17 PackageOptions biblatex natbib=true
18
19 # The framework (biblatex|bibtex)
20 CiteFramework biblatex
21
22 # Cite style variants (default|authoryear|natbib)
23 # We provide both authoryear and numerical citations
24 CiteEngineType authoryear|numerical
25
26 # Default style files for either engine type
27 DefaultBiblio  authoryear:authoryear|numerical:numeric
28
29 # Maximum number of names before "et al." chimes in
30 MaxCiteNames 3
31
32
33 # The syntax of the cite command definitions below is:
34 # LyXName|alias*<!_stardesc!_stardesctooltip>[][]=latexcmd
35
36 # * LyXName:  The LyX name as output in the LyX file. For
37 #             portability reasons, we try to use the same
38 #             name for same-formatted commands in the
39 #             different engines (thus many names stem from
40 #             natbib).
41 # * Alias:    A (comma-separated) list of commands that fall
42 #             back to the given LyX name in the current engine.
43 #             This is a bit like "ObsoletedBy" in the layouts.
44 # * latexcmd: The actual LaTeX command that is output.
45 #
46 # Alias and latexcmd are optional. If no latexcmd is given, the
47 # LyXName will be output to LaTeX.
48 #
49 # Note further:
50 #
51 # * The LyXName "keyonly" has a special meaning: only the citation key,
52 #   without any latex command, is output.
53 # * Capitalization indicates that the command also has a capitalized
54 #   form (\Latexcmd vs. \latexcmd). These usually enforce upcasing of
55 #   name prefixes (von Goethe => Von Goethe).
56 # * Brackets [] indicate the number of optional arguments (0, 1, 2).
57 # * The star * indicates there is a starred version of the command
58 #   (\latexcmd* vs. \latexcmd). By default, the starred version means:
59 #   Expand the author list even if the maxnames setting would cause
60 #   BibTeX/Biber to shorten it with "et al.".
61 #   If the star has a different meaning for a command, it can be
62 #   specified in angle brackets: <!_stardesc!_stardesctooltip>.
63 #   Maximal two translatable macro keywords, marked by the prefix '!_',
64 #   can be given. The first points to the string that replaces the
65 #   "Full aut&hor list" checkbox label in the Citation dialog, the
66 #   second one an optional tooltip for this checkbox. Note that these
67 #   two macros have to be defined in the CiteFormat section (see below),
68 #   dropping the '!' from the prefix (see below), e.g.:
69 #   _stardesc Starred command label
70 #   _stardesctooltip Tooltip for the starred command checkbox.
71 # * A trailing $ indicates that a command features "qualified citation
72 #   lists" (a specific Biblatex feature)
73
74 #
75 # CITE COMMAND DEFINITIONS for either engine type
76 #
77 # We support the same cite command as natbib
78 # and add biblatex citation commands on top.
79
80 CiteEngine authoryear
81         Citet|textcite*[][]
82         Citep|parencite*[][]
83         Citealt|cite*[][]
84         Citealp*[][]
85         Citeauthor*[][]
86         citeyearpar[][]
87         citeyear[][]=cite*
88         citebyear[][]=citeyear
89         Footcite$[][]=smartcite
90         Autocite$[][]
91         citetitle*<!_citetitlestar!_citetitlestartooltip>[][]
92         fullcite[][]
93         footfullcite[][]
94         nocite
95         keyonly
96 End
97
98 CiteEngine numerical
99         Citep|citealp,citealt*[][]
100         Citet|textcite*[][]
101         supercite
102         Footcite$[][]=smartcite
103         Autocite$[][]
104         Citeauthor[][]*
105         citeyearpar[][]
106         citeyear|citebyear[][]
107         citetitle*<!_citetitlestar!_citetitlestartooltip>[][]
108         fullcite[][]
109         footfullcite[][]
110         nocite
111         keyonly
112 End
113
114
115 #
116 # CITE FORMAT
117 #
118
119 # The following defines how the commands are represented in the GUI
120 # (inset button and citation dialog) as well as in XHTML, docbook and
121 # plain text output.
122 #
123 # There are common definitions (default) and specific definitions for
124 # either cite engine type (which overwrite existing defaults.
125 #
126
127 # Input standard format definitions for the bibliography
128 Input stdciteformats.inc
129
130 CiteFormat default
131         #
132         # MACROS
133         #
134         # 1. Translatable bits (need to be marked by _ prefix, if translated to the GUI language,
135         #    or B_, if translated to the buffer language)
136         #    Note that preceding and trailing spaces matter.
137         #
138         _notcited not cited
139         _addtobib Add to bibliography only.
140         _keyonly Key only.
141         _key Key
142         B_finaland , and 
143         _footnote Footnote
144         _foot Foot
145         _fullcite bibliography entry
146         _bibentry Full bibliography entry.
147         _autocite Autocite
148         _auto Auto
149         # GUI strings for the starred commands
150         _citetitlestar F&orce full title[[Possible substitute to All aut&hors]]
151         _citetitlestartooltip Use full title even if shorttitle exists
152         # The following are handled by BiblioInfo
153         B_etal  et al.
154         B_namesep , [[separate author names in citation, except for last name]]
155         B_lastnamesep , and [[separate name of last author in citation]]
156         B_pairnamesep  and [[separate two authors in citation]]
157
158         #
159         # 2. Macros re-used in the style definitions
160         #
161         # NOTE: Year is always in parens, also in numerical style
162         !yearopen (
163         !yearclose )
164
165         # A dummy year modifier. This just indicates that a modifier might be output,
166         # to differentiate \cite* and \citeyear
167         !dummymod [a]
168
169         # A link that lets us jump to the bibliography entry in LyXHTML
170         # %clean:key% will be substituted by the cite key to give a unique id
171         !startlink {!<a href='#LyXCite-%clean:key%'>!}
172         !endlink {!</a>!}
173
174         # Add " , and " before the last item (but " and " if there are only two), else ", "
175         !smartsep {%second%[[{%next%[[%B_namesep%]][[%B_pairnamesep%]]}]][[{%next%[[%B_namesep%]][[%B_lastnamesep%]]}]]}
176
177         # "Author et al." or "??"
178         !abbrvciteauthor {%abbrvciteauthor%[[%abbrvciteauthor%]][[??]]}
179         # "Author, ..." or "??"
180         !fullciteauthor {%fullciteauthor%[[%fullciteauthor%]][[??]]}
181         # Handle starred command: abbr. or full author list
182         !makeauthor {%ifstar%[[%!fullciteauthor%]][[%!abbrvciteauthor%]]}
183         # "prenote "
184         !textbefore {%textbefore%[[%textbefore% ]]}
185         # ", postnote"
186         !textafter {%textafter%[[, %textafter%]]}
187         # "prenote " (for qualified lists)
188         !ctextbefore {%curpretext%[[%curpretext% ]]}
189         # ", postnote" (for qualified lists)
190         !ctextafter {%curposttext%[[, %curposttext%]]}
191         # Add a year if it exists (else "??") and possibly a modifier (as in 2017a)
192         !makeyear {%year%[[%year%]][[??]]}{%modifier%[[%modifier%]]}
193         # Add a year if it exists (else "??") and indicate a possible modifier (as in 2017[a])
194         !myear {%year%[[%year%]][[??]]}{%modifier%[[%modifier%]][[{%export%[[]][[%!dummymod%]]}]]}
195         # Add a shorthand if it exists else myear (see above)
196         !shmyear {%shorthand%[[%shorthand%]][[%!myear%]]}
197         # Add a year if it exists (else "??") without any modifier at all
198         !byear {%year%[[%year%]][[??]]}
199         # Add a shorttitle or title if it exists (else "??")
200         !makeshorttitle {%shorttitle%[[%shorttitle%]][[{%title%[[%title%]][[??]]}]]}
201         # Add a title (or "??")
202         !maketitle {%ifstar%[[{%title%[[%title%]][[??]]}]][[%!makeshorttitle%]]}
203         # "cf. Key..."
204         !fullcite %bibentry%%!nextfullcite%
205
206         # "...; Author..."
207         !nextauthor {%next%[[%!sep% %!startlink%%!makeauthor%%!endlink%%!nextauthor%]]}
208         # "..., CiteKey..."
209         !nextkey {%next%[[%!sep% %key%%!nextkey%]]}
210         # ".., Year..." (including extra label, as in 2017a)
211         !nextyear {%next%[[%!sep% %!startlink%%!makeyear%%!endlink%%!nextyear%]]}
212         # "...; Nextyear ..." (including emulated extra label, as in 2017[a])
213         !nextshmyear {%next%[[%!sep% %!startlink%%!shmyear%%!endlink%%!nextshmyear%]]}
214         # "...; Nextyear ..." (without any extra label)
215         !nextbyear {%next%[[%!sep% %!startlink%%!byear%%!endlink%%!nextbyear%]]}
216         # "...; Nexttitle ..." 
217         !makenexttitle {%next%[[%!sep% %!startlink%%!maketitle%%!endlink%%!makenexttitle%]]}
218         # "...; NextKey..."
219         !nextfullcite {%next%[[%!sep% %bibentry%%!nextfullcite%]]}
220
221         #
222         # ACTUAL STYLE DEFINITIONS
223         #
224         # (identical in authoryear and numerical)
225         #
226
227         # "cf. Author; NextAuthor, p. xx"
228         citeauthor %!textbefore%%!startlink%%!makeauthor%%!endlink%%!nextauthor%%!textafter%
229         # "cf. Year; NextYear, S. xx" [Authoryear] / "cf. Year, NextYear, S. xx" [Numerical]
230         citeyear %!textbefore%%!startlink%%!shmyear%%!endlink%%!nextshmyear%%!textafter%
231         # "cf. Year; Nextyear, p. xx" (without any extra label)
232         citebyear %!textbefore%%!startlink%%!byear%%!endlink%%!nextbyear%%!textafter%
233         # "(cf. Year; NextYear, p. xx)" [Authoryear] / "(cf. Year, NextYear, p. xx)" [Numerical]
234         citeyearpar %!yearopen%%!textbefore%%!startlink%%!makeyear%%!endlink%%!nextyear%%!textafter%%!yearclose%
235         # "cf. Year; Nextyear, p. xx" (without any extra label)
236         citetitle %!textbefore%%!startlink%%!maketitle%%!endlink%%!makenexttitle%%!textafter%
237         # "Bibliography entry." (dialog) / "cf. Key; NextKey..., p. xx (bibliography entry)" (button)
238         fullcite {%dialog%[[%_bibentry%]][[%!textbefore%{%label%[[%!fullcite%]][[%key%%!nextkey% (%_fullcite%)]]}%!textafter%}]]}
239         # "Footnote: Full bibliography entry." (dialog) / "Foot: Key (bibliography entry)"
240         footfullcite {%dialog%[[%_footnote%]][[%_foot%]]}: {%dialog%[[%_bibentry%]][[{%label%[[%!fullcite%]][[%key%%!nextkey% (%_fullcite%)]]}]]}
241         # "Add to bibliography only." (dialog) / "[ID] (not cited)" (button)
242         nocite {%dialog%[[%_addtobib%]][[%key%%!nextkey% (%_notcited%)]]}
243         # Output only the key
244         keyonly {%dialog%[[%_keyonly%]][[%_key%: %key%%!nextkey%]]}
245 End
246
247 CiteFormat authoryear
248         #
249         # MACROS
250         #
251         !open (
252         !sep ;
253         !close )
254
255         # "cf. Author et. al Year..."
256         !makecite %!ctextbefore%%!startlink%%!abbrvciteauthor% %!makeyear%%!endlink%%!ctextafter%%!nextcite%
257         # "Author et al. (cf. Year..."
258         !makecitet %!startlink%%!makeauthor%%!endlink% %!open%%!textbefore%%!makeyear%%!nextcitet%
259         # "cf. Author et al. Year..."
260         !makecitealt %!textbefore%%!startlink%%!makeauthor% %!makeyear%%!endlink%%!nextcitealt%
261         # "Author et al., Year..."
262         !makecitealp %!startlink%%!makeauthor%, %!makeyear%%!endlink%%!nextcitealp%
263
264         # "...; Nextauthor Year..."
265         !nextcite {%next%[[%!sep% %!makecite%]]}
266         # "...), [and] Nextauthor (Year..."
267         !nextcitet {%next%[[%!close%%!smartsep%%!startlink%%!makeauthor%%!endlink% %!open%%!makeyear%%!nextcitet%]]}
268         # "...; NextAuthor et al. Year..."
269         !nextcitealt {%next%[[%!sep% %!startlink%%!makeauthor% %!makeyear%%!endlink%%!nextcitealt%]]}
270         # "...; NextAuthor et al., Year..."
271         !nextcitealp {%next%[[%!sep% %!makecitealp%]]}
272
273         #
274         # ACTUAL STYLE DEFINITIONS
275         #
276         # (additions and modifications to default)
277         #
278
279         # "Author (cf. Year),[ and] NextAuthor (Year, p. xx)"
280         citet %!makecitet%%!textafter%%!close%
281         # "(cf. Author et al., Year; NextAuthor et al., Year, p. xx)"
282         citep %!open%%!textbefore%%!makecitealp%%!textafter%%!close%
283         # "cf. Author et al., Year; NextAuthor et al., Year, p. xx"
284         citealp %!textbefore%%!makecitealp%%!textafter%
285         # "cf. Author Year; NextAuthor Year, p. xx" [NB: textbefore position differs from real natbib!]
286         citealt %!makecitealt%%!textafter%
287         # "Footnote: cf. Author A Year; Author B Year, p. xx."
288         footcite {%dialog%[[%_footnote%]][[%_foot%]]}: %!textbefore%%!makecite%%!textafter%.
289         # "Auto: (cf. Author A Year; Author B Year, p. xx)"
290         autocite {%dialog%[[%_autocite%]][[%_auto%]]}: %!open%%!textbefore%%!makecite%%!textafter%%!close%
291
292         # Fallback style: "Author A (cf. Year),[ and] Author B (Year, p. xx)"
293         cite %!makecitet%%!textafter%%!close%
294 End
295
296 CiteFormat numerical
297         #
298         # MACROS
299         #
300         # 1. Translatable bits (need to be marked by _ prefix, if translated to the GUI language,
301         #    or B_, if translated to the buffer language)
302         #
303         _super Super
304         _superscript Superscript
305
306         #
307         # 2. Macros re-used in the style definitions
308         #
309         !open [
310         !sep ,
311         !close ]
312
313         # "Author [cf. ID..."
314         !makecitet %!makeauthor% %!open%%!textbefore%{%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!nextcitet%
315         # "ID..."
316         !makecitealt {%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!nextcitealt%
317         # "ID..."
318         !hashkey {%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%%!nexthashkey%]]}
319         # "ID"
320         !makekey %!ctextbefore%{%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!ctextafter%%!nextkey%
321
322         # "...], [and] NextAuthor [ID..."
323         !nextcitet {%next%[[%!close%%!smartsep%%!makeauthor% %!open%%!textbefore%{%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!nextcitet%]]}
324         # "..., ID..."
325         !nextcitealt {%next%[[%!sep% %!makecitealt%]]}
326         # FIXME: What is this?
327         !nexthashid {%next%[[%!sep% #ID%!nexthashid%]]}
328         # "..., NextID..."
329         !nexthashkey {%next%[[%!sep% %!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%%!nexthashkey%]]}
330         # "...); Nextauthor [ID..."
331         !nextcitet {%next%[[%!close%%!smartsep%%!makeauthor% %!open%{%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!nextcitet%]]}
332         # "..., NextID..."
333         !nextkey {%next%[[%!sep% %!ctextbefore%{%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!ctextafter%%!nextkey%]]}
334
335         #
336         # ACTUAL STYLE DEFINITIONS
337         #
338         # (additions and modifications to default)
339         #
340
341         # "[cf. ID, NextID, p. xx]"
342         citep %!open%%!textbefore%%!hashkey%%!textafter%%!close%
343         # "Author [cf. ID],[ and] Nextauthor [NextID, p. xx]"
344         citet %!makecitet%%!textafter%%!close%
345         # "Footnote: cf. ID, NextID, p. xx."
346         footcite {%dialog%[[%_footnote%]][[%_foot%]]}: %!textbefore%%!makekey%%!textafter%.
347         # "Auto: (cf. Author A Year; Author B Year, p. xx)"
348         autocite {%dialog%[[%_autocite%]][[%_auto%]]}: %!open%%!textbefore%%!makekey%%!textafter%%!close%
349         # "Superscript: ID" (dialog) / "Super: ID" (button) 
350         supercite {%dialog%[[%_superscript%]][[%_super%]]}: %!makekey%
351
352         # Fallback style: "[cf. ID, NextID..., p. xx]"
353         cite %!open%%!textbefore%%!hashkey%%!textafter%%!close%
354 End