how to get parentheses to change to brackets when citation is in parentheses?

2
  • Hi Ryan,

    Thanks for taking an interest and sorry about the broken link. Try it now (http://coffeewithbarretts.com/uploads/SearchParens.docm). By the way, I made a couple of changes to the VBA macro because it wasn't working properly for too many levels of nested parentheses/brackets.

    The SearchParens.docm document has a few paragraphs of text with various kinds of parentheses. Just put the cursor someplace in the text and press ctrl+alt+shift P to have it pop up a message box saying whether you are inside parentheses or not. My personal bibliographic software uses this information to swap parentheses and brackets in citations if the insertion point is inside parentheses already.

    I can post the modified VBA macro if it would be helpful.

    I'd love for this sort of functionality to be included in Zotero.

    --Rob
  • Just a vote for adding some kind of automation for this feature at least in the SBL citation style. In keeping with examples like the ones that mbrand, robbarrett, and rschellenberg have mentioned. Despite some other disciplines' preferences for shorter or citation-only footnotes, scholarly writing in biblical studies often makes use of lengthy footnotes to discuss in detail multiple references to secondary literature. So, in my writing too, as in the examples that mbrand, robbarrett, and rschellenberg have mentioned, this kind of embedding of an initial reference to a particular work within a larger parenthetical citation in a footnote actually comes up quite often, and so the need to change parentheses out for square brackets according to CMS, 15th ed., §6.102, actually comes up pretty frequently.
  • So to go back to my original point, a) I still don't think this was ever explained very clearly , and b) yes, I did miss something.

    My current understanding:
    SBL is a note-based style. In that style, some details (like publisher) are by default enclosed in parenthesis. But sometimes, some users want to include such citations in parentheses, in which case the nested parentheses are wrong, and the inner parenthesis should be converted to brackets. The need for brackets or parenthesis thus depends on context, and so cannot be coded in CSL.
    So first, a question: is this description correct? Or do I need to amend that middle sentence to:
    But when a user includes a citation in a footnote, such citations must always be wrapped in parentheses, and thus ...
    Either way, this is what I mean by clearly defined use cases. You need to explain the needs in general but precise terms that those of us who don't use these styles can understand. I think we collectively wasted hours tying to understand this.

    The technical discussion depends a lot on which interpretation is correct.
  • bdarcus, if this kind of automation is indeed not possible with CSL, my apologies for understanding that that conclusion had been reached in the preceding discussion. By and large, your first summary seems correct, though perhaps with one meaningful twist.

    By way of trying to provide the kind of example that might help, here is a sentence from a footnote on an essay that I'm currently writing:
    Photius of Constantinople and Diodorus of Tarsus seem to refer this text to the Father (John Anthony Cramner, Catenæ Græcorum Patrum in Novum Testamentum (Oxford: Oxford University, 1844), 4:162, lines 22–29; J. P. Migne, ed., Patrologia graeca (Paris, 1857), 102:157b–c).
    This citation is correctly formatted per CMS (and SBLHS, which defers to CMS at this point) except that:
    (Oxford: Oxford University, 1844) . . . (Paris, 1857)
    should be:
    [Oxford: Oxford University, 1844] . . . [Paris, 1857]
    The (LibreOffice) Zotero field text for the citation at the end of the sentence that I've quoted is as follows:
    ZOTERO_ITEM CSL_CITATION {"citationID":"cXqlO3pK","properties":{"formattedCitation":"{\\rtf (John Anthony Cramner, \\i Caten\\uc0\\u230{} Gr\\uc0\\u230{}corum Patrum in Novum Testamentum\\i0{} (Oxford: Oxford University, 1844), 4:162, lines 22\\uc0\\u8211{}29; J. P. Migne, ed., \\i Patrologia graeca\\i0{} (Paris, 1857), 102:157b\\uc0\\u8211{}c).}","plainCitation":"(John Anthony Cramner, Catenæ Græcorum Patrum in Novum Testamentum (Oxford: Oxford University, 1844), 4:162, lines 22–29; J. P. Migne, ed., Patrologia graeca (Paris, 1857), 102:157b–c)."},"citationItems":[{"id":1312,"uris":["http://zotero.org/users/2212/items/D2PWUSVU"],"uri":["http://zotero.org/users/2212/items/D2PWUSVU"],"itemData":{"id":1312,"type":"book","title":"Catenæ Græcorum Patrum in Novum Testamentum","publisher":"Oxford University","publisher-place":"Oxford","number-of-volumes":"8","event-place":"Oxford","note":"http://books.google.com/books?id=Yb4UAAAAQAAJ","shortTitle":"Catenæ Græcorum Patrum","author":[{"family":"Cramner","given":"John Anthony"}],"issued":{"year":1844}},"locator":"4:162, lines 22–29","label":"page","prefix":"("},{"id":17236,"uris":["http://zotero.org/users/2212/items/E95J7EMR"],"uri":["http://zotero.org/users/2212/items/E95J7EMR"],"itemData":{"id":17236,"type":"book","title":"Patrologia graeca","publisher-place":"Paris","number-of-volumes":"162","event-place":"Paris","editor":[{"family":"Migne","given":"J. P."}],"issued":{"year":1857,"season":"1886"}},"locator":"102:157b–c","label":"page","suffix":")"}],"schema":"https://github.com/citation-style-language/schema/raw/master/csl-citation.json"} RNDmAdHFDC27j
    As has been mentioned previously, parentheses that are simply typed into the word processor and not entered in the citation editor shouldn't be something for which we'd expect Zotero to account automatically. But, since I've here specified the enclosing parentheses as a prefix to the first and a suffix to the second (and last) citation (cf. adamsmith above):
    "prefix":"(" . . . "suffix":")"
    it would be nice if Zotero would translate any medial parentheses into square brackets. Or, since a compound citation of two or more individual sources might be involved (as in my example here), perhaps what's needed is an additional field or option in the citation editor for applying parentheses to the whole compound citation and then, based on this setting, translating what would be medial parentheses, e.g.,
    (Oxford: Oxford University, 1844) . . . (Paris, 1857)
    into square brackets, e.g.,
    [Oxford: Oxford University, 1844] . . . [Paris, 1857]
    These medial parentheses can, of course, already be replaced manually in the citation editor, but making those replacements one-at-a-time over several hundred pages of footnote text makes an automation option desirable.

    I hope this example is helpful. Thanks so much for the thoughts.
  • edited January 10, 2012
    @dstark - so just to be crystal clear:
    By and large, your first summary seems correct ...
    In SBL, parentheses around a citation in a footnote are entirely optional, and it's just as common to include such a citation (in a footnote) without parentheses?
    ... though perhaps with one meaningful twist.
    I'm not seeing the "meaningful twist" (to my description of the case).
  • bdarcus, yes, probably a majority or at least a substantial minority of the citations would occur in a footnote without parentheses around the whole citation (cf. the example of adamsmith above).

    In your description, you had summarized that:
    [S]ometimes, some users want to include such citations in parentheses, in which case the nested parentheses are wrong, and the inner parenthesis should be converted to brackets. The need for brackets or parenthesis thus depends on context, and so cannot be coded in CSL.
    If the "context" mentioned here refers to a situation in which parentheses had been typed directly into the word processor and not into a particular reference's Zotero field through the citation editor—e.g., my example without the
    "prefix":"(" . . . "suffix":")"
    elements—then (to me at least), it's quite understandable that these parentheses implications "c[ould ]not be coded in CSL."

    But, if the "context" mentioned here could refer to instances where a user had added the framing parentheses in the prefix/suffix fields or some other option in the citation editor (perhaps akin to how the suppress author function already works), having framing parentheses and translating what would be medial parentheses into square brackets would seem to be something that could be automated. . . . "could be" in the sense that the user has then "told" Zotero about his or her desire to have these framing parentheses. The feasibility of the nuts and bolts of the code required to perform such an operation may be (is?) another matter entirely.
  • OK. By "context" I was purely meaning of the citation within the document, from the perspective of the user dealing with these citations; irrespective even of Zotero, etc. I probably should have left out that last phrase.
  • @dstark,
    As has been mentioned previously, parentheses that are simply typed into the word processor and not entered in the citation editor shouldn't be something for which we'd expect Zotero to account automatically. But, since I've here specified the enclosing parentheses as a prefix to the first and a suffix to the second (and last) citation ...
    I've just checked in a revision to the citation processor that implements parens-to-bracket flipping, along the lines you suggest. It will take awhile (probably weeks, likely not months) for the revised processor to appear in Zotero. To be on the safe side, I've included a switch to make it easy for the Zotero developers to turn it off, if it causes problems for other users (which I don't expect it will, but you never know). So no guarantees yet, but we have something in the works.
  • To make sure we're all understanding this: The citeproc revision will automatically flip parentheses to brackets for all cases where open parentheses are in the prefix or close parentheses are in the suffix? Or are both required?
  • fbennett, thanks so much for the update.
  • Flipping to square braces is turned on when the last-occurring (round) parens in an affix (suffix or prefix) is an open parens, and turned off when it is a close parens (nesting of parens is not relevant). Flipping resets to off at the start of a citation, so a dangling open parens will not affect other citations.

    There is a test here that illustrates the behavior.

    This will not work for text controlled by the word processor, of course; the parens need to be in the affixes of a cite to make them "visible" to the processor.
  • thanks - looks good to me.
  • I'm trying to apply this functionality and don't seem to be getting results. Did this change ever get pushed out? Not a huge deal as I can tweak manually for the once case I need it (square brackets inside a parenthetical citation).
  • As far as I know, the code for this is still in the processor. It would only be triggered when the enclosing parentheses are in the Prefix field of the first item in the citation, and the Suffix field of the last. Parens in the word-processor document text would not be recognized.
  • Thank you for your reply. Yes, that was how I applied it (using Prefix and Suffix fields). Is it style-dependent (e.g. only works with SBL, which I don't use)? If so, then I could add it to the styles I use. This is good functionality to have.
  • It's not part of the style and should work across the board. But to replicate any issues you have: which one are you using?
  • This should replicate it:
    1. Install Ecology style.
    2. begin new MS Word doc. Set the style to Ecology in Zotero Document Preferences.
    3. Type some text
    4. Search for a citation using the "new" tool. Click on the citation, in the Prefix field add "(parenthetical statement " (no quotes)
    5. In the Suffix field add ")" or add some text and then the end parens, no quotes.
    6. Hit enter a couple of times. The result is:
    ((parenthetical statement Author1 and Author2 1995))

    I expected:
    (parenthetical statement [Author1 and Author2 1995])
  • It's apparently set up to switch to brackets only in note styles. I'll loosen that constraint.
  • Oh, no, I take that back. It's failing when the parens are set as affixes to the overall citation (on cs:layout). Should be able to fix that.
  • Excellent. Thanks for looking into this.
  • edited February 25, 2016
    Just for the sake of documentation and if anyone else needs a solution to the specific example I gave above, this workaround does the trick:

    put "parenthetical statement [" in the prefix and "]" in the suffix. You'll end up with

    (parenthetical statement [Author1 and Author2 1995])

    Obviously, this workaround only applies to a small subset of scenarios where the square brackets would be useful to have.
  • I have a working solution in a revised draft of the processor that handles nesting correctly across the entire citation, to arbitrary nesting depth.

    There is one logic/design issue to settle before it's released. Some citation forms contain square braces. Instances I can think of off the top of my head are square-braces years and square-braced paragraph numbers in some legal cites. There may be others.

    So the question is whether those should flip as well (bracket to parens) when they are nested. My inclination would be to say "yes," but I'm not 100% sure that's the right call.

    Any thoughts? @adamsmith? @rintzezelle?
  • I'd be inclined to say no. Chicago Manual specifies this just in one direction and I have never seen the opposite and it'll just create unwanted effects.

    I'm actually, having consulted the Manual, less certain this is a good idea: apparently, e.g. in UK typography, parentheses within parentheses are generally preferred. So I'm wondering if we're not actually breaking more than we're fixing here, since, as tghoward points out, there is at least a workaround for getting the square brackets. Once implemented, it'd be impossibel to get parentheses within parentheses (right?).

    Sorry that didn't occur to me sooner, I just read this.
  • No worries, it was good to revisit this end of the code. Whether paens flipping is offered or not, we seem to have an issue with the nesting priority of item prefix and layout prefix. Worth further discussion maybe.
  • For APA, the general preference for citations is to have no nested brackets whatsoever, but instead to use commas to offset years for citations within parenthetical comments. (Truly nested parenthetical comments, such as giving an acronym within a parenthetical comment, do use brackets.). So there is definitely diversity in how such rules are specified.
  • That would be possible, but it would obviously need a flag somewhere in the CSL code of the style.

    Not sure what to do in the processor for the time being. The flipping code currently takes effect only on parens inside the layout affixes, which is halfway to the goal, so to speak. Could wind out parens flipping completely, or finish it out completely, or leave it as it is.
  • edited February 26, 2016
    e.g. in UK typography, parentheses within parentheses are generally preferred.
    The Dutch Language Union (Taalunie) does recommend the use of square brackets within round parentheses, FWIW: http://taaladvies.net/taal/advies/vraag/865
  • Is nested bracket rules something that should be specified in locales, with a style override?
  • Any suggestions on the best policy for the present? The current Zotero version ignores affixes on cs:layout, and so fails on most author-date styles (the issue that prompted this thread). Halfway-there does not seem a happy place to be, but if no changes are made, there will be no fresh surprises.

    (1) If we were to attempt a rational explanation for current behaviour, you could say that it flips in note styles, and does not in in-text styles. That's not a 100% accurate description, but in effect that's what most users will see.

    (2) Alternatively, I could remove parens-flipping entirely, which as Sebastian has noted would align behaviour with Chicago.

    (3) Or I could go forward with robust parens flipping, which given what we know so far would probably be a very bad idea.

    I don't much like (3), but as between (1) and (2) I don't have a strong preference myself. Any thoughts?
  • As someone who finds the current parens-flipping helpful, I'd advocate for (1). Chicago does in fact request square brackets within parentheses (see below, copied from earlier in the thread -- though not, apparently, vice versa).

    If UK styles prefer parentheses within parentheses, the ideal would be to make parens-flipping style-dependent — be able to turn it on or off in the csl code.

    If that is not feasible, it seems that one group of users will have to be making manual changes. So then it would be a matter of weighing the greater inconvenience. Unless you're hearing complaints about current behavior, it would seem a shame to me to lose this function, even if it's not perfect.



    "The Chicago Manual of Style" 15th edition (2003), p. 266 has:

    "6.102 Parentheses within parentheses. Athough the use of parentheses within parentheses (usually for bibliographic purposes) is permitted in some publications -- especially in law -- Chicago prefers brackets within parentheses (see 6.106)."...

    and p. 268:

    [under section "Brackets, Square Brackets"]:

    "6.106. Within Parentheses. Square brackets are used as parentheses within parentheses, usually for bibliographic purposes."...
Sign In or Register to comment.