Ampersand as namessep in biblatex label
up vote
9
down vote
favorite
I am trying to change the way that labels are generated. Some of it I already got working (only at maximum two authors, only last two digits of the year), but one thing does not seem to work, which is putting an ampersand between the authors if there are at least two.
In the manual on page 205 it is explained, that one can use special characters without escaping them as literals or padding, but what about the namessep field?
In the MWE I used 'X' in the place where an '&' should be placed, but I do not know how to do it.
I suspect, that since it is converted into the .bcf
file, which is XML, that the ampersand makes troubles there, so is this a bug?
Here is a MWE:
documentclassarticle
usepackage[utf8]inputenc
usepackage[english]babel
usepackagecsquotes
usepackagefilecontents
beginfilecontents*references.bib
@articleeinstein,
author = "Albert Einstein and Second Author",
title = "Zur Elektrodynamik bewegter K"orper. (German)
[On the electrodynamics of moving bodies]",
journal = "Annalen der Physik",
volume = "322",
number = "10",
pages = "891--921",
year = "1905",
DOI = "http://dx.doi.org/10.1002/andp.19053221004",
keywords = "physics"
@bookdirac,
title=The Principles of Quantum Mechanics,
author=Paul Adrien Maurice Dirac,
isbn=9780198520115,
series=International series of monographs on physics,
year=1981,
publisher=Clarendon Press,
keywords = physics
@booklatexcompanion,
author = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
title = "The LaTeX Companion",
year = "1993",
publisher = "Addison-Wesley",
address = "Reading, Massachusetts",
keywords = "latex"
endfilecontents*
usepackage[
backend=biber,
style=alphabetic,
citestyle=alphabetic,
maxcitenames=2,
mincitenames=2,
giveninits=true,
isbn=false,
]biblatex
renewcommand*labelalphaothers$^+$
DeclareLabelalphaTemplate
labelelement
field[final]shorthand
fieldlabel
field[names=2, namessep=addspaceXaddspace]labelname
labelelement
literaladdspace
labelelement
field[strside=right,strwidth=2]year
addbibresourcereferences.bib
begindocument
sectionFirst section
Items that are cited: textitThe LaTeX Companion book citelatexcompanion, The Einstein's journal paper citeeinstein and the Dirac's book citedirac are physics related items. Next, a citation about textitThe LaTeX Companion book citelatexcompanion.
medskip
printbibliography
enddocument
Render of MWE:
biblatex biber
add a comment |
up vote
9
down vote
favorite
I am trying to change the way that labels are generated. Some of it I already got working (only at maximum two authors, only last two digits of the year), but one thing does not seem to work, which is putting an ampersand between the authors if there are at least two.
In the manual on page 205 it is explained, that one can use special characters without escaping them as literals or padding, but what about the namessep field?
In the MWE I used 'X' in the place where an '&' should be placed, but I do not know how to do it.
I suspect, that since it is converted into the .bcf
file, which is XML, that the ampersand makes troubles there, so is this a bug?
Here is a MWE:
documentclassarticle
usepackage[utf8]inputenc
usepackage[english]babel
usepackagecsquotes
usepackagefilecontents
beginfilecontents*references.bib
@articleeinstein,
author = "Albert Einstein and Second Author",
title = "Zur Elektrodynamik bewegter K"orper. (German)
[On the electrodynamics of moving bodies]",
journal = "Annalen der Physik",
volume = "322",
number = "10",
pages = "891--921",
year = "1905",
DOI = "http://dx.doi.org/10.1002/andp.19053221004",
keywords = "physics"
@bookdirac,
title=The Principles of Quantum Mechanics,
author=Paul Adrien Maurice Dirac,
isbn=9780198520115,
series=International series of monographs on physics,
year=1981,
publisher=Clarendon Press,
keywords = physics
@booklatexcompanion,
author = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
title = "The LaTeX Companion",
year = "1993",
publisher = "Addison-Wesley",
address = "Reading, Massachusetts",
keywords = "latex"
endfilecontents*
usepackage[
backend=biber,
style=alphabetic,
citestyle=alphabetic,
maxcitenames=2,
mincitenames=2,
giveninits=true,
isbn=false,
]biblatex
renewcommand*labelalphaothers$^+$
DeclareLabelalphaTemplate
labelelement
field[final]shorthand
fieldlabel
field[names=2, namessep=addspaceXaddspace]labelname
labelelement
literaladdspace
labelelement
field[strside=right,strwidth=2]year
addbibresourcereferences.bib
begindocument
sectionFirst section
Items that are cited: textitThe LaTeX Companion book citelatexcompanion, The Einstein's journal paper citeeinstein and the Dirac's book citedirac are physics related items. Next, a citation about textitThe LaTeX Companion book citelatexcompanion.
medskip
printbibliography
enddocument
Render of MWE:
biblatex biber
add a comment |
up vote
9
down vote
favorite
up vote
9
down vote
favorite
I am trying to change the way that labels are generated. Some of it I already got working (only at maximum two authors, only last two digits of the year), but one thing does not seem to work, which is putting an ampersand between the authors if there are at least two.
In the manual on page 205 it is explained, that one can use special characters without escaping them as literals or padding, but what about the namessep field?
In the MWE I used 'X' in the place where an '&' should be placed, but I do not know how to do it.
I suspect, that since it is converted into the .bcf
file, which is XML, that the ampersand makes troubles there, so is this a bug?
Here is a MWE:
documentclassarticle
usepackage[utf8]inputenc
usepackage[english]babel
usepackagecsquotes
usepackagefilecontents
beginfilecontents*references.bib
@articleeinstein,
author = "Albert Einstein and Second Author",
title = "Zur Elektrodynamik bewegter K"orper. (German)
[On the electrodynamics of moving bodies]",
journal = "Annalen der Physik",
volume = "322",
number = "10",
pages = "891--921",
year = "1905",
DOI = "http://dx.doi.org/10.1002/andp.19053221004",
keywords = "physics"
@bookdirac,
title=The Principles of Quantum Mechanics,
author=Paul Adrien Maurice Dirac,
isbn=9780198520115,
series=International series of monographs on physics,
year=1981,
publisher=Clarendon Press,
keywords = physics
@booklatexcompanion,
author = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
title = "The LaTeX Companion",
year = "1993",
publisher = "Addison-Wesley",
address = "Reading, Massachusetts",
keywords = "latex"
endfilecontents*
usepackage[
backend=biber,
style=alphabetic,
citestyle=alphabetic,
maxcitenames=2,
mincitenames=2,
giveninits=true,
isbn=false,
]biblatex
renewcommand*labelalphaothers$^+$
DeclareLabelalphaTemplate
labelelement
field[final]shorthand
fieldlabel
field[names=2, namessep=addspaceXaddspace]labelname
labelelement
literaladdspace
labelelement
field[strside=right,strwidth=2]year
addbibresourcereferences.bib
begindocument
sectionFirst section
Items that are cited: textitThe LaTeX Companion book citelatexcompanion, The Einstein's journal paper citeeinstein and the Dirac's book citedirac are physics related items. Next, a citation about textitThe LaTeX Companion book citelatexcompanion.
medskip
printbibliography
enddocument
Render of MWE:
biblatex biber
I am trying to change the way that labels are generated. Some of it I already got working (only at maximum two authors, only last two digits of the year), but one thing does not seem to work, which is putting an ampersand between the authors if there are at least two.
In the manual on page 205 it is explained, that one can use special characters without escaping them as literals or padding, but what about the namessep field?
In the MWE I used 'X' in the place where an '&' should be placed, but I do not know how to do it.
I suspect, that since it is converted into the .bcf
file, which is XML, that the ampersand makes troubles there, so is this a bug?
Here is a MWE:
documentclassarticle
usepackage[utf8]inputenc
usepackage[english]babel
usepackagecsquotes
usepackagefilecontents
beginfilecontents*references.bib
@articleeinstein,
author = "Albert Einstein and Second Author",
title = "Zur Elektrodynamik bewegter K"orper. (German)
[On the electrodynamics of moving bodies]",
journal = "Annalen der Physik",
volume = "322",
number = "10",
pages = "891--921",
year = "1905",
DOI = "http://dx.doi.org/10.1002/andp.19053221004",
keywords = "physics"
@bookdirac,
title=The Principles of Quantum Mechanics,
author=Paul Adrien Maurice Dirac,
isbn=9780198520115,
series=International series of monographs on physics,
year=1981,
publisher=Clarendon Press,
keywords = physics
@booklatexcompanion,
author = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
title = "The LaTeX Companion",
year = "1993",
publisher = "Addison-Wesley",
address = "Reading, Massachusetts",
keywords = "latex"
endfilecontents*
usepackage[
backend=biber,
style=alphabetic,
citestyle=alphabetic,
maxcitenames=2,
mincitenames=2,
giveninits=true,
isbn=false,
]biblatex
renewcommand*labelalphaothers$^+$
DeclareLabelalphaTemplate
labelelement
field[final]shorthand
fieldlabel
field[names=2, namessep=addspaceXaddspace]labelname
labelelement
literaladdspace
labelelement
field[strside=right,strwidth=2]year
addbibresourcereferences.bib
begindocument
sectionFirst section
Items that are cited: textitThe LaTeX Companion book citelatexcompanion, The Einstein's journal paper citeeinstein and the Dirac's book citedirac are physics related items. Next, a citation about textitThe LaTeX Companion book citelatexcompanion.
medskip
printbibliography
enddocument
Render of MWE:
biblatex biber
biblatex biber
edited Nov 10 at 20:04
asked Nov 10 at 18:53
H. Rosendahl
936
936
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
up vote
6
down vote
accepted
Hide the ampersand in a command (&
is not good enough because the command name contains an ampersand, which still throws the XML off) and use detokenize
to make sure the macro does not get expanded when it is written to the .bcf
.
detokenize
can often be a cheap work-around if biblatex
options that may contain printable data explode. Often that happens because the value of the option needs to be written to the .bcf
file, so Biber can consume its value. LaTeX usually performs full expansion when text is written to a file, so things may go wrong if the desired value is not expandable or (as in this case) expands to problematic text. detokenize
stops this unwanted expansion. When the value is then picked up from the .bbl
file, the tokens will be interpreted as usual and the output will be as expected.
The quoted passage on page 205 of the manual only applies to padchar
and literal
, the value of namessep
needs escaping for special characters in both LaTeX and XML.
documentclassarticle
usepackage[utf8]inputenc
usepackage[english]babel
usepackagecsquotes
usepackage[backend=biber,style=alphabetic,maxcitenames=2,mincitenames=2,giveninits=true,isbn=false,]biblatex
renewcommand*labelalphaotherstextsuperscript+
newcommand*ampersand&
DeclareLabelalphaTemplate
labelelement
field[final]shorthand
fieldlabel
field[names=2, namessep=detokenizeaddspaceampersandspace]labelname
labelelement
literaladdspace
labelelement
field[strside=right,strwidth=2]year
addbibresourcebiblatex-examples.bib
begindocument
citecompanion,sigfridsson,worman
printbibliography
enddocument
I'm not a big fan of abusing alphabetic
to obtain what is essentially a full-blown author-year style with square brackets and the labels in the bibliography, but because it is a bit tricky to get only the last two digits of the year and retain uniqueness features I can't offer a simple implementation of the exact same style with style=authoryear
, but
documentclassarticle
usepackage[utf8]inputenc
usepackage[english]babel
usepackagecsquotes
usepackage[backend=biber,style=ext-authoryear,
introcite=label,
autocite=inline,
maxcitenames=2,mincitenames=1,giveninits=true,uniquename=init,
isbn=false]biblatex
DeclareOuterCiteDelimsparencitebibopenbracketbibclosebracket
DeclareFieldFormatbbx@introcitemkbibbrackets#1
DeclareDelimFormatfinalnamedelimaddspace&space
DeclareDelimFormat[bib]finalnamedelim%
ifnumgreatervalueliststop2finalandcomma%
addspacebibstringandspace
addbibresourcebiblatex-examples.bib
begindocument
autocitecompanion,sigfridsson,worman
printbibliography
enddocument
could be a start.
The 'two-column' layout of the alphabetic
style that automatically allocates enough space for each label to not run into the entry data may seem preferable, but if you cite a work by Helena Bonham Carter and Ralph Vaughn Williams, you will soon notice that the space left for the actual entry data becomes painfully narrow and does not allow for good line breaks any more.
Thanks! This explains nicely why it fails and what to do to correct it.
– H. Rosendahl
Nov 11 at 7:38
add a comment |
up vote
3
down vote
newcommand*ambr&
didn't work for me. newrobustcmdambr&
worked.
documentclassarticle
usepackage[utf8]inputenc
usepackage[english]babel
usepackagecsquotes
usepackagefilecontents
usepackage[
backend=biber,
style=alphabetic,
citestyle=alphabetic,
maxcitenames=2,
mincitenames=2,
giveninits=true,
isbn=false,
]biblatex
beginfilecontents*references.bib
@articleeinstein,
author = "Albert Einstein and Second Author",
title = "Zur Elektrodynamik bewegter K"orper. (German)
[On the electrodynamics of moving bodies]",
journal = "Annalen der Physik",
volume = "322",
number = "10",
pages = "891--921",
year = "1905",
DOI = "http://dx.doi.org/10.1002/andp.19053221004",
keywords = "physics"
@bookdirac,
title=The Principles of Quantum Mechanics,
author=Paul Adrien Maurice Dirac,
isbn=9780198520115,
series=International series of monographs on physics,
year=1981,
publisher=Clarendon Press,
keywords = physics
@booklatexcompanion,
author = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
title = "The LaTeX Companion",
year = "1993",
publisher = "Addison-Wesley",
address = "Reading, Massachusetts",
keywords = "latex"
endfilecontents*
renewcommand*labelalphaothers$^+$
%newcommand*ambr&
newrobustcmdambr&
DeclareLabelalphaTemplate
labelelement
field[final]shorthand
fieldlabel
field[names=2, namessep=addspaceambraddspace]labelname
labelelement
literaladdspace
labelelement
field[strside=right,strwidth=2]year
addbibresourcereferences.bib
begindocument
sectionFirst section
Items that are cited: textitThe LaTeX Companion book citelatexcompanion, The Einstein's journal paper citeeinstein and the Dirac's book citedirac are physics related items. Next, a citation about textitThe LaTeX Companion book citelatexcompanion.
medskip
printbibliography
enddocument
1
That's why I had thedetokenize
as well, you need to make sure that the ampersand does not expand when it is written to the.bcf
. A robust command as you used it would be the other possibility.
– moewe
Nov 10 at 22:29
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "85"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f459362%2fampersand-as-namessep-in-biblatex-label%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
6
down vote
accepted
Hide the ampersand in a command (&
is not good enough because the command name contains an ampersand, which still throws the XML off) and use detokenize
to make sure the macro does not get expanded when it is written to the .bcf
.
detokenize
can often be a cheap work-around if biblatex
options that may contain printable data explode. Often that happens because the value of the option needs to be written to the .bcf
file, so Biber can consume its value. LaTeX usually performs full expansion when text is written to a file, so things may go wrong if the desired value is not expandable or (as in this case) expands to problematic text. detokenize
stops this unwanted expansion. When the value is then picked up from the .bbl
file, the tokens will be interpreted as usual and the output will be as expected.
The quoted passage on page 205 of the manual only applies to padchar
and literal
, the value of namessep
needs escaping for special characters in both LaTeX and XML.
documentclassarticle
usepackage[utf8]inputenc
usepackage[english]babel
usepackagecsquotes
usepackage[backend=biber,style=alphabetic,maxcitenames=2,mincitenames=2,giveninits=true,isbn=false,]biblatex
renewcommand*labelalphaotherstextsuperscript+
newcommand*ampersand&
DeclareLabelalphaTemplate
labelelement
field[final]shorthand
fieldlabel
field[names=2, namessep=detokenizeaddspaceampersandspace]labelname
labelelement
literaladdspace
labelelement
field[strside=right,strwidth=2]year
addbibresourcebiblatex-examples.bib
begindocument
citecompanion,sigfridsson,worman
printbibliography
enddocument
I'm not a big fan of abusing alphabetic
to obtain what is essentially a full-blown author-year style with square brackets and the labels in the bibliography, but because it is a bit tricky to get only the last two digits of the year and retain uniqueness features I can't offer a simple implementation of the exact same style with style=authoryear
, but
documentclassarticle
usepackage[utf8]inputenc
usepackage[english]babel
usepackagecsquotes
usepackage[backend=biber,style=ext-authoryear,
introcite=label,
autocite=inline,
maxcitenames=2,mincitenames=1,giveninits=true,uniquename=init,
isbn=false]biblatex
DeclareOuterCiteDelimsparencitebibopenbracketbibclosebracket
DeclareFieldFormatbbx@introcitemkbibbrackets#1
DeclareDelimFormatfinalnamedelimaddspace&space
DeclareDelimFormat[bib]finalnamedelim%
ifnumgreatervalueliststop2finalandcomma%
addspacebibstringandspace
addbibresourcebiblatex-examples.bib
begindocument
autocitecompanion,sigfridsson,worman
printbibliography
enddocument
could be a start.
The 'two-column' layout of the alphabetic
style that automatically allocates enough space for each label to not run into the entry data may seem preferable, but if you cite a work by Helena Bonham Carter and Ralph Vaughn Williams, you will soon notice that the space left for the actual entry data becomes painfully narrow and does not allow for good line breaks any more.
Thanks! This explains nicely why it fails and what to do to correct it.
– H. Rosendahl
Nov 11 at 7:38
add a comment |
up vote
6
down vote
accepted
Hide the ampersand in a command (&
is not good enough because the command name contains an ampersand, which still throws the XML off) and use detokenize
to make sure the macro does not get expanded when it is written to the .bcf
.
detokenize
can often be a cheap work-around if biblatex
options that may contain printable data explode. Often that happens because the value of the option needs to be written to the .bcf
file, so Biber can consume its value. LaTeX usually performs full expansion when text is written to a file, so things may go wrong if the desired value is not expandable or (as in this case) expands to problematic text. detokenize
stops this unwanted expansion. When the value is then picked up from the .bbl
file, the tokens will be interpreted as usual and the output will be as expected.
The quoted passage on page 205 of the manual only applies to padchar
and literal
, the value of namessep
needs escaping for special characters in both LaTeX and XML.
documentclassarticle
usepackage[utf8]inputenc
usepackage[english]babel
usepackagecsquotes
usepackage[backend=biber,style=alphabetic,maxcitenames=2,mincitenames=2,giveninits=true,isbn=false,]biblatex
renewcommand*labelalphaotherstextsuperscript+
newcommand*ampersand&
DeclareLabelalphaTemplate
labelelement
field[final]shorthand
fieldlabel
field[names=2, namessep=detokenizeaddspaceampersandspace]labelname
labelelement
literaladdspace
labelelement
field[strside=right,strwidth=2]year
addbibresourcebiblatex-examples.bib
begindocument
citecompanion,sigfridsson,worman
printbibliography
enddocument
I'm not a big fan of abusing alphabetic
to obtain what is essentially a full-blown author-year style with square brackets and the labels in the bibliography, but because it is a bit tricky to get only the last two digits of the year and retain uniqueness features I can't offer a simple implementation of the exact same style with style=authoryear
, but
documentclassarticle
usepackage[utf8]inputenc
usepackage[english]babel
usepackagecsquotes
usepackage[backend=biber,style=ext-authoryear,
introcite=label,
autocite=inline,
maxcitenames=2,mincitenames=1,giveninits=true,uniquename=init,
isbn=false]biblatex
DeclareOuterCiteDelimsparencitebibopenbracketbibclosebracket
DeclareFieldFormatbbx@introcitemkbibbrackets#1
DeclareDelimFormatfinalnamedelimaddspace&space
DeclareDelimFormat[bib]finalnamedelim%
ifnumgreatervalueliststop2finalandcomma%
addspacebibstringandspace
addbibresourcebiblatex-examples.bib
begindocument
autocitecompanion,sigfridsson,worman
printbibliography
enddocument
could be a start.
The 'two-column' layout of the alphabetic
style that automatically allocates enough space for each label to not run into the entry data may seem preferable, but if you cite a work by Helena Bonham Carter and Ralph Vaughn Williams, you will soon notice that the space left for the actual entry data becomes painfully narrow and does not allow for good line breaks any more.
Thanks! This explains nicely why it fails and what to do to correct it.
– H. Rosendahl
Nov 11 at 7:38
add a comment |
up vote
6
down vote
accepted
up vote
6
down vote
accepted
Hide the ampersand in a command (&
is not good enough because the command name contains an ampersand, which still throws the XML off) and use detokenize
to make sure the macro does not get expanded when it is written to the .bcf
.
detokenize
can often be a cheap work-around if biblatex
options that may contain printable data explode. Often that happens because the value of the option needs to be written to the .bcf
file, so Biber can consume its value. LaTeX usually performs full expansion when text is written to a file, so things may go wrong if the desired value is not expandable or (as in this case) expands to problematic text. detokenize
stops this unwanted expansion. When the value is then picked up from the .bbl
file, the tokens will be interpreted as usual and the output will be as expected.
The quoted passage on page 205 of the manual only applies to padchar
and literal
, the value of namessep
needs escaping for special characters in both LaTeX and XML.
documentclassarticle
usepackage[utf8]inputenc
usepackage[english]babel
usepackagecsquotes
usepackage[backend=biber,style=alphabetic,maxcitenames=2,mincitenames=2,giveninits=true,isbn=false,]biblatex
renewcommand*labelalphaotherstextsuperscript+
newcommand*ampersand&
DeclareLabelalphaTemplate
labelelement
field[final]shorthand
fieldlabel
field[names=2, namessep=detokenizeaddspaceampersandspace]labelname
labelelement
literaladdspace
labelelement
field[strside=right,strwidth=2]year
addbibresourcebiblatex-examples.bib
begindocument
citecompanion,sigfridsson,worman
printbibliography
enddocument
I'm not a big fan of abusing alphabetic
to obtain what is essentially a full-blown author-year style with square brackets and the labels in the bibliography, but because it is a bit tricky to get only the last two digits of the year and retain uniqueness features I can't offer a simple implementation of the exact same style with style=authoryear
, but
documentclassarticle
usepackage[utf8]inputenc
usepackage[english]babel
usepackagecsquotes
usepackage[backend=biber,style=ext-authoryear,
introcite=label,
autocite=inline,
maxcitenames=2,mincitenames=1,giveninits=true,uniquename=init,
isbn=false]biblatex
DeclareOuterCiteDelimsparencitebibopenbracketbibclosebracket
DeclareFieldFormatbbx@introcitemkbibbrackets#1
DeclareDelimFormatfinalnamedelimaddspace&space
DeclareDelimFormat[bib]finalnamedelim%
ifnumgreatervalueliststop2finalandcomma%
addspacebibstringandspace
addbibresourcebiblatex-examples.bib
begindocument
autocitecompanion,sigfridsson,worman
printbibliography
enddocument
could be a start.
The 'two-column' layout of the alphabetic
style that automatically allocates enough space for each label to not run into the entry data may seem preferable, but if you cite a work by Helena Bonham Carter and Ralph Vaughn Williams, you will soon notice that the space left for the actual entry data becomes painfully narrow and does not allow for good line breaks any more.
Hide the ampersand in a command (&
is not good enough because the command name contains an ampersand, which still throws the XML off) and use detokenize
to make sure the macro does not get expanded when it is written to the .bcf
.
detokenize
can often be a cheap work-around if biblatex
options that may contain printable data explode. Often that happens because the value of the option needs to be written to the .bcf
file, so Biber can consume its value. LaTeX usually performs full expansion when text is written to a file, so things may go wrong if the desired value is not expandable or (as in this case) expands to problematic text. detokenize
stops this unwanted expansion. When the value is then picked up from the .bbl
file, the tokens will be interpreted as usual and the output will be as expected.
The quoted passage on page 205 of the manual only applies to padchar
and literal
, the value of namessep
needs escaping for special characters in both LaTeX and XML.
documentclassarticle
usepackage[utf8]inputenc
usepackage[english]babel
usepackagecsquotes
usepackage[backend=biber,style=alphabetic,maxcitenames=2,mincitenames=2,giveninits=true,isbn=false,]biblatex
renewcommand*labelalphaotherstextsuperscript+
newcommand*ampersand&
DeclareLabelalphaTemplate
labelelement
field[final]shorthand
fieldlabel
field[names=2, namessep=detokenizeaddspaceampersandspace]labelname
labelelement
literaladdspace
labelelement
field[strside=right,strwidth=2]year
addbibresourcebiblatex-examples.bib
begindocument
citecompanion,sigfridsson,worman
printbibliography
enddocument
I'm not a big fan of abusing alphabetic
to obtain what is essentially a full-blown author-year style with square brackets and the labels in the bibliography, but because it is a bit tricky to get only the last two digits of the year and retain uniqueness features I can't offer a simple implementation of the exact same style with style=authoryear
, but
documentclassarticle
usepackage[utf8]inputenc
usepackage[english]babel
usepackagecsquotes
usepackage[backend=biber,style=ext-authoryear,
introcite=label,
autocite=inline,
maxcitenames=2,mincitenames=1,giveninits=true,uniquename=init,
isbn=false]biblatex
DeclareOuterCiteDelimsparencitebibopenbracketbibclosebracket
DeclareFieldFormatbbx@introcitemkbibbrackets#1
DeclareDelimFormatfinalnamedelimaddspace&space
DeclareDelimFormat[bib]finalnamedelim%
ifnumgreatervalueliststop2finalandcomma%
addspacebibstringandspace
addbibresourcebiblatex-examples.bib
begindocument
autocitecompanion,sigfridsson,worman
printbibliography
enddocument
could be a start.
The 'two-column' layout of the alphabetic
style that automatically allocates enough space for each label to not run into the entry data may seem preferable, but if you cite a work by Helena Bonham Carter and Ralph Vaughn Williams, you will soon notice that the space left for the actual entry data becomes painfully narrow and does not allow for good line breaks any more.
edited Nov 11 at 11:16
answered Nov 10 at 21:37
moewe
85k9108327
85k9108327
Thanks! This explains nicely why it fails and what to do to correct it.
– H. Rosendahl
Nov 11 at 7:38
add a comment |
Thanks! This explains nicely why it fails and what to do to correct it.
– H. Rosendahl
Nov 11 at 7:38
Thanks! This explains nicely why it fails and what to do to correct it.
– H. Rosendahl
Nov 11 at 7:38
Thanks! This explains nicely why it fails and what to do to correct it.
– H. Rosendahl
Nov 11 at 7:38
add a comment |
up vote
3
down vote
newcommand*ambr&
didn't work for me. newrobustcmdambr&
worked.
documentclassarticle
usepackage[utf8]inputenc
usepackage[english]babel
usepackagecsquotes
usepackagefilecontents
usepackage[
backend=biber,
style=alphabetic,
citestyle=alphabetic,
maxcitenames=2,
mincitenames=2,
giveninits=true,
isbn=false,
]biblatex
beginfilecontents*references.bib
@articleeinstein,
author = "Albert Einstein and Second Author",
title = "Zur Elektrodynamik bewegter K"orper. (German)
[On the electrodynamics of moving bodies]",
journal = "Annalen der Physik",
volume = "322",
number = "10",
pages = "891--921",
year = "1905",
DOI = "http://dx.doi.org/10.1002/andp.19053221004",
keywords = "physics"
@bookdirac,
title=The Principles of Quantum Mechanics,
author=Paul Adrien Maurice Dirac,
isbn=9780198520115,
series=International series of monographs on physics,
year=1981,
publisher=Clarendon Press,
keywords = physics
@booklatexcompanion,
author = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
title = "The LaTeX Companion",
year = "1993",
publisher = "Addison-Wesley",
address = "Reading, Massachusetts",
keywords = "latex"
endfilecontents*
renewcommand*labelalphaothers$^+$
%newcommand*ambr&
newrobustcmdambr&
DeclareLabelalphaTemplate
labelelement
field[final]shorthand
fieldlabel
field[names=2, namessep=addspaceambraddspace]labelname
labelelement
literaladdspace
labelelement
field[strside=right,strwidth=2]year
addbibresourcereferences.bib
begindocument
sectionFirst section
Items that are cited: textitThe LaTeX Companion book citelatexcompanion, The Einstein's journal paper citeeinstein and the Dirac's book citedirac are physics related items. Next, a citation about textitThe LaTeX Companion book citelatexcompanion.
medskip
printbibliography
enddocument
1
That's why I had thedetokenize
as well, you need to make sure that the ampersand does not expand when it is written to the.bcf
. A robust command as you used it would be the other possibility.
– moewe
Nov 10 at 22:29
add a comment |
up vote
3
down vote
newcommand*ambr&
didn't work for me. newrobustcmdambr&
worked.
documentclassarticle
usepackage[utf8]inputenc
usepackage[english]babel
usepackagecsquotes
usepackagefilecontents
usepackage[
backend=biber,
style=alphabetic,
citestyle=alphabetic,
maxcitenames=2,
mincitenames=2,
giveninits=true,
isbn=false,
]biblatex
beginfilecontents*references.bib
@articleeinstein,
author = "Albert Einstein and Second Author",
title = "Zur Elektrodynamik bewegter K"orper. (German)
[On the electrodynamics of moving bodies]",
journal = "Annalen der Physik",
volume = "322",
number = "10",
pages = "891--921",
year = "1905",
DOI = "http://dx.doi.org/10.1002/andp.19053221004",
keywords = "physics"
@bookdirac,
title=The Principles of Quantum Mechanics,
author=Paul Adrien Maurice Dirac,
isbn=9780198520115,
series=International series of monographs on physics,
year=1981,
publisher=Clarendon Press,
keywords = physics
@booklatexcompanion,
author = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
title = "The LaTeX Companion",
year = "1993",
publisher = "Addison-Wesley",
address = "Reading, Massachusetts",
keywords = "latex"
endfilecontents*
renewcommand*labelalphaothers$^+$
%newcommand*ambr&
newrobustcmdambr&
DeclareLabelalphaTemplate
labelelement
field[final]shorthand
fieldlabel
field[names=2, namessep=addspaceambraddspace]labelname
labelelement
literaladdspace
labelelement
field[strside=right,strwidth=2]year
addbibresourcereferences.bib
begindocument
sectionFirst section
Items that are cited: textitThe LaTeX Companion book citelatexcompanion, The Einstein's journal paper citeeinstein and the Dirac's book citedirac are physics related items. Next, a citation about textitThe LaTeX Companion book citelatexcompanion.
medskip
printbibliography
enddocument
1
That's why I had thedetokenize
as well, you need to make sure that the ampersand does not expand when it is written to the.bcf
. A robust command as you used it would be the other possibility.
– moewe
Nov 10 at 22:29
add a comment |
up vote
3
down vote
up vote
3
down vote
newcommand*ambr&
didn't work for me. newrobustcmdambr&
worked.
documentclassarticle
usepackage[utf8]inputenc
usepackage[english]babel
usepackagecsquotes
usepackagefilecontents
usepackage[
backend=biber,
style=alphabetic,
citestyle=alphabetic,
maxcitenames=2,
mincitenames=2,
giveninits=true,
isbn=false,
]biblatex
beginfilecontents*references.bib
@articleeinstein,
author = "Albert Einstein and Second Author",
title = "Zur Elektrodynamik bewegter K"orper. (German)
[On the electrodynamics of moving bodies]",
journal = "Annalen der Physik",
volume = "322",
number = "10",
pages = "891--921",
year = "1905",
DOI = "http://dx.doi.org/10.1002/andp.19053221004",
keywords = "physics"
@bookdirac,
title=The Principles of Quantum Mechanics,
author=Paul Adrien Maurice Dirac,
isbn=9780198520115,
series=International series of monographs on physics,
year=1981,
publisher=Clarendon Press,
keywords = physics
@booklatexcompanion,
author = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
title = "The LaTeX Companion",
year = "1993",
publisher = "Addison-Wesley",
address = "Reading, Massachusetts",
keywords = "latex"
endfilecontents*
renewcommand*labelalphaothers$^+$
%newcommand*ambr&
newrobustcmdambr&
DeclareLabelalphaTemplate
labelelement
field[final]shorthand
fieldlabel
field[names=2, namessep=addspaceambraddspace]labelname
labelelement
literaladdspace
labelelement
field[strside=right,strwidth=2]year
addbibresourcereferences.bib
begindocument
sectionFirst section
Items that are cited: textitThe LaTeX Companion book citelatexcompanion, The Einstein's journal paper citeeinstein and the Dirac's book citedirac are physics related items. Next, a citation about textitThe LaTeX Companion book citelatexcompanion.
medskip
printbibliography
enddocument
newcommand*ambr&
didn't work for me. newrobustcmdambr&
worked.
documentclassarticle
usepackage[utf8]inputenc
usepackage[english]babel
usepackagecsquotes
usepackagefilecontents
usepackage[
backend=biber,
style=alphabetic,
citestyle=alphabetic,
maxcitenames=2,
mincitenames=2,
giveninits=true,
isbn=false,
]biblatex
beginfilecontents*references.bib
@articleeinstein,
author = "Albert Einstein and Second Author",
title = "Zur Elektrodynamik bewegter K"orper. (German)
[On the electrodynamics of moving bodies]",
journal = "Annalen der Physik",
volume = "322",
number = "10",
pages = "891--921",
year = "1905",
DOI = "http://dx.doi.org/10.1002/andp.19053221004",
keywords = "physics"
@bookdirac,
title=The Principles of Quantum Mechanics,
author=Paul Adrien Maurice Dirac,
isbn=9780198520115,
series=International series of monographs on physics,
year=1981,
publisher=Clarendon Press,
keywords = physics
@booklatexcompanion,
author = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
title = "The LaTeX Companion",
year = "1993",
publisher = "Addison-Wesley",
address = "Reading, Massachusetts",
keywords = "latex"
endfilecontents*
renewcommand*labelalphaothers$^+$
%newcommand*ambr&
newrobustcmdambr&
DeclareLabelalphaTemplate
labelelement
field[final]shorthand
fieldlabel
field[names=2, namessep=addspaceambraddspace]labelname
labelelement
literaladdspace
labelelement
field[strside=right,strwidth=2]year
addbibresourcereferences.bib
begindocument
sectionFirst section
Items that are cited: textitThe LaTeX Companion book citelatexcompanion, The Einstein's journal paper citeeinstein and the Dirac's book citedirac are physics related items. Next, a citation about textitThe LaTeX Companion book citelatexcompanion.
medskip
printbibliography
enddocument
answered Nov 10 at 22:24
nidhin
3,324927
3,324927
1
That's why I had thedetokenize
as well, you need to make sure that the ampersand does not expand when it is written to the.bcf
. A robust command as you used it would be the other possibility.
– moewe
Nov 10 at 22:29
add a comment |
1
That's why I had thedetokenize
as well, you need to make sure that the ampersand does not expand when it is written to the.bcf
. A robust command as you used it would be the other possibility.
– moewe
Nov 10 at 22:29
1
1
That's why I had the
detokenize
as well, you need to make sure that the ampersand does not expand when it is written to the .bcf
. A robust command as you used it would be the other possibility.– moewe
Nov 10 at 22:29
That's why I had the
detokenize
as well, you need to make sure that the ampersand does not expand when it is written to the .bcf
. A robust command as you used it would be the other possibility.– moewe
Nov 10 at 22:29
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f459362%2fampersand-as-namessep-in-biblatex-label%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown