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.

1as 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 06 '16 at 17:33@apudcite command there uses thecitebib macro… I'm thinking I could define another macro that opens the parenthesis at the right place and then another that closes it at the right place, but then I don't know how to make the multicite command use one or the other conditionally, I've tried checking thecitecountfor that, but couldn't get it to work. – dbmrq May 07 '16 at 05:40bibstrings, I don't see how the code can be compiled to reproduce your situation. – cfr May 07 '16 at 12:07bibstringcommand just prints "apud" in bold, I thought it was enough for testing… we could even have the "apud" string hardcoded there, the main thing is that it shows up in the right place and I think my code allows us to test that. I could add thebibstringcode, but I think it has to be in its own.lbxfile, doesn't it? Then it seems like a lot of trouble to add it here and link it correctly to theauthoryearstyle… I don't even know how to do that and it seems like it'll make the example a lot more complicated with little gain. – dbmrq May 07 '16 at 21:27relatedfield, i.e. add the main entry's citekey in the "apud entry". Then modify the citation style to incorporate related entries within parentheses and cite just the "apud entry". This requires runningbibertwice. – ienissei May 08 '16 at 08:03\multicitewhich takes two (or more) arguments and turns#2into a related field of#1. – ienissei May 08 '16 at 08:07