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