1 # \DeclareLyXCiteEngine[biblatex.sty]{Biblatex (natbib mode)}
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.
11 # Author: Jürgen Spitzmüller <spitz@lyx.org>
17 PackageOptions biblatex natbib=true
19 # The framework (biblatex|bibtex)
20 CiteFramework biblatex
22 # Cite style variants (default|authoryear|natbib)
23 # We provide both authoryear and numerical citations
24 CiteEngineType authoryear|numerical
26 # Default style files for either engine type
27 DefaultBiblio authoryear:authoryear|numerical:numeric
29 # Maximum number of names before "et al." chimes in
33 # The syntax of the cite command definitions below is:
34 # LyXName|alias*<!_stardesc!_stardesctooltip>[][]=latexcmd
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
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.
46 # Alias and latexcmd are optional. If no latexcmd is given, the
47 # LyXName will be output to LaTeX.
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)
75 # CITE COMMAND DEFINITIONS for either engine type
77 # We support the same cite command as natbib
78 # and add biblatex citation commands on top.
88 citebyear[][]=citeyear
89 Footcite$[][]=smartcite
91 citetitle*<!_citetitlestar!_citetitlestartooltip>[][]
99 Citep|citealp,citealt*[][]
102 Footcite$[][]=smartcite
106 citeyear|citebyear[][]
107 citetitle*<!_citetitlestar!_citetitlestartooltip>[][]
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
123 # There are common definitions (default) and specific definitions for
124 # either cite engine type (which overwrite existing defaults.
130 # 1. Translatable bits (need to be marked by _ prefix)
131 # Note that preceding and trailing spaces matter.
134 _addtobib Add to bibliography only.
140 _fullcite bibliography entry
141 _bibentry Full bibliography entry.
144 # GUI strings for the starred commands
145 _citetitlestar F&orce full title[[Possible substitute to All aut&hors]]
146 _citetitlestartooltip Use full title even if shorttitle exists
147 # The following are handled by BiblioInfo
149 _namesep , [[separate author names in citation, except for last name]]
150 _lastnamesep , and [[separate name of last author in citation]]
151 _pairnamesep and [[separate two authors in citation]]
154 # 2. Macros re-used in the style definitions
156 # NOTE: Year is always in parens, also in numerical style
160 # A dummy year modifier. This just indicates that a modifier might be output,
161 # to differentiate \cite* and \citeyear
164 # A link that lets us jump to the bibliography entry in LyXHTML
165 # %clean:key% will be substituted by the cite key to give a unique id
166 !startlink {!<a href='#LyXCite-%clean:key%'>!}
169 # Add " , and " before the last item (but " and " if there are only two), else ", "
170 !smartsep {%second%[[{%next%[[%_namesep%]][[%_pairnamesep%]]}]][[{%next%[[%_namesep%]][[%_lastnamesep%]]}]]}
172 # "Author et al." or "??"
173 !abbrvciteauthor {%abbrvciteauthor%[[%abbrvciteauthor%]][[??]]}
174 # "Author, ..." or "??"
175 !fullciteauthor {%fullciteauthor%[[%fullciteauthor%]][[??]]}
176 # Handle starred command: abbr. or full author list
177 !makeauthor {%ifstar%[[%!fullciteauthor%]][[%!abbrvciteauthor%]]}
179 !textbefore {%textbefore%[[%textbefore% ]]}
181 !textafter {%textafter%[[, %textafter%]]}
182 # "prenote " (for qualified lists)
183 !ctextbefore {%curpretext%[[%curpretext% ]]}
184 # ", postnote" (for qualified lists)
185 !ctextafter {%curposttext%[[, %curposttext%]]}
186 # Add a year if it exists (else "??") and possibly a modifier (as in 2017a)
187 !makeyear {%year%[[%year%]][[??]]}{%modifier%[[%modifier%]]}
188 # Add a year if it exists (else "??") and indicate a possible modifier (as in 2017[a])
189 !myear {%year%[[%year%]][[??]]}{%modifier%[[%modifier%]][[{%export%[[]][[%!dummymod%]]}]]}
190 # Add a year if it exists (else "??") without any modifier at all
191 !byear {%year%[[%year%]][[??]]}
192 # Add a shorttitle or title if it exists (else "??")
193 !makeshorttitle {%shorttitle%[[%shorttitle%]][[{%title%[[%title%]][[??]]}]]}
194 # Add a title (or "??")
195 !maketitle {%ifstar%[[{%title%[[%title%]][[??]]}]][[%!makeshorttitle%]]}
197 !fullcite %bibentry%%!nextfullcite%
200 !nextauthor {%next%[[%!sep% %!startlink%%!makeauthor%%!endlink%%!nextauthor%]]}
202 !nextkey {%next%[[%!sep% %key%%!nextkey%]]}
203 # ".., Year..." (including extra label, as in 2017a)
204 !nextyear {%next%[[%!sep% %!startlink%%!makeyear%%!endlink%%!nextyear%]]}
205 # "...; Nextyear ..." (including emulated extra label, as in 2017[a])
206 !nextmyear {%next%[[%!sep% %!startlink%%!myear%%!endlink%%!nextmyear%]]}
207 # "...; Nextyear ..." (without any extra label)
208 !nextbyear {%next%[[%!sep% %!startlink%%!byear%%!endlink%%!nextbyear%]]}
209 # "...; Nexttitle ..."
210 !makenexttitle {%next%[[%!sep% %!startlink%%!maketitle%%!endlink%%!makenexttitle%]]}
212 !nextfullcite {%next%[[%!sep% %bibentry%%!nextfullcite%]]}
215 # ACTUAL STYLE DEFINITIONS
217 # (identical in authoryear and numerical)
220 # "cf. Author; NextAuthor, p. xx"
221 citeauthor %!textbefore%%!startlink%%!makeauthor%%!endlink%%!nextauthor%%!textafter%
222 # "cf. Year; NextYear, S. xx" [Authoryear] / "cf. Year, NextYear, S. xx" [Numerical]
223 citeyear %!textbefore%%!startlink%%!myear%%!endlink%%!nextmyear%%!textafter%
224 # "cf. Year; Nextyear, p. xx" (without any extra label)
225 citebyear %!textbefore%%!startlink%%!byear%%!endlink%%!nextbyear%%!textafter%
226 # "(cf. Year; NextYear, p. xx)" [Authoryear] / "(cf. Year, NextYear, p. xx)" [Numerical]
227 citeyearpar %!yearopen%%!textbefore%%!startlink%%!makeyear%%!endlink%%!nextyear%%!textafter%%!yearclose%
228 # "cf. Year; Nextyear, p. xx" (without any extra label)
229 citetitle %!textbefore%%!startlink%%!maketitle%%!endlink%%!makenexttitle%%!textafter%
230 # "Bibliography entry." (dialog) / "cf. Key; NextKey..., p. xx (bibliography entry)" (button)
231 fullcite {%dialog%[[%_bibentry%]][[%!textbefore%{%label%[[%!fullcite%]][[%key%%!nextkey% (%_fullcite%)]]}%!textafter%}]]}
232 # "Footnote: Full bibliography entry." (dialog) / "Foot: Key (bibliography entry)"
233 footfullcite {%dialog%[[%_footnote%]][[%_foot%]]}: {%dialog%[[%_bibentry%]][[{%label%[[%!fullcite%]][[%key%%!nextkey% (%_fullcite%)]]}]]}
234 # "Add to bibliography only." (dialog) / "[ID] (not cited)" (button)
235 nocite {%dialog%[[%_addtobib%]][[%key%%!nextkey% (%_notcited%)]]}
236 # Output only the key
237 keyonly {%dialog%[[%_keyonly%]][[%_key%: %key%%!nextkey%]]}
240 CiteFormat authoryear
248 # "cf. Author et. al Year..."
249 !makecite %!ctextbefore%%!startlink%%!abbrvciteauthor% %!makeyear%%!endlink%%!ctextafter%%!nextcite%
250 # "Author et al. (cf. Year..."
251 !makecitet %!startlink%%!makeauthor%%!endlink% %!open%%!textbefore%%!makeyear%%!nextcitet%
252 # "cf. Author et al. Year..."
253 !makecitealt %!textbefore%%!startlink%%!makeauthor% %!makeyear%%!endlink%%!nextcitealt%
254 # "Author et al., Year..."
255 !makecitealp %!startlink%%!makeauthor%, %!makeyear%%!endlink%%!nextcitealp%
257 # "...; Nextauthor Year..."
258 !nextcite {%next%[[%!sep% %!makecite%]]}
259 # "...), [and] Nextauthor (Year..."
260 !nextcitet {%next%[[%!close%%!smartsep%%!startlink%%!makeauthor%%!endlink% %!open%%!makeyear%%!nextcitet%]]}
261 # "...; NextAuthor et al. Year..."
262 !nextcitealt {%next%[[%!sep% %!startlink%%!makeauthor% %!makeyear%%!endlink%%!nextcitealt%]]}
263 # "...; NextAuthor et al., Year..."
264 !nextcitealp {%next%[[%!sep% %!makecitealp%]]}
267 # ACTUAL STYLE DEFINITIONS
269 # (additions and modifications to default)
272 # "Author (cf. Year),[ and] NextAuthor (Year, p. xx)"
273 citet %!makecitet%%!textafter%%!close%
274 # "(cf. Author et al., Year; NextAuthor et al., Year, p. xx)"
275 citep %!open%%!textbefore%%!makecitealp%%!textafter%%!close%
276 # "cf. Author et al., Year; NextAuthor et al., Year, p. xx"
277 citealp %!textbefore%%!makecitealp%%!textafter%
278 # "cf. Author Year; NextAuthor Year, p. xx" [NB: textbefore position differs from real natbib!]
279 citealt %!makecitealt%%!textafter%
280 # "Footnote: cf. Author A Year; Author B Year, p. xx."
281 footcite {%dialog%[[%_footnote%]][[%_foot%]]}: %!textbefore%%!makecite%%!textafter%.
282 # "Auto: (cf. Author A Year; Author B Year, p. xx)"
283 autocite {%dialog%[[%_autocite%]][[%_auto%]]}: %!open%%!textbefore%%!makecite%%!textafter%%!close%
285 # Fallback style: "Author A (cf. Year),[ and] Author B (Year, p. xx)"
286 cite %!makecitet%%!textafter%%!close%
293 # 1. Translatable bits (need to be marked by _ prefix)
296 _superscript Superscript
299 # 2. Macros re-used in the style definitions
305 # "Author [cf. ID..."
306 !makecitet %!makeauthor% %!open%%!textbefore%{%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!nextcitet%
308 !makecitealt {%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!nextcitealt%
310 !hashkey {%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%%!nexthashkey%]]}
312 !makekey %!ctextbefore%{%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!ctextafter%%!nextkey%
314 # "...], [and] NextAuthor [ID..."
315 !nextcitet {%next%[[%!close%%!smartsep%%!makeauthor% %!open%%!textbefore%{%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!nextcitet%]]}
317 !nextcitealt {%next%[[%!sep% %!makecitealt%]]}
318 # FIXME: What is this?
319 !nexthashid {%next%[[%!sep% #ID%!nexthashid%]]}
321 !nexthashkey {%next%[[%!sep% %!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%%!nexthashkey%]]}
322 # "...); Nextauthor [ID..."
323 !nextcitet {%next%[[%!close%%!smartsep%%!makeauthor% %!open%{%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!nextcitet%]]}
325 !nextkey {%next%[[%!sep% %!ctextbefore%{%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!ctextafter%%!nextkey%]]}
328 # ACTUAL STYLE DEFINITIONS
330 # (additions and modifications to default)
333 # "[cf. ID, NextID, p. xx]"
334 citep %!open%%!textbefore%%!hashkey%%!textafter%%!close%
335 # "Author [cf. ID],[ and] Nextauthor [NextID, p. xx]"
336 citet %!makecitet%%!textafter%%!close%
337 # "Footnote: cf. ID, NextID, p. xx."
338 footcite {%dialog%[[%_footnote%]][[%_foot%]]}: %!textbefore%%!makekey%%!textafter%.
339 # "Auto: (cf. Author A Year; Author B Year, p. xx)"
340 autocite {%dialog%[[%_autocite%]][[%_auto%]]}: %!open%%!textbefore%%!makekey%%!textafter%%!close%
341 # "Superscript: ID" (dialog) / "Super: ID" (button)
342 supercite {%dialog%[[%_superscript%]][[%_super%]]}: %!makekey%
344 # Fallback style: "[cf. ID, NextID..., p. xx]"
345 cite %!open%%!textbefore%%!hashkey%%!textafter%%!close%