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