Content-specific conditions in CSL

Hello everybody,

I have a question concerning the use of CSL styles : is it possible to make concrete conditions influence the behaviour of the style? Here are a few examples of what I would like to do, to make my point clearer:
- when a "number-of-volumes" variable is stated for a book, I want it to appear unless the number is 1 (I don't find the information so relevant to read "1 vol." at the end of my reference) => is anything like meaningful?
- when the name of the author matches that of the book author, I would like the latter not to appear => is anything like meaningful?
- finally, this is maybe the most tricky part, but also the most useful in my case, I would like certain items to behave differently with the same style (e.g. references by a certain author, namely the main author discussed in a work). Could I do this by referring to the content of the variable "author" or to that of a certain Tag?

I hope my question is clear enough. Thank you in advance for your help!

Best,

  • No to all three of these. For the content-specific conditions, these would be very prone to breaking, which is why they were not included in CSL.

    For the third question, Tags are not available to the citation processor. You could code a custom CSL style that uses a specific variable as a flag alerting the processor to use a different format (e.g., if an item contains anything in Extra ['note' in CSL] -- note that this can purely test for the presence or absence of any content, not specific values). Beyond that, there is no way to specify custom formatting like that. If the special formatting is fairly simple (e.g., bold the author's name), it is easy enough to do using Find-and-Replace in your word processor during the final formatting stage of writing.
  • edited January 11, 2017
    Short-answer : no, CSL does not support this. You can't test for the content of a field.
    - when a "number-of-volumes" variable is stated for a book, I want it to appear unless the number is 1 (I don't find the information so relevant to read "1 vol." at the end of my reference) => is anything like meaningful?
    You're right, "1" is not relevant. But where does it come from ? I assume you didn't add it manually… The translator could be improved if you provide the URL of the website where you picked up the reference.
    - when the name of the author matches that of the book author, I would like the latter not to appear => is anything like meaningful?
    No. But have a look there: https://forums.zotero.org/discussion/4785/check-for-identical-author-editor
    - finally, this is maybe the most tricky part, but also the most useful in my case, I would like certain items to behave differently with the same style (e.g. references by a certain author, namely the main author discussed in a work). Could I do this by referring to the content of the variable "author" or to that of a certain Tag?
    No, I think this has been discussed on this forum in the past, though. Manual editing once you've finished your paper is the only way to do that.
  • Many thanks to you both for your answers.

    @bwiernik : the variable to be used as a flag could be an idea indeed; considering what you explained, I suppose this would be the only solution.
    @Gracile : the "1 volume" case was an example taken from students making their first steps in Zotero... The issue can be solved by simply filling in the fields accurately.
    Rintze's suggestion in that other discussion you mentioned (having a if same-variable-value="author editor" condition) would have been what I hoped to find, but I see the issue is not yet solved for citations... to be followed then!

    All the best,
Sign In or Register to comment.