Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

With biblatex is very convenient to write something like this:

\documentclass{article}
\usepackage{biblatex}
\addbibresource{biblatex-examples.bib}
\begin{document}
\ldots as presented by \textcite{shore,yoon,cicero}
\end{document}

Then biblatex will automatically render this to:

...as presented by Shore [2], Yoon et al. [3], and Cicero [1]

Sometime it would be helpful to not use and as conjunction but or. Is that possible?

BTW: Why is there no comma when there are only two items in \textcite{foo,bar}? When there are two authors and maxcitenames=2 this is rendered to:

"..as presented by Foo and Bar [1] and Bar and Foo [2]"

Possible duplicates:

This question is related to biblatex: Tighter integration of \textcite "in the flow of text", where this question was actually a comment, but as the comment trail was too long already I was asked to make a new question, so here it is.

Also the question might seem related to Change citation conjunction from "and" to "i" but this is asking for different conjunctions within a single bibkey connecting authors.

share|improve this question
    
Can you give an actual example in which or is more suited than and? I can't think of any... –  Jubobs Feb 26 at 9:20
1  
In response to your BTW: the Oxford comma applies ONLY in a series of three or more terms. –  karlkoeller Feb 26 at 9:24
    
@Jubobs, I want to make it more clear that the literture list not complete with "or". When using "and" it sounds more like a complete list. –  math Feb 26 at 13:04
    
@math I understand, but using "or" is dangerous because it can be misinterpreted as an exclusive "or". If you really want to convey the fact that the list of references is not exhaustive, you could write as presented by Shore [2], Yoon et al. [3], and Cicero [1], among others, or something like that. –  Jubobs Feb 26 at 13:21
add comment

2 Answers

up vote 7 down vote accepted

To make use of biblatex's localisation capabilities we can define a new bibliography string or.

\NewBibliographyString{or}
\DefineBibliographyStrings{english}{%
  or = {or},
}
\DefineBibliographyStrings{german}{%
  or = {oder},
}

We can then define a new command that will change the "and" in \textcite to an "or".

\newcommand{\useor}{%
  \renewcommand*{\textcitedelim}{%
    \iffinalcitedelim
      {\ifnumgreater{\value{textcitetotal}}{2}
       {\iftextcitepunct{\finalandsemicolon}{\finalandcomma}}{}%
      \addspace\bibstring{or}}% here was \bibstring{and} before
      {\iftextcitepunct{\addsemicolon}{\addcomma}}%
    \space}%
}

The \textcite commands can then very easily be patched to use "or" instead of "and" by adding \useor to the wrapper command.

For numeric and friends that would be

\makeatletter
\DeclareCiteCommand{\textciteor}[\useor\cbx@textcite@init\cbx@textcite]
  {\gdef\cbx@savedkeys{}%
   \citetrackerfalse%
   \pagetrackerfalse%
   \DeferNextCitekeyHook%
   \usebibmacro{textcite:init}}
  {\ifthenelse{\iffirstcitekey\AND\value{multicitetotal}>0}
     {\protected@xappto\cbx@savedcites{()(\thefield{multipostnote})}%
      \global\clearfield{multipostnote}}
     {}%
   \xappto\cbx@savedkeys{\thefield{entrykey},}%
   \iffieldequals{namehash}{\cbx@lasthash}
     {}
     {\stepcounter{textcitetotal}%
      \savefield{namehash}{\cbx@lasthash}}}
  {}
  {\protected@xappto\cbx@savedcites{%
     [\thefield{prenote}][\thefield{postnote}]{\cbx@savedkeys}}}
\makeatother

For authortitle/authoryear you would use

\DeclareCiteCommand{\textciteor}[\useor]
  {\boolfalse{cbx:parens}}
  {\usebibmacro{citeindex}%
   \iffirstcitekey
     {\setcounter{textcitetotal}{1}}
     {\stepcounter{textcitetotal}%
      \textcitedelim}%
   \usebibmacro{textcite}}
  {\ifbool{cbx:parens}
     {\bibcloseparen\global\boolfalse{cbx:parens}}
     {}}
  {\usebibmacro{textcite:postnote}}

Look up the \DeclareCiteCommand{\textcite} in your .cbx file, copy the definition, change the name to \textciteor and add \useor to the wrapper command (that is the portion in square brackets just after \DeclareCiteCommand{\textciteor}, create this optional argument if its not there already).

MWE

\documentclass{article}
\usepackage{biblatex}
\addbibresource{biblatex-examples.bib}

\NewBibliographyString{or}
\DefineBibliographyStrings{english}{%
  or = {or},
}
\DefineBibliographyStrings{german}{%
  or = {oder},
}

\newcommand{\useor}{%
  \renewcommand*{\textcitedelim}{%
    \iffinalcitedelim
      {\ifnumgreater{\value{textcitetotal}}{2}
       {\iftextcitepunct{\finalandsemicolon}{\finalandcomma}}{}%
      \addspace\bibstring{or}}
      {\iftextcitepunct{\addsemicolon}{\addcomma}}%
    \space}%
}

\makeatletter
\DeclareCiteCommand{\textciteor}[\useor\cbx@textcite@init\cbx@textcite]
  {\gdef\cbx@savedkeys{}%
   \citetrackerfalse%
   \pagetrackerfalse%
   \DeferNextCitekeyHook%
   \usebibmacro{textcite:init}}
  {\ifthenelse{\iffirstcitekey\AND\value{multicitetotal}>0}
     {\protected@xappto\cbx@savedcites{()(\thefield{multipostnote})}%
      \global\clearfield{multipostnote}}
     {}%
   \xappto\cbx@savedkeys{\thefield{entrykey},}%
   \iffieldequals{namehash}{\cbx@lasthash}
     {}
     {\stepcounter{textcitetotal}%
      \savefield{namehash}{\cbx@lasthash}}}
  {}
  {\protected@xappto\cbx@savedcites{%
     [\thefield{prenote}][\thefield{postnote}]{\cbx@savedkeys}}}
\makeatother

\begin{document}
\ldots as presented by \textcite{shore,yoon,cicero,baez/article}.

\ldots as presented by \textciteor{shore,yoon,cicero,baez/article}.

Just to test \textcite{shore,yoon,cicero,baez/article}.
\end{document}

enter image description here


Of course you can also hook \useor into \AtNextCite:

Just to test \textcite{shore,yoon,cicero,baez/article}.
Just to test \AtNextCite{\useor}\textcite{shore,yoon,cicero,baez/article}.
Just to test \textcite{shore,yoon,cicero,baez/article}.

And then define

\newrobustcmd*{\textciteor}{\AtNextCite{\useor}\textcite}

thanks to @Audrey for that solution.


Regarding your BTW: biblatex only uses the Oxford/serial comma for list with more than two items.

The standard definitions are:

\newcommand*{\finalnamedelim}{%
  \ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
  \addspace\bibstring{and}\space}

\newcommand*{\finallistdelim}{%
  \ifnumgreater{\value{liststop}}{2}{\finalandcomma}{}%
  \addspace\bibstring{and}\space}

\newcommand*{\textcitedelim}{%
  \iffinalcitedelim
    {\ifnumgreater{\value{textcitetotal}}{2}
       {\iftextcitepunct{\finalandsemicolon}{\finalandcomma}}{}%
     \addspace\bibstring{and}}
    {\iftextcitepunct{\addsemicolon}{\addcomma}}%
  \space}

One can of course force the \finalandcomma to appear always by

\renewcommand*{\finalnamedelim}{%
  \finalandcomma\addspace\bibstring{and}\space}

and the like.

share|improve this answer
    
Pretty sure the Oxford comma goes with “or” just as much as “and.” –  Luke Maurer Feb 26 at 10:00
    
@LukeMaurer I suppose you are right, I deleted the passage, as it was probably more confusing than helpful anyway. –  moewe Feb 26 at 10:10
1  
@moewe Just go with \newrobustcmd*{\textciteor}{\AtNextCite{\useor}\textcite}. BTW: Thanks a bunch for your posts here. –  Audrey Feb 27 at 0:32
add comment

You can define a new cite command \textciteor that does that.

The following code is required in the preamble:

\makeatletter
\DeclareCiteCommand{\cbx@textciteor}
  {\usebibmacro{textcite:init}}
  {\usebibmacro{citeindex}%
   \usebibmacro{textciteor}}
  {}
  {\usebibmacro{textcite:postnote}}
\DeclareCiteCommand{\textciteor}[\cbx@textcite@init\cbx@textciteor]
  {\gdef\cbx@savedkeys{}%
   \citetrackerfalse%
   \pagetrackerfalse%
   \DeferNextCitekeyHook%
   \usebibmacro{textcite:init}}
  {\ifthenelse{\iffirstcitekey\AND\value{multicitetotal}>0}
     {\protected@xappto\cbx@savedcites{()(\thefield{multipostnote})}%
      \global\clearfield{multipostnote}}
     {}%
   \xappto\cbx@savedkeys{\thefield{entrykey},}%
   \iffieldequals{namehash}{\cbx@lasthash}
     {}
     {\stepcounter{textcitetotal}%
      \savefield{namehash}{\cbx@lasthash}}}
  {}
  {\protected@xappto\cbx@savedcites{%
     [\thefield{prenote}][\thefield{postnote}]{\cbx@savedkeys}}}
\newbibmacro*{textciteor}{%
  \iffieldequals{namehash}{\cbx@lasthash}
    {\setunit{\multicitedelim}}
    {\ifnameundef{labelname}
       {\printfield[citetitle]{labeltitle}}
       {\printnames{labelname}}%
     \setunit{%
       \global\booltrue{cbx:parens}%
       \addspace\bibopenbracket}%
     \stepcounter{textcitecount}%
     \savefield{namehash}{\cbx@lasthash}}%
  \ifnumequal{\value{citecount}}{1}
    {\usebibmacro{prenote}}
    {}%
  \usebibmacro{cite}%
  \setunit{%
    \ifbool{cbx:parens}
      {\bibcloseparen\global\boolfalse{cbx:parens}}
      {}%
    \textciteordelim}}
\newcommand*{\textciteordelim}{%
  \iffinalcitedelim
    {\ifnumgreater{\value{textcitetotal}}{2}
       {\iftextcitepunct{\finalandsemicolon}{\finalandcomma}}{}%
     \addspace or}
    {\iftextcitepunct{\addsemicolon}{\addcomma}}%
  \space}
\makeatother

MWE

\documentclass{article}
\usepackage{biblatex}
\addbibresource{biblatex-examples.bib}

\makeatletter
\DeclareCiteCommand{\cbx@textciteor}
  {\usebibmacro{textcite:init}}
  {\usebibmacro{citeindex}%
   \usebibmacro{textciteor}}
  {}
  {\usebibmacro{textcite:postnote}}
\DeclareCiteCommand{\textciteor}[\cbx@textcite@init\cbx@textciteor]
  {\gdef\cbx@savedkeys{}%
   \citetrackerfalse%
   \pagetrackerfalse%
   \DeferNextCitekeyHook%
   \usebibmacro{textcite:init}}
  {\ifthenelse{\iffirstcitekey\AND\value{multicitetotal}>0}
     {\protected@xappto\cbx@savedcites{()(\thefield{multipostnote})}%
      \global\clearfield{multipostnote}}
     {}%
   \xappto\cbx@savedkeys{\thefield{entrykey},}%
   \iffieldequals{namehash}{\cbx@lasthash}
     {}
     {\stepcounter{textcitetotal}%
      \savefield{namehash}{\cbx@lasthash}}}
  {}
  {\protected@xappto\cbx@savedcites{%
     [\thefield{prenote}][\thefield{postnote}]{\cbx@savedkeys}}}
\newbibmacro*{textciteor}{%
  \iffieldequals{namehash}{\cbx@lasthash}
    {\setunit{\multicitedelim}}
    {\ifnameundef{labelname}
       {\printfield[citetitle]{labeltitle}}
       {\printnames{labelname}}%
     \setunit{%
       \global\booltrue{cbx:parens}%
       \addspace\bibopenbracket}%
     \stepcounter{textcitecount}%
     \savefield{namehash}{\cbx@lasthash}}%
  \ifnumequal{\value{citecount}}{1}
    {\usebibmacro{prenote}}
    {}%
  \usebibmacro{cite}%
  \setunit{%
    \ifbool{cbx:parens}
      {\bibcloseparen\global\boolfalse{cbx:parens}}
      {}%
    \textciteordelim}}
\newcommand*{\textciteordelim}{%
  \iffinalcitedelim
    {\ifnumgreater{\value{textcitetotal}}{2}
       {\iftextcitepunct{\finalandsemicolon}{\finalandcomma}}{}%
     \addspace or}
    {\iftextcitepunct{\addsemicolon}{\addcomma}}%
  \space}
\makeatother

\begin{document}
\ldots as presented by \textcite{shore,yoon,cicero}

\ldots as presented by \textciteor{shore,yoon,cicero}
\end{document} 

Output

enter image description here

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.