no way to compare when less than two revisions

Differences

This shows you the differences between two versions of the page.


Last revision
zh:dev:citation_styles:style_editing_step-by-step [2011/07/18 05:09] – created gao
Line 1: Line 1:
 +======修改 CSL 样式 ======
 +虽然没有 CSL 的编辑器,但是修改样式其实一点都不困难。你甚至都不需要太多的 XML 知识,只需要按照下列步骤进行即可。
  
 +===== 打开测试面板 =====
 +
 +在Firefox浏览器地址栏中输入
 +
 +''<nowiki>chrome://zotero/content/tools/csledit.xul</nowiki>''
 +
 +如下所示。
 +
 +{{:test-pane.png?600}}
 +
 +打开Zotero面板,选定一个或多个条目,关闭Zotero面板,在测试面板右侧下拉菜单中选择一个样式,CSL样式将会在第一个文本框中出现,引文和参考文献目录将在第二个文本框中出现。
 +
 +==== 动它一下 ====
 +
 +现在你可以在第一个文本框中改动XML文件的内容。只要改动后的文件仍然具有正确的结构,改动后的格式就会在第二个文本框中显示。
 +**注意**你所做的改动不会自动保存,请自行保存。你可以将相应的文本复制到文本编辑器中,存为以csl文件(*.csl)。
 +
 +====示例====
 +
 +在CSL文件的末尾,会有''<citation>'' 和 ''<bibliography>'' 这两块代码,前者决定引文的格式,后者决定参考文献的格式。
 +一般情况下,你只需要改动这两个部分。
 +
 +**code**代码块决定引文格式
 +<code>
 +  <citation>
 +    <option name="collapse" value="citation-number"/>
 +    <sort>
 +      <key variable="citation-number"/>
 +    </sort>
 +    <layout prefix="(" suffix=")" delimiter="; ">
 +      <text variable="citation-number"/>
 +    </layout>
 +  </citation>
 +</code>
 +**bibliography**代码块决定参考文献格式
 +<code><bibliography>
 +    <option name="second-field-align" value="true"/>
 +    <layout>
 +      <text variable="citation-number" suffix=". "/>
 +      <text macro="author"/>
 +      <text macro="title" suffix=". "/>
 +      <choose>
 + <if type="book">
 +   <text macro="edition" prefix=" " suffix=" "/>
 +   <text macro="publisher" prefix=" " suffix="."/>
 + </if>
 + <else-if type="chapter">
 +   <group prefix=" " suffix=". ">
 +     <text term="in" suffix=": " text-case="capitalize-first"/>
 +     <text macro="editor"/>
 +     <text variable="container-title"/>
 +   </group>
 +   <text macro="publisher" prefix=" "/>
 +   <text variable="page" prefix=" p. " suffix="."/>
 + </else-if>
 + <else>
 +   <text variable="container-title" suffix=" " form="short"/>
 +   <text macro="date" suffix=";"/>
 +   <text variable="volume"/>
 +   <text variable="issue" prefix="(" suffix=")"/>
 +   <text variable="page" prefix=":" suffix="."/>
 + </else>
 +      </choose>
 +
 +          </layout>  
 +</bibliography></code>
 +
 +===改变标点符号===
 +引文格式的差异通常会很小,你可以找一个类似的格式,只需要做些许改动,就可以得到你想要的格式。
 +一般情况下,你只需要改动参考文献目录中的标点符号,各个项目(作者,题目,年份等)的位置就可以了。
 +
 +在 Zotero 中,分别以''prefix'', ''suffix'' 和 (group) ''delimiter''属性来标识。
 +
 +例如,下列改动将会将卷号由格式''(9)''变动为''[9]''
 +<code><text variable="issue" prefix="(" suffix=")"/></code>
 +<code><text variable="issue" prefix="[" suffix="]"/></code>
 +
 +
 +===改变参数===
 +
 +当一篇引文的作者有多个的时候,常常需要显示 //et al.// 的缩写,这需要一个**option**参数。这个设置在CSL 0.8.1 和 1.0 中有所不同。
 +
 +
 +==CSL 0.8.1==
 +
 +For example, to remove all [[kb/given_name_disambiguation|given-name disambiguation]], find the line:
 +
 +''<option name="disambiguate-add-givenname" value="true"/>''
 +
 +And just delete the whole line.
 +You'll see the change occur immediately in the preview pane below.
 +
 +如果有4个以上作者时,只显示第一个作者,并加上 //et al.// ,那么会有如下代码:
 +<code><option name="et-al-min" value="4" />
 +<option name="et-al-use-first" value="1"/></code>
 +不妨将4改为6,将1改为3,你会在下面的文本框中看到改动后的结果。
 +<code><option name="et-al-min" value="6" />
 +<option name="et-al-use-first" value="3"/></code>
 +
 +The [[dev/citation_styles/CSL 0.8.1 Syntax]] explains how CSL 0.8.1 works.  Common options you might wish to change are [[dev/citation_styles/CSL 0.8.1 Syntax#options|here]].
 +
 +==CSL 1.0==
 +In CSL 1.0, the same options - and several new ones - exist, but they are not listed separately, but included in the <citation> and <bibliography> lines, e.g.
 +<code><citation et-al-min="4" et-al-use-first="1" disambiguate-add-year-suffix="true" disambiguate-add-names="true"></code>
 +
 +A bit of trial and error, and testing with a few combinations should help. You can see what different items and combinations will look like by selecting them in Zotero (Ctrl-click to select multiple items), and then "Refresh" at the top-left of the Test pane.  
 +
 +<html>
 +<blockquote><font color="blue" size="+1.2">TIP :</font>
 +If your style has a mistake, an error message is displayed instead of a citation. Often these messages can help you figure out what you're doing wrong.<br>Also, you can use Ctrl-Z to undo, or if you get really stuck, just select the style from the drop-down again and you're back where you started.</blockquote></html>
 +
 +==== 改变样式的标题(Title)和 ID ====
 +
 +强烈建议你修改样式的Title和ID。
 +
 +否则:
 +  * 你安装新的样式会覆盖掉原有的样式
 +  * 自动更新之后,你的自定义样式又会被更新覆盖。
 +
 +这部分内容在文件的开头,像这个样子:
 +
 +
 +<code><title>Harvard Reference format 1 (Author-Date)</title> 
 +<id>http://www.zotero.org/styles/harvard1</id></code>
 +
 +你可以将其改为
 +
 +<code><title>Harvard Style Modified</title>
 +<id>http://www.zotero.org/styles/harvard-modified</id></code>
 +
 +==== Different CSL versions ====
 +Starting with version 2.1, Zotero uses an updated version of the Citation Style Language, [[http://citationstyles.org/downloads/specification.html|CSL 1.0]], which has a changed syntax. The styles that come with your copy of Zotero as well as most styles in the [[http://www.zotero.org/styles|Zotero Style Repository]] are in the old CSL 0.8.1 format and are updated internally. You can still edit CSL 0.8.1 styles, but if you want to make more substantive changes or take advantage of one of the [[http://citationstyles.org/downloads/upgrade-notes.html|new features of CSL 1.0]], you should download an updated version of the style from the [[https://github.com/citation-style-language/styles|CSL 1.0 repository]] or use [[http://citationstyles.org/downloads/upgrade-notes.html#updating-csl-0-8-styles|update the CSL 0.8.1 style]] yourself. //You cannot mix CSL 0.8.1 and 1.0. If you want to use some of the new features in 1.0 you will need to use a style converted to 1.0.//
 +
 +===== 使用你自定义的样式 =====
 +
 +你需要将一个样式安装到 Firefox 中,或者说安装到 Zotero 中。
 +
 +将样式的文本全选,复制并粘贴到文本编辑器中,保存为一个以**.csl**结尾的文件。然后,拖动该文件到 Firefox 窗口上面,会提示你是否安装,如下图所示。
 +
 +{{:style_install.png?600}}
 +
 +选择确定。该样式就会安装到你的 Zotero 中了。
 +
 +
 +=====  Some Slightly more advanced tips =====
 +
 +For anything more advanced, [[dev/citation_styles|this page]] is your friend. It also includes links to comprehensive documentation for both CSL 1.0 and CSL 0.8.1.
 +
 +If you are making several changes, you might want to copy all the CSL code from the top window (Ctrl-A, Ctrl-C) and paste it into a new file in a text editor. Notepad works fine, though using a good text editor designed for programming like the free [[http://notepad-plus.sourceforge.net|Notepad++]] for Windows or [[http://www.barebones.com/products/TextWrangler/|TextWrangler]] for Mac OS X, can help you to see the structure clearly and not make mistakes. Set the "language" to XML (CSL is based around XML).
 +
 +You'll find that your fellow users on the Zotero forum will be happy to help you with any problems. The forums also have little nuggets of gold all through them, and [[/search/#support|searching]] usually finds the solution to any issue. If you are still having trouble, post a question in the Styles section of the forums and it's likely to get answered quickly.
 +
 +===== Sharing Styles =====
 +
 +If your new style has general appeal, consider [[dev/citation_styles/sharing_styles|submitting]] it for inclusion into the [[http://www.zotero.org/styles|Zotero Style Repository]].