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