]> git.lyx.org Git - lyx.git/blob - lib/citeengines/biblatex-natbib.citeengine
Merge branch 'master' into biblatex2
[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 63
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 # * Capitalization indicates that the command also has a capitalized
52 #   form (\Latexcmd vs. \latexcmd). These usually enforce upcasing of
53 #   name prefixes (von Goethe => Von Goethe).
54 # * Brackets [] indicate the number of optional arguments (0, 1, 2).
55 # * The star * indicates there is a starred version of the command
56 #   (\latexcmd* vs. \latexcmd). By default, the starred version means:
57 #   Expand the author list even if the maxnames setting would cause
58 #   BibTeX/Biber to shorten it with "et al.".
59 #   If the star has a different meaning for a command, it can be
60 #   specified in angle brackets: <!_stardesc!_stardesctooltip>.
61 #   Maximal two translatable macro keywords, marked by the prefix '!_',
62 #   can be given. The first points to the string that replaces the
63 #   "Full aut&hor list" checkbox label in the Citation dialog, the
64 #   second one an optional tooltip for this checkbox. Note that these
65 #   two macros have to be defined in the CiteFormat section (see below),
66 #   dropping the '!' from the prefix (see below), e.g.:
67 #   _stardesc Starred command label
68 #   _stardesctooltip Tooltip for the starred command checkbox.
69
70 #
71 # CITE COMMAND DEFINITIONS for either engine type
72 #
73 # We support the same cite command as natbib
74 # and add biblatex citation commands on top.
75
76 CiteEngine authoryear
77         Citet|textcite*[][]
78         Citep|parencite*[][]
79         Citealt|cite*[][]
80         Citealp*[][]
81         Citeauthor*[][]
82         citeyearpar[][]
83         citeyear=cite*
84         citebyear[][]=citeyear
85         Footcite[][]=smartcite
86         Autocite[][]
87         citetitle*<!_citetitlestar!_citetitlestartooltip>[][]
88         fullcite[][]
89         footfullcite[][]
90         nocite
91 End
92
93 CiteEngine numerical
94         Citep|citealp,citealt*[][]
95         Citet|textcite*[][]
96         supercite
97         Footcite[][]=smartcite
98         Autocite[][]
99         Citeauthor[][]*
100         citeyearpar[][]
101         citeyear|citebyear[][]
102         citetitle*<!_citetitlestar!_citetitlestartooltip>[][]
103         fullcite[][]
104         footfullcite[][]
105         nocite
106 End
107
108
109 #
110 # CITE FORMAT
111 #
112
113 # The following defines how the commands are represented in the GUI
114 # (inset button and citation dialog) as well as in XHTML, docbook and
115 # plain text output.
116 #
117 # There are common definitions (default) and specific definitions for
118 # either cite engine type (which overwrite existing defaults.
119 #
120 CiteFormat default
121         #
122         # MACROS
123         #
124         # 1. Translatable bits (need to be marked by _ prefix)
125         #    Note that preceding and trailing spaces matter.
126         #
127         _notcited not cited
128         _addtobib Add to bibliography only.
129         _finaland , and 
130         _footnote Footnote
131         _foot Foot
132         _fullcite bibliography entry
133         _bibentry Full bibliography entry.
134         _autocite Autocite
135         _auto Auto
136         # GUI strings for the starred commands
137         _citetitlestar F&orce full title[[Possible substitute to All aut&hors]]
138         _citetitlestartooltip Use full title even if shorttitle exists
139         # The following are handled by BiblioInfo
140         _etal  et al.
141         _namesep , [[separate author names in citation, except for last name]]
142         _lastnamesep , and [[separate name of last author in citation]]
143         _pairnamesep  and [[separate two authors in citation]]
144
145         #
146         # 2. Macros re-used in the style definitions
147         #
148         # NOTE: Year is always in parens, also in numerical style
149         !yearopen (
150         !yearclose )
151
152         # A dummy year modifier. This just indicates that a modifier might be output,
153         # to differentiate \cite* and \citeyear
154         !dummymod [a]
155
156         # A link that lets us jump to the bibliography entry in LyXHTML
157         # %clean:key% will be substituted by the cite key to give a unique id
158         !startlink {!<a href='#LyXCite-%clean:key%'>!}
159         !endlink {!</a>!}
160
161         # Add " , and " before the last item (but " and " if there are only two), else ", "
162         !smartsep {%second%[[{%next%[[%_namesep%]][[%_pairnamesep%]]}]][[{%next%[[%_namesep%]][[%_lastnamesep%]]}]]}
163
164         # "Author et al." or "??"
165         !abbrvciteauthor {%abbrvciteauthor%[[%abbrvciteauthor%]][[??]]}
166         # "Author, ..." or "??"
167         !fullciteauthor {%fullciteauthor%[[%fullciteauthor%]][[??]]}
168         # Handle starred command: abbr. or full author list
169         !makeauthor {%ifstar%[[%!fullciteauthor%]][[%!abbrvciteauthor%]]}
170         # "prenote "
171         !textbefore {%textbefore%[[%textbefore% ]]}
172         # ", postnote"
173         !textafter {%textafter%[[, %textafter%]]}
174         # Add a year if it exists (else "??") and possibly a modifier (as in 2017a)
175         !makeyear {%year%[[%year%]][[??]]}{%modifier%[[%modifier%]]}
176         # Add a year if it exists (else "??") and indicate a possible modifier (as in 2017[a])
177         !myear {%year%[[%year%]][[??]]}{%modifier%[[%modifier%]][[{%export%[[]][[%!dummymod%]]}]]}
178         # Add a year if it exists (else "??") without any modifier at all
179         !byear {%year%[[%year%]][[??]]}
180         # Add a shorttitle or title if it exists (else "??")
181         !makeshorttitle {%shorttitle%[[%shorttitle%]][[{%title%[[%title%]][[??]]}]]}
182         # Add a title (or "??")
183         !maketitle {%ifstar%[[{%title%[[%title%]][[??]]}]][[%!makeshorttitle%]]}
184         # "cf. Key..."
185         !fullcite %bibentry%%!nextfullcite%
186
187         # "...; Author..."
188         !nextauthor {%next%[[%!sep% %!startlink%%!makeauthor%%!endlink%%!nextauthor%]]}
189         # "..., CiteKey..."
190         !nextkey {%next%[[%!sep% %key%%!nextkey%]]}
191         # ".., Year..." (including extra label, as in 2017a)
192         !nextyear {%next%[[%!sep% %!startlink%%!makeyear%%!endlink%%!nextyear%]]}
193         # "...; Nextyear ..." (including emulated extra label, as in 2017[a])
194         !nextmyear {%next%[[%!sep% %!startlink%%!myear%%!endlink%%!nextmyear%]]}
195         # "...; Nextyear ..." (without any extra label)
196         !nextbyear {%next%[[%!sep% %!startlink%%!byear%%!endlink%%!nextbyear%]]}
197         # "...; Nexttitle ..." 
198         !makenexttitle {%next%[[%!sep% %!startlink%%!maketitle%%!endlink%%!makenexttitle%]]}
199         # "...; NextKey..."
200         !nextfullcite {%next%[[%!sep% %bibentry%%!nextfullcite%]]}
201
202         #
203         # ACTUAL STYLE DEFINITIONS
204         #
205         # (identical in authoryear and numerical)
206         #
207
208         # "cf. Author; NextAuthor, p. xx"
209         citeauthor %!textbefore%%!startlink%%!makeauthor%%!endlink%%!nextauthor%%!textafter%
210         # "cf. Year; NextYear, S. xx" [Authoryear] / "cf. Year, NextYear, S. xx" [Numerical]
211         citeyear %!textbefore%%!startlink%%!myear%%!endlink%%!nextmyear%%!textafter%
212         # "cf. Year; Nextyear, p. xx" (without any extra label)
213         citebyear %!textbefore%%!startlink%%!byear%%!endlink%%!nextbyear%%!textafter%
214         # "(cf. Year; NextYear, p. xx)" [Authoryear] / "(cf. Year, NextYear, p. xx)" [Numerical]
215         citeyearpar %!yearopen%%!textbefore%%!startlink%%!makeyear%%!endlink%%!nextyear%%!textafter%%!yearclose%
216         # "cf. Year; Nextyear, p. xx" (without any extra label)
217         citetitle %!textbefore%%!startlink%%!maketitle%%!endlink%%!makenexttitle%%!textafter%
218         # "Bibliography entry." (dialog) / "cf. Key; NextKey..., p. xx (bibliography entry)" (button)
219         fullcite {%dialog%[[%_bibentry%]][[%!textbefore%{%label%[[%!fullcite%]][[%key%%!nextkey% (%_fullcite%)]]}%!textafter%}]]}
220         # "Footnote: Full bibliography entry." (dialog) / "Foot: Key (bibliography entry)"
221         footfullcite {%dialog%[[%_footnote%]][[%_foot%]]}: {%dialog%[[%_bibentry%]][[{%label%[[%!fullcite%]][[%key%%!nextkey% (%_fullcite%)]]}]]}
222         # "Add to bibliography only." (dialog) / "[ID] (not cited)" (button)
223         nocite {%dialog%[[%_addtobib%]][[%key%%!nextkey% (%_notcited%)]]}
224 End
225
226 CiteFormat authoryear
227         #
228         # MACROS
229         #
230         !open (
231         !sep ;
232         !close )
233
234         # "Author et al. (cf. Year..."
235         !makecitet %!startlink%%!makeauthor%%!endlink% %!open%%!textbefore%%!makeyear%%!nextcitet%
236         # "cf. Author et al. Year..."
237         !makecitealt  %!textbefore%%!startlink%%!makeauthor% %!makeyear%%!endlink%%!nextcitealt%
238         # "Author et al., Year..."
239         !makecitealp %!startlink%%!makeauthor%, %!makeyear%%!endlink%%!nextcitealp%
240
241         # "...), [and] Nextauthor (Year..."
242         !nextcitet {%next%[[%!close%%!smartsep%%!startlink%%!makeauthor%%!endlink% %!open%%!makeyear%%!nextcitet%]]}
243         # "...; NextAuthor et al. Year..."
244         !nextcitealt {%next%[[%!sep% %!startlink%%!makeauthor% %!makeyear%%!endlink%%!nextcitealt%]]}
245         # "...; NextAuthor et al., Year..."
246         !nextcitealp {%next%[[%!sep% %!makecitealp%]]}
247
248         #
249         # ACTUAL STYLE DEFINITIONS
250         #
251         # (additions and modifications to default)
252         #
253
254         # "Author (cf. Year),[ and] NextAuthor (Year, p. xx)"
255         citet %!makecitet%%!textafter%%!close%
256         # "(cf. Author et al., Year; NextAuthor et al., Year, p. xx)"
257         citep %!open%%!textbefore%%!makecitealp%%!textafter%%!close%
258         # "cf. Author et al., Year; NextAuthor et al., Year, p. xx"
259         citealp %!textbefore%%!makecitealp%%!textafter%
260         # "cf. Author Year; NextAuthor Year, p. xx" [NB: textbefore position differs from real natbib!]
261         citealt %!makecitealt%%!textafter%
262         # "Footnote: cf. Author A Year; Author B Year, p. xx."
263         footcite {%dialog%[[%_footnote%]][[%_foot%]]}: %!textbefore%%!makecitealp%%!textafter%.
264         # "Auto: (cf. Author A Year; Author B Year, p. xx)"
265         autocite {%dialog%[[%_autocite%]][[%_auto%]]}: %!open%%!textbefore%%!makecitealp%%!textafter%%!close%
266
267         # Fallback style: "Author A (cf. Year),[ and] Author B (Year, p. xx)"
268         cite %!makecitet%%!textafter%%!close%
269 End
270
271 CiteFormat numerical
272         #
273         # MACROS
274         #
275         # 1. Translatable bits (need to be marked by _ prefix)
276         #
277         _super Super
278         _superscript Superscript
279
280         #
281         # 2. Macros re-used in the style definitions
282         #
283         !open [
284         !sep ,
285         !close ]
286
287         # "Author [cf. ID..."
288         !makecitet %!makeauthor% %!open%%!textbefore%{%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!nextcitet%
289         # "ID..."
290         !makecitealt {%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!nextcitealt%
291         # "ID..."
292         !hashkey {%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%%!nexthashkey%]]}
293
294         # "...], [and] NextAuthor [ID..."
295         !nextcitet {%next%[[%!close%%!smartsep%%!makeauthor% %!open%%!textbefore%{%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!nextcitet%]]}
296         # "..., ID..."
297         !nextcitealt {%next%[[%!sep% %!makecitealt%]]}
298         # FIXME: What is this?
299         !nexthashid {%next%[[%!sep% #ID%!nexthashid%]]}
300         # "..., NextID..."
301         !nexthashkey {%next%[[%!sep% %!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%%!nexthashkey%]]}
302         # "...); Nextauthor [ID..."
303         !nextcitet {%next%[[%!close%%!smartsep%%!makeauthor% %!open%{%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!nextcitet%]]}
304
305         #
306         # ACTUAL STYLE DEFINITIONS
307         #
308         # (additions and modifications to default)
309         #
310
311         # "[cf. ID, NextID, p. xx]"
312         citep %!open%%!textbefore%%!hashkey%%!textafter%%!close%
313         # "Author [cf. ID],[ and] Nextauthor [NextID, p. xx]"
314         citet %!makecitet%%!textafter%%!close%
315         # "Footnote: cf. ID, NextID, p. xx."
316         footcite {%dialog%[[%_footnote%]][[%_foot%]]}: %!textbefore%%!makekey%%!textafter%.
317         # "Auto: (cf. Author A Year; Author B Year, p. xx)"
318         autocite {%dialog%[[%_autocite%]][[%_auto%]]}: %!open%%!textbefore%%!makekey%%!textafter%%!close%
319         # "Superscript: ID" (dialog) / "Super: ID" (button) 
320         supercite {%dialog%[[%_superscript%]][[%_super%]]}: %!makekey%
321
322         # Fallback style: "[cf. ID, NextID..., p. xx]"
323         cite %!open%%!textbefore%%!hashkey%%!textafter%%!close%
324 End