How to insert new line breaks in your citation style file.

Note: remove blanks between & and ; in the comment below:

You can use the entity & # 1 0 ; to represent a newline in an XML attribute. & # 1 3 ; can be used to represent a carriage return. A windows style CRLF could be represented as & # 13 ; & # 1 0 ; .

This is legal XML syntax (csl file is a kind of xml file). See XML spec for more details.

Example code:

<group prefix="{" suffix="}" delimiter=", & # 1 0 ;">
<text macro="citeKey"/>
...
</group>

Here it inserts a line break after , - they together act as the delimiter to separate group items.
  • Dear mleoking,
    I have tried your proposed solution but I did not get good results.
    May you send an example type of this?
    Thanks in advance
    -
    Adrian
  • Hello - I am also trying to do this with a custom citation style. I came across this post on stackexchange by @Rintze :
    https://stackoverflow.com/questions/24911522/csl-how-to-insert-a-line-break-in-bibliography
    I downloaded the apa-line-break.csl file and installed it. In the Zotero style preview, it indeed breaks as indicated, but when exporting to either RTF or HTML, the line breaks are not preserved. Is there a way to insert line breaks such that they carry over to external documents (particularly HTML)?
    Thank you for any help!
  • edited July 11, 2018
    What exactly are you trying to do? Can you show the format you are looking to have?
  • @bwiernik - hi! Sure - I am working with a professor to update their publication page, and I'd like to use something close to what they have on their page:
    http://www.wag.caltech.edu/publications/papers/
    If Zotero can't do it, that's fine, I'm sure I can find some other style that will work. I was just surprised that the modified APA style linked above does show correctly in preview, but does not export to RTF or HTML.
  • I believe the citation processor filters out any hardcoded linebreaks, but you can get linebreaks using the display options in CSL, in particular display="block":
    http://docs.citationstyles.org/en/stable/specification.html#display
  • @adamsmith Ahh. That would make sense. I'll try the block display - I did see that as a possible solution, but it didn't work. Entirely possible I wrote the CSL wrong though! Thanks!
  • Display is definitely how you would do this with CSL. When you say, "it didn't work", what exactly do you mean?
  • I Inserted
    <macro name="title">
    <text variable="title" />
    </macro>


    and

    <bibliography et-al-min="20" et-al-use-first="21">
    <sort>
    <key variable="issued" sort="ascending"/>
    <key macro="citation-number" sort="descending"/>
    </sort>
    <layout suffix=" ">
    <text variable="citation-number" suffix=". "/>
    <group delimiter=" ">
    <choose>
    <if type="article article-magazine article-newspaper article-journal review" match="any">
    <group display="block">
    <text macro="title" />
    </group>
    <group display="left-margin">
    <text variable="container-title" form="short" text-case="title"/>
    </group>


    etc.

    And my result is still:

    4. Improved Quantum Theory of Many-Electron Systems. III. The GF Method J. Chem. Phys. 48:450–461 (1968) W.A. Goddard III. http://resolver.caltech.edu/CaltechAUTHORS:20120905-102022532
    3. Magnetic hyperfine structure of lithium Phys. Rev. 157:93–96 (1967) W.A. Goddard III. http://resolver.caltech.edu/CaltechAUTHORS:GODpr67c
    2. Improved quantum theory of many-electron systems. II. The basic method Phys. Rev. 157:81–93 (1967) W.A. Goddard III. http://resolver.caltech.edu/CaltechAUTHORS:GODDpr67b
    1. Improved quantum theory of many-electron systems. I. Construction of eigenfunctions of Ŝ2 which satisfy Pauli’s principle Phys. Rev. 157:73–80 (1967) W.A. Goddard III. http://resolver.caltech.edu/CaltechAUTHORS:GODDpr67a
    I.e. no break after the title. I'm pretty sure i need to re-read the CSL spec as I don't think I have this in the right place. I can post the entire style to a gist if that would help.

    Thanks!
  • How exactly are those generated? The display function unfortunately works a bit unevenly depending on exactly how you're creating bibliographies, but should work in RTF and HTML (and at least going by a quick look, your code looks good)
  • @adamsmith - the actual bibliography? I copied and pasted those from the Style Preview pane. I get the same result when exporting to RTF and HTML.
  • OK, could we see the whole style then? Select all, copy &paste to hastebin.com , click on the save icon at the top right, then post the URL from your browser's address bar here.
  • Hastebin! How cool!
    Here it is: https://hastebin.com/emakezakaq.xml
    Again, I am 99.95% sure I am doing something wrong.
    Thanks!
  • Try something like this: https://hastebin.com/opezuzacoj.xml
    (not polished, but gets you the idea for journal articles)
    You can't "bury" the display elements in other groups.
  • Ahhh - gotcha. So they need ot be in any top most level "group"? Thank you! Testing now!
Sign In or Register to comment.