]> git.lyx.org Git - lyx.git/blob - lib/citeengines/natbib.citeengine
1e1af3fb00950c48433816bbdd0fb5e17bb10db3
[lyx.git] / lib / citeengines / natbib.citeengine
1 # \DeclareLyXCiteEngine[natbib.sty]{Natbib (BibTeX)}
2 # DescriptionBegin
3 #   Natbib supports a range of both author-year and numerical styles mainly
4 #   aimed at the Humanities. It features automatic sorting and merging of
5 #   numerical citations, annotations, capitalization of the `van' part of
6 #   author names, shortened and full author lists, and more.
7 # DescriptionEnd
8
9 # Author: Julien Rioux <jrioux@lyx.org>
10
11 Format 68
12
13 Requires natbib
14
15 # The framework (biblatex|bibtex)
16 CiteFramework bibtex
17
18 # Cite style variants (default|authoryear|natbib)
19 # We provide both authoryear and numerical citations
20 CiteEngineType authoryear|numerical
21
22 # Default style files for either engine type
23 DefaultBiblio  authoryear:plainnat|numerical:plainnat
24
25 # Maximum number of names before "et al." chimes in
26 MaxCiteNames 2
27
28
29 # The syntax of the cite command definitions below is:
30 # LyXName|alias*<!_stardesc!_stardesctooltip>[][]=latexcmd
31
32 # * LyXName:  The LyX name as output in the LyX file. For
33 #             portability reasons, we try to use the same
34 #             name for same-formatted commands in the
35 #             different engines (thus many names stem from
36 #             natbib).
37 # * Alias:    A (comma-separated) list of commands that fall
38 #             back to the given LyX name in the current engine.
39 #             This is a bit like "ObsoletedBy" in the layouts.
40 # * latexcmd: The actual LaTeX command that is output.
41 #
42 # Alias and latexcmd are optional. If no latexcmd is given, the
43 # LyXName will be output to LaTeX.
44 #
45 # Note further:
46 #
47 # * The LyXName "keyonly" has a special meaning: only the citation key,
48 #   without any latex command, is output.
49 # * Capitalization indicates that the command also has a capitalized
50 #   form (\Latexcmd vs. \latexcmd). These usually enforce upcasing of
51 #   name prefixes (von Goethe => Von Goethe).
52 # * Brackets [] indicate the number of optional arguments (0, 1, 2).
53 # * The star * indicates there is a starred version of the command
54 #   (\latexcmd* vs. \latexcmd). By default, the starred version means:
55 #   Expand the author list even if the maxnames setting would cause
56 #   BibTeX/Biber to shorten it with "et al.".
57 #   If the star has a different meaning for a command, it can be
58 #   specified in angle brackets: <!_stardesc!_stardesctooltip>.
59 #   Maximal two translatable macro keywords, marked by the prefix '!_',
60 #   can be given. The first points to the string that replaces the
61 #   "Full aut&hor list" checkbox label in the Citation dialog, the
62 #   second one an optional tooltip for this checkbox. Note that these
63 #   two macros have to be defined in the CiteFormat section (see below),
64 #   dropping the '!' from the prefix (see below), e.g.:
65 #   _stardesc Starred command label
66 #   _stardesctooltip Tooltip for the starred command checkbox.
67
68 #
69 # CITE COMMAND DEFINITIONS for either engine type
70 #
71 CiteEngine authoryear
72         Citet*[][]
73         Citep*[][]
74         Citealt*[][]
75         Citealp*[][]
76         Citeauthor*[]
77         citeyear[]
78         citeyearpar[][]
79         nocite
80         keyonly
81 End
82
83 CiteEngine numerical
84         Citep*[][]
85         Citealp*[][]
86         Citet*[][]
87         Citealt*[][]
88         Citeauthor*
89         citeyearpar[][]
90         citeyear
91         nocite
92         keyonly
93 End
94
95
96 #
97 # CITE FORMAT
98 #
99
100 # The following defines how the commands are represented in the GUI
101 # (inset button and citation dialog) as well as in XHTML, docbook and
102 # plain text output.
103 #
104 # There are common definitions (default) and specific definitions for
105 # either cite engine type (which overwrite existing defaults.
106 #
107
108 # Input standard format definitions for the bibliography
109 Input stdciteformats.inc
110
111 CiteFormat default
112         #
113         # MACROS
114         #
115         # 1. Translatable bits (need to be marked by _ prefix, if translated to the GUI language,
116         #    or B_, if translated to the buffer language)
117         #    Note that preceding and trailing spaces matter.
118         #
119         _notcited not cited
120         _addtobib Add to bibliography only.
121         _keyonly Key only.
122         _key Key
123         # The following are handled by BiblioInfo
124         B_etal  et al.
125         B_namesep , [[separate author names in citation, except for last name]]
126         B_lastnamesep , and [[separate name of last author in citation]]
127         B_pairnamesep  and [[separate two authors in citation]]
128
129         #
130         # 2. Macros re-used in the style definitions
131         #
132         # A link that lets us jump to the bibliography entry in LyXHTML
133         # %clean:key% will be substituted by the cite key to give a unique id
134         !startlink {!<a href='#LyXCite-%clean:key%'>!}
135         !endlink {!</a>!}
136
137         # "Author et al." or "??"
138         !abbrvciteauthor {%abbrvciteauthor%[[%abbrvciteauthor%]][[??]]}
139         # "Author, ..." or "??"
140         !fullciteauthor {%fullciteauthor%[[%fullciteauthor%]][[??]]}
141         # Handle starred command: abbr. or full author list
142         !makeauthor {%ifstar%[[%!fullciteauthor%]][[%!abbrvciteauthor%]]}
143         # "prenote "
144         !textbefore {%textbefore%[[%textbefore% ]]}
145         # ", postnote"
146         !textafter {%textafter%[[, %textafter%]]}
147         # Add a year if it exists (else "??") and possibly a modifier (as in 2017a)
148         !year {%year%[[%year%]][[??]]}{%modifier%[[%modifier%]]}
149
150         # "...; Author..."
151         !nextauthor {%next%[[%!sep% %!startlink%%!abbrvauthor%%!endlink%%!nextauthor%]]}
152         # Handle starred command: abbr. or full author list
153         !makenextauthor {%next%[[%!sep% %!startlink%%!makeauthor%%!endlink%%!makenextauthor%]]}
154         # "..., CiteKey..."
155         !nextkey {%next%[[%!sep% %key%%!nextkey%]]}
156         # "..., Year..."
157         !nextyear {%next%[[%!sep% %!startlink%%!year%%!endlink%%!nextyear%]]}
158
159         #
160         # ACTUAL STYLE DEFINITIONS
161         #
162         # (identical in authoryear and numerical)
163         #
164
165         # "(cf. Year; NextYear, p. xx)" [Authoryear] / "(cf. Year, NextYear, p. xx)" [Numerical]
166         citeyearpar %!open%%!textbefore%%!startlink%%!year%%!endlink%%!nextyear%%!textafter%%!close%
167         # "Add to bibliography only." (dialog) / "[ID] (not cited)" (button)
168         nocite {%dialog%[[%_addtobib%]][[%key%%!nextkey% (%_notcited%)]]}
169         # Output only the key
170         keyonly {%dialog%[[%_keyonly%]][[%_key%: %key%%!nextkey%]]}
171 End
172
173 CiteFormat authoryear
174         #
175         # MACROS
176         #
177         !open (
178         !sep ;
179         !close )
180
181         # "Author et al. (cf. Year..."
182         !makecitet %!startlink%%!makeauthor%%!endlink% %!open%%!textbefore%%!year%%!nextcitet%
183         # "Author et al. cf. Year..." [sic!]
184         !makecitealt %!startlink%%!makeauthor% %!textbefore%%!year%%!endlink%%!nextcitealt%
185         # "Author et al., Year..."
186         !makecitealp %!startlink%%!makeauthor%, %!year%%!endlink%%!nextcitealp%
187
188         # "...); Nextauthor (Year..."
189         !nextcitet {%next%[[%!close%%!sep% %!startlink%%!makeauthor%%!endlink% %!open%%!year%%!nextcitet%]]}
190         # "...; NextAuthor et al. Year..."
191         !nextcitealt {%next%[[%!sep% %!makecitealt%]]}
192         # "...; NextAuthor et al., Year..."
193         !nextcitealp {%next%[[%!sep% %!makecitealp%]]}
194
195         #
196         # ACTUAL STYLE DEFINITIONS
197         #
198         # (additions and modifications to default)
199         #
200
201         # "Author (cf. Year); NextAuthor (Year, p. xx)"
202         citet %!makecitet%%!textafter%%!close%
203         # "(cf. Author et al., Year; NextAuthor et al., Year, p. xx)"
204         citep %!open%%!textbefore%%!makecitealp%%!textafter%%!close%
205         # "cf. Author et al., Year; NextAuthor et al., Year, p. xx"
206         citealp %!textbefore%%!makecitealp%%!textafter%
207         # "Author cf. Year; NextAuthor Year, p. xx" [sic!]
208         citealt %!makecitealt%%!textafter%
209         # "Author; NextAuthor, p. xx"
210         citeauthor %!startlink%%!makeauthor%%!endlink%%!makenextauthor%%!textafter%
211         # "Year; NextYear, p. xx"
212         citeyear %!startlink%%!year%%!endlink%%!nextyear%%!textafter%
213
214         # Fallback style: "Author (cf. Year); NextAuthor (Year, p. xx)"
215         cite %!makecitet%%!textafter%%!close%
216 End
217
218 CiteFormat numerical
219         #
220         # MACROS
221         #
222         !open [
223         !sep ,
224         !close ]
225
226         # "Author [cf. ID..."
227         !makecitet %!makeauthor% %!open%%!textbefore%{%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!nextcitet%
228         # "Author cf. ID..."
229         !makecitealt %!makeauthor% %!textbefore%{%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!nextcitealt%
230         # "ID..."
231         !hashkey {%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%%!nexthashkey%]]}
232
233         # "...], NextAuthor [ID..."
234         !nextcitet {%next%[[%!close%%!sep% %!makeauthor% %!open%%!textbefore%{%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!nextcitet%]]}
235         # "..., NextAuthor ID..."
236         !nextcitealt {%next%[[%!sep% %!makeauthor% {%dialog%[[#ID]][[%!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%]]}%!nextcitealt%]]}
237         # FIXME: What is this?
238         !nexthashid {%next%[[%!sep% #ID%!nexthashid%]]}
239         # "..., NextID..."
240         !nexthashkey {%next%[[%!sep% %!startlink%{%numericallabel%[[%numericallabel%]][[#%key%]]}%!endlink%%!nexthashkey%]]}
241
242         #
243         # ACTUAL STYLE DEFINITIONS
244         #
245         # (additions and modifications to default)
246         #
247
248         # "[cf. ID, NextID, p. xx]"
249         citep %!open%%!textbefore%%!hashkey%%!textafter%%!close%
250         # "Author [cf. ID], Nextauthor [NextID, p. xx]"
251         citet %!makecitet%%!textafter%%!close%
252         # "cf. ID, NextID, p. xx"
253         citealp %!textbefore%%!hashkey%%!textafter%
254         # "Author cf. ID, NextAuthor ID, p. xx"
255         citealt %!makecitealt%%!textafter%
256         # "Author, NextAuthor"
257         citeauthor %!startlink%%!makeauthor%%!endlink%%!makenextauthor%
258         # "Year, NextYear"
259         citeyear %!startlink%%!year%%!endlink%%!nextyear%
260
261         # Fallback style: "[cf. ID, NextID, p. xx]"
262         cite %!open%%!textbefore%%!hashkey%%!textafter%%!close%
263 End