2

Update: I can get the result I want by doing this:

\newcommand*{\textapud}[2]{\citeauthor{#1} (\citeyear{#1} apud \citeauthor{#2}, \citeyear{#2})}

But there are a few problems. First of all it doesn't look very nice and I think I could do better. Second of all I can't specify a prenote and a postnote for each of the two entries (I think there might be a way to add that possibility to this command, but I couldn't get it to work yet). And lastly, I can't use the bibstring command – the "apud" text is hardcoded there.


My question is similar to this one, except I want to put only part of the citation in parenthesis.


I'm trying to write a biblatex style and citations should be like

"this" (DOE, 2015)

or, when citing the author in the middle of the text, like this:

according to BLOW (2016).

So far so good, I managed to do that. Then, when citing one author based on another author, it has to be like

"this" (DOE, 2015 apud BLOW, 2016).

Based on moewe's answer to the question I mentioned above, I managed to do that too (my code is in the MWE below), but now I need the version for doing it in the middle of the text, like this:

according to DOE (2015 apud BLOW, 2016).

And I don't have a clue how to do that. Any ideas?


\begin{filecontents}{\jobname.bib}
@abook{doe,
    author = {John Doe},
    year = {2015}}
@article{blow,
    author = {Joe Blow},
    year = {2016}}
@article{smith,
    author = {Jim Smith},
    year = {2016}}
\end{filecontents}

\documentclass{article}

\usepackage[backend=biber, style=authoryear]{biblatex}
\addbibresource{\jobname.bib}

\renewcommand*{\nameyeardelim}{\addcomma\addspace}

\newcommand{\addapud}{%
  \renewcommand*{\multicitedelim}{%
    \ifnumequal{\value{multicitecount}}{\value{multicitetotal}}
      {\space\bibstring{apud}}
      {\addsemicolon}%
    \space}%
  \renewcommand*{\textcitedelim}{%
    \ifnumequal{\value{multicitecount}}{\value{multicitetotal}}
      {\addspace\bibstring{apud}}
      {\addsemicolon}%
    \space}%
}

\DeclareMultiCiteCommand{\apud}[\addapud\mkbibparens]
    {\@apud}
    {\setunit{\multicitedelim}}

% This is to allow that second option down there
% in which the first author isn't in the .bib file.
\DeclareCiteCommand{\@apud}
    {\iffieldundef{prenote}
        {}
        {\printfield[uppercase]{prenote}
        \addspace\bibstring{apud}\addspace}}
    {\usebibmacro{citeindex}%
    \usebibmacro{cite}}
    {\setunit{\multicitedelim}}
    {\usebibmacro{postnote}}

% \DeclareMultiCiteCommand{\textapud}% HOW??

\begin{document}

  \apud{doe}{blow}{smith}

  \apud[Batman][]{smith}

\end{document}

PS: I didn't add the bibstring or the code to make names and fields uppercase because I thought it wasn't relevant.

PS2: The command doesn't have to account for the possibility of more than two authors, like the regular \apud does.

  • @cfr Ah, It's the first thing I said in my question, but I guess it wasn't clear enough, now I edited the "question above" part to link to the question too. – dbmrq May 6 '16 at 17:27
  • Sorry. I somehow missed the fact that you had a link earlier in the question. Apologies. (But it is always good to hit readers like me over the head with important information, so your edit is appreciated!) – cfr May 6 '16 at 17:30
  • I would test whether the value of the counter is 1 as well as if it equals the total and then execute the relevant code conditionally. I.e. if counter is 1 then ... else (if counter is total then ... else ...). – cfr May 6 '16 at 17:33
  • @cfr I'm trying to work with that, but I only manage to add stuff in between two cited entries, so I don't know how to open the parentheses in between the first author's name and the first year. – dbmrq May 7 '16 at 5:30
  • 1
    Or create a fake \multicite which takes two (or more) arguments and turns #2 into a related field of #1. – ienissei May 8 '16 at 8:07
3
+50

Imho the title of your question is wrong: You don't have a multicite here. What you really want is to add a \cite in the comment of another \cite. The logical input would imho be

 \textcite[{apud \cite[15]{smith}}]{Doe}

But this input is not allowed as you can't nest citations.

What you should do instead depends on the concrete case.

I wouldn't try to tweak multicite. While it can work it doesn't look sane to misuse it for this case. I also wouldn't overdo -- consider how often you really need it, and if a manual solution (which often is more flexible) isn't the best solution.

You could add a related field pointing to smith and write a cite command that use this field. But this will not allow you to add a prenote or postnote to smith.

The alternative is to do what you already suggesting: Write a fake cite command \textapud that gives what you want. You can improve it with optional arguments (you will perhaps want to change the placement of the pre- and postnotes):

\documentclass{book}
\usepackage[backend=biber, style=authoryear]{biblatex}
\addbibresource{test.bib}

\renewcommand*{\nameyeardelim}{\addcomma\addspace}

\NewBibliographyString{apud}
\DefineBibliographyStrings{english}{apud=apud}

\usepackage{xparse}

\makeatletter
\NewDocumentCommand{\textapud}{o o m o o m}{%
 \citeauthor{#3}  
 \mkbibparens{%
  \IfNoValueTF{#2}
   {%
    \IfNoValueTF{#1}
     {\citeyear{#3}}
     {\citeyear[#1]{#3}}%
   }
   {%
    \citeyear[#1][#2]{#3}%
   }   
  \IfNoValueTF{#5}
   {%
    \IfNoValueTF{#4}
     {\cite[\blx@imc@bibxstring{apud}][]{#6}}
     {\cite[\blx@imc@bibxstring{apud}][#4]{#6}}%
   }
   {%
    \cite[\blx@imc@bibxstring{apud} #4][#5]{#6}%
   }%   
  }}
\makeatother 


\begin{document}

\textapud[see][15]{doe}[blub][20]{smith}

\end{document}

enter image description here

  • This works perfectly, thank you! The only thing is I'm adding it to a biblatex style file and then I'd have to do \RequirePackage{xparse} right there at the .cbx file… is that a good idea? I don't know anything about LaTeX3 and, well, about pretty much anything at all, I'm just trying to piece stuff together to replace an old bibtex style. – dbmrq May 11 '16 at 3:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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