'chap. ' appears in reference list from pages field

I am using a custom citation style that I created myself and I've discovered some weird behaviour in the reference list.

I have a report item in Zotero which has 'ch. 4' in the pages field because I want to reference a chapter rather than specific pages.

Surprisingly, when I look at my reference list for this item it comes up as 'chap. ch. 4'. That is, it adds the prefix 'chap. ' rather than adding 'p.' or not adding a prefix at all.

Is there a way to change this or take advantage of it?

I know I could just enter '4' in the pages field but then it will revert to 'p. 4'.

I'm assuming this is some sort of default behaviour because I don't have any code in my CSL file that refers to this. Below is the only code I use for the reference list that refers to pages:

<macro name="pages">
<label variable="page" form="short" suffix=".&#160;" strip-periods="true"/>
<text variable="page"/>
</macro>
<macro name="edition">
<choose>
<if is-numeric="edition">
<group delimiter=" ">
<number variable="edition" form="ordinal"/>
<text term="edition" form="short" strip-periods="true"/>
</group>
</if>
<else>
<text variable="edition"/>
</else>
</choose>
</macro>
  • edited May 3, 2013
    Could you edit your post and enclose the CSL code sample in <code>&lt/code> tags? The forum makes it disappear. In the source of the page, the structure of the CSL looks all wrong, but it's possible that the forum formatting engine is doing that.

    In the same line, have you validated the style? You can paste the code here to find out if there are syntax errors:

    http://simonster.github.io/csl-validator.js/
  • (I've added code tags.)
  • I tried validating it and got what I think is one error:

    stdin:139:12: error: missing attributes of http://purl.org/net/xbiblio/csl^label
    required:
    attribute ^variable
    allowed:
    attribute ^plural
    attribute ^prefix
    attribute ^font-style
    attribute ^font-variant
    attribute ^font-weight
    attribute ^text-decoration
    attribute ^vertical-align
    attribute ^text-case
    error: invalid input

    I'm not exactly sure what this means or how to fix it?

    But it isn't obvious to me that it has anything to do with the 'chap. ' issue.

    Any thoughts?
  • we don't see you style. What's in line 139?
  • Sorry, here's the offending section. Line 139 is : label form="short" suffix="" strip-periods="true"



    <names variable="author">
    <label form="short" prefix="" suffix=" ;" strip-periods="true"/>
    <name form="short" name-as-sort-order="all" and="text" sort-separator=", " delimiter=", " delimiter-precedes-last="never" initialize-with="."/>
    <substitute>
    <names variable="editor"/>
    <label form="short" suffix="" strip-periods="true"/>
    <text macro="noauthor_title"/>
    </substitute>
    </names>
    </else>
    </choose>

    </macro>

  • you can't have a label in substitute like that. If you want to specify a label in this case just use the label in the second line - since authors don't have a label it will only apply to editors.

    I don't know if this is going to fix the chap. issue, but invalid styles can produce all types of weird behavior.
  • but I can reproduce that issue, so that won't fix it.
    @fbennet:
    sample data and style are here:
    https://gist.github.com/adam3smith/5522615
    doesn't look like this depends on the style, though, anything that prints page numbers for reports (at a minimum) will do.
  • Thanks Adam. Well that did fix the validation error at least.

    Unfortunately, I just installed the updated style file and I still get the 'chap. ' issue.
  • OK well I do actually think it's a good feature if it only it was functioning properly. Let me know if it gets fixed.

    (P.S. I'm still not sure how to import a single field author using Zotero RDF. If you have a moment to help : https://forums.zotero.org/discussion/29213/import-an-zotero-rdf-citation-with-single-field-author/ )
  • I'll take a look at the chap. issue later today.
  • Any luck fixing this?
  • Thanks for the ping. I should get to it this week.
  • edited May 13, 2013
    Okay, here's news on this one.

    This is a bug, obviously, but as you have noticed, it is potentially useful. Unfortunately, the feature that triggers the bug (which is useful) is not available in standard CSL.

    In the CSL-m extension of CSL that is used in the Multilingual Zotero variant, "page" is a numeric variable, and must be set using cs:number rather than cs:text. If you make that change in your style, you should find that the localized "chap." label appears and that the shorthand label "ch." is removed, to give you "chap. 4". That's the intended behaviour, but unfortunately "pages" is not a numeric variable in standard CSL, so the modified style won't validate, and can't be distributed through the official CSL repository.

    To eliminate confusion, I'll be fixing the processor to render "p. ch. 4" in this case, which is probably not what you want, but more correct under the standard CSL schema.
  • An updated version of the processor is now available. You can try it by installing the processor patch plugin. All the plugin does is to swap in the latest version of the citation processor. You can remove it when the next Zotero release comes out.
Sign In or Register to comment.