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.
10 # Excludes: basic | jurabib | biblatex | natbib
12 # Author: Jürgen Spitzmüller <spitz@lyx.org>
18 PackageOptions biblatex natbib=true
20 # The framework (biblatex|bibtex)
21 CiteFramework biblatex
23 # Cite style variants (default|authoryear|natbib)
24 # We provide both authoryear and numerical citations
25 CiteEngineType authoryear|numerical
27 # Default style files for either engine type
28 DefaultBiblio authoryear:authoryear|numerical:numeric
30 # Maximum number of names before "et al." chimes in
34 # The syntax of the cite command definitions below is:
35 # LyXName|alias*<!_stardesc!_stardesctooltip>[][]=latexcmd
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
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.
47 # Alias and latexcmd are optional. If no latexcmd is given, the
48 # LyXName will be output to LaTeX.
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.
72 # CITE COMMAND DEFINITIONS for either engine type
74 # We support the same cite command as natbib
75 # and add biblatex citation commands on top.
85 citebyear[][]=citeyear
86 Footcite[][]=smartcite
88 citetitle*<!_citetitlestar!_citetitlestartooltip>[][]
95 Citep|citealp,citealt*[][]
98 Footcite[][]=smartcite
102 citeyear|citebyear[][]
103 citetitle*<!_citetitlestar!_citetitlestartooltip>[][]
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
118 # There are common definitions (default) and specific definitions for
119 # either cite engine type (which overwrite existing defaults.
125 # 1. Translatable bits (need to be marked by _ prefix)
126 # Note that preceding and trailing spaces matter.
129 _addtobib Add to bibliography only.
133 _fullcite bibliography entry
134 _bibentry Full bibliography entry.
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
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]]
147 # 2. Macros re-used in the style definitions
149 # NOTE: Year is always in parens, also in numerical style
153 # A dummy year modifier. This just indicates that a modifier might be output,
154 # to differentiate \cite* and \citeyear
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%'>!}
162 # Add " , and " before the last item (but " and " if there are only two), else ", "
163 !smartsep {%second%[[{%next%[[%_namesep%]][[%_pairnamesep%]]}]][[{%next%[[%_namesep%]][[%_lastnamesep%]]}]]}
165 # "Author et al." or "??"
166 !abbrvauthor {%abbrvauthor%[[%abbrvauthor%]][[??]]}
168 !textbefore {%textbefore%[[%textbefore% ]]}
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%]]}
182 !fullcite %bibentry%%!nextfullcite%
185 !nextauthor {%next%[[%!sep% %!startlink%%!abbrvauthor%%!endlink%%!nextauthor%]]}
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%]]}
197 !nextfullcite {%next%[[%!sep% %bibentry%%!nextfullcite%]]}
200 # ACTUAL STYLE DEFINITIONS
202 # (identical in authoryear and numerical)
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%)]]}
223 CiteFormat authoryear
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%
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%]]}
246 # ACTUAL STYLE DEFINITIONS
248 # (additions and modifications to default)
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%
264 # Fallback style: "Author A (cf. Year),[ and] Author B (Year, p. xx)"
265 cite %!makecitet%%!textafter%%!close%
272 # 1. Translatable bits (need to be marked by _ prefix)
275 _superscript Superscript
278 # 2. Macros re-used in the style definitions
284 # "Author [cf. ID..."
285 !makecitet %!abbrvauthor% %!open%%!textbefore%{%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!nextcitet%
287 !makecitealt {%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!nextcitealt%
289 !hashkey {%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%%!nexthashkey%]]}
291 # "...], [and] NextAuthor [ID..."
292 !nextcitet {%next%[[%!close%%!smartsep%%!abbrvauthor% %!open%%!textbefore%{%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!nextcitet%]]}
294 !nextcitealt {%next%[[%!sep% %!makecitealt%]]}
295 # FIXME: What is this?
296 !nexthashid {%next%[[%!sep% #ID%!nexthashid%]]}
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%]]}
303 # ACTUAL STYLE DEFINITIONS
305 # (additions and modifications to default)
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%
319 # Fallback style: "[cf. ID, NextID..., p. xx]"
320 cite %!open%%!textbefore%%!hashkey%%!textafter%%!close%