add non-breaking spaces to 'and' and 'et al.'

I'm trying to create a custom style that includes non breaking spaces (NBS) within citations.

Currently I can add NBS between an author name and a year fine:

(Smith*2004) (Assume asterisks refer to NBS)

And i can add NBS between author names fine too:

(Smith,*Brown and Green*2005)

But I can't work out how to replace the breaking spaces where a citation has " and " or " et al.". That is I'd like to have citations that look like this:

(Smith*et*al.*2005) or (Smith,*Brown*and*Green*2005)

As far as I can tell "and" and "et al." are set up differently. Is it possible to do what I want?
  • Sorry scratch this. I'm still not sure how to do it, but I don't think I want to after all.
  • Good - I don't think it can be done anyway.
  • edited February 5, 2012
    It can be done!
    Here is how it works:

    All you need is the HTML-Code for NBS, which is

    &amp#160;

    You can insert this Code anywhere you like.
    I inserted it as suffix after the page-variable, which is quite neat. A "p." on one line and the number on the next is not looking too good.

    For the NBS between terms you need to manually override them.
    I'll just paste a sample from my custom-APA-csl. All you need to do is, copy&paste right after the closing info-tag </info>, change the de-DE to whatever is your locale (i.e. en-US, es-ES, de-AT...) and edit the terms according to your needs. Quite simple solution, which I didn't find, when searching for it, myself.

    <locale xml:lang="de-DE">
    <terms>
    <term name="et-al">et&amp#160;al.</term>
    <term name="and others">et&amp#160;al.</term>
    <term name="retrieved">Verfügbar unter</term>
    <term name="no date" form="long">ohne Datum</term>
    </terms>
    </locale>

    I hope this post helps you.
  • Axolot - yes, but, that's only one of the three nbsp that Josh wanted. You can't modify the spaces after et al and before and after and. Zotero inserts them automatically, they can't be defined in the terms.
  • ...and it's probably not such a bad thing that there's no option to do that anyway. Having given it a small amount of thought it would probably be a terrible idea. It would lead to some very strange looking formatting.

    I knew how to add a NBS into term names. But I hadn't specifically defined the term et al with a NBS in it which does make sense.

    So thanks for your help Axolot.
  • edited February 5, 2012
    Minor clarification:
    All you need is the HTML-Code for NBS, which is

     
    That's not "HTML"; it's a unicode code point.

    I don't much like the idea of including this sort of stuff in styles.
  • bdarcus - why's that?
  • I assume Bruce means because CSL files are Unicode, and there's no reason to use HTML/XML entities in (properly parsed) Unicode files. That's true for most characters, but I'd say spaces are a special case, since it's very hard to tell what space is being used if it's not written as an entity.
  • edited February 5, 2012
    I assume Bruce means because CSL files are Unicode, and there's no reason to use HTML/XML entities in (properly parsed) Unicode files. That's true for most characters, but I'd say spaces are a special case, since it's very hard to tell what space is being used if it's not written as an entity.
    I was mainly correcting the suggestion of embedding "HTML code", which this isn't (nor it an entity, BTW). It's actually a numeric character reference, which refers to the unicode character.

    I also think the suggestion above on terms feels like a hack. If it's really a good idea to be using non-breaking spaces (which I confess to generally not liking), then I think we should come up with a better general solution.
  • We don't need to be pedantic here—everyone calls them entities, whether named or numeric.

    I was responding to your "I don't much like the idea of including this sort of stuff in styles." I'm saying that, for the less common spaces, using numeric entities is clearer than using Unicode characters directly. Do you disagree with that? Or are you suggesting another solution?
  • Ah okay, I see what you mean. The nbs between et al. and page-numbers and p. are quite useful. I agree though, nbs between "and" and author-names and places like this are not that good. You probably wouldn't use them at those places anyway.
    And about using unicode... I'm fine with it, as long as it works. Nbs are only of "cosmetic value", if you ask me... If things get torn apart, or not, does not make the style incorrect.
    I just wanted to share my solution...
  • edited May 10, 2012
    for the less common spaces, using numeric entities is clearer than using Unicode characters directly.
    I have been pretty-printing the styles in the CSL style repository to get consistent indentation, but my current script unescapes any escaped unicode characters. See e.g. https://github.com/citation-style-language/styles/commit/fcbe151df6ba2804dbe1b671c7bbe0c0ff984d77#diff-1

    I'm planning to do a find-and-replace to (re-)escape some of these characters. Are there any other characters to escape other than the non-breaking space (& #160;) and narrow non-breaking space (& #8239;)? I'm only concerned about those characters that cannot be recognized visually in their unicode representation. @adamsmith, @Gracile, thoughts?
Sign In or Register to comment.