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.

dbmrq
  • 1,299
  • @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 06 '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 06 '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 06 '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 07 '16 at 05:30
  • @cfr My @apud cite command there uses the cite bib 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 the citecount for that, but couldn't get it to work. – dbmrq May 07 '16 at 05:40
  • Note that the code is relevant if somebody needs it to reproduce the problem. Without the bibstrings, I don't see how the code can be compiled to reproduce your situation. – cfr May 07 '16 at 12:07
  • @cfr Well, without the definition the bibstring command 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 the bibstring code, but I think it has to be in its own .lbx file, doesn't it? Then it seems like a lot of trouble to add it here and link it correctly to the authoryear style… 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:27
  • If this is a recurrent thing with this entry but a relatively unfrequent one in your entire bibliography, maybe you could use a related field, 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 running biber twice. – ienissei May 08 '16 at 08:03
  • 1
    Or create a fake \multicite which takes two (or more) arguments and turns #2 into a related field of #1. – ienissei May 08 '16 at 08:07

1 Answers1

3

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

Ulrike Fischer
  • 327,261
  • 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 03:30