1

I am trying to define a custom citation style for my text. An MWE is the following

\documentclass{report}

\usepackage[backend=biber,sorting=none,style=phys, biblabel=brackets,pageranges=false,chaptertitle=false]{biblatex}
\usepackage{filecontents}

\begin{filecontents}{xxx1.bib}
@article{key1,
  author = {Author, A. and Author, B. and Author, C.},
  title = {paper title},
  journal = {journal name},
  volume = {50}, 
  issue = {4},              
  pages = {15},
  year = {2019}
}
\end{filecontents}

\addbibresource{xxx1.bib}

\DeclareCiteCommand{\citelong}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {
   [%   
   \ifciteindex
     {\indexfield{indextitle}}
     {}%
     \printnames{author},
     \printfield[citetitle]{labeltitle},
     \textit{\printfield[citefield]{journaltitle}}
     \textbf{\printfield[citefield]{volume}},
     \iffieldundef{pages}{% NEW
       \printfield{number}%
     }{% NEW
       \printfield{pages}
     }
     (\printfield[citefield]{year})%
   ]%
  } 
  {\multicitedelim}
  {\usebibmacro{postnote}}

\begin{document}    
They went to the beach and met with a mermaid \citelong{key1}.    
\printbibliography    
\end{document}

The above code produces enter image description here Now, unlike the one above, I want the all of the authors to be displayed not just the first one followed by et al. Biblatex documentation says that printnames should print all of its arguments but it does not in my code. I know that the way I define my custom citation format may not be the best one, that is as far as I can manage on my own by looking at biblatex manual. Therefore I appreciate if your modification does not change the above citation style code too much.

2
  • Do you want all authors shown everywhere, including in your bibliography? Or just in your \citelong macro? Aug 12 '19 at 12:20
  • The particular options I have for biblatex package already make the bibliography entries to show all authors. For this problem I just want to implement it for citelong.
    – nougako
    Aug 12 '19 at 12:23
3

The biblatex-phys style loads biblatex with these options:

maxnames=999, maxcitenames=2

So you just need to override the value of maxcitenames when you load biblatex. You can just use the maxnames option which sets both maxcitenames and maxbibnames.

\usepackage[sorting=none,style=phys, maxnames=999, biblabel=brackets, pageranges=false, chaptertitle=false]{biblatex}

To set the number of names directly in your \citelong macro, you could use \printnames[][-\value{listtotal}]{author}.

I've also tidied up your macro a bit so that punctuation will be more robust.

\DeclareFieldFormat{citejournaltitle}{\mkbibemph{#1}}

\DeclareCiteCommand{\citelong}[\mkbibbrackets]
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\ifciteindex
     {\indexfield{indextitle}}
     {}%
   \printnames[][-\value{listtotal}]{author}%
   \newunit
   \printfield[citetitle]{labeltitle}%
   \newunit
   \printfield[citejournaltitle]{journaltitle}%
   \setunit*{\addspace}%
   \printfield{volume}%
   \newunit
   \iffieldundef{pages}
     {\printfield{number}}
     {\printfield{pages}}%
   \setunit{\addspace}%
   \printtext[parens]{\usebibmacro{date}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}
5
  • Thanks it works! Although I am still puzzled. Previously I have also tried \printnames[1-2]{author}, which, if I understood biblatex manual correctly, should print up to the second author in the list but it still showed the first one only.
    – nougako
    Aug 12 '19 at 12:38
  • 2
    @nougako You can use \printnames[][-\value{listtotal}]{author}. It needs both optional arguments for some reason. Actually, your cite command is not very robust. I'll update my question and show you how I would do it. Aug 12 '19 at 12:48
  • 1
    You need the empty pair of square brackets, because \printnames can have two optional arguments: \printnames[<format>][<start>-<stop>]{<name list>}. If only one optional argument is found it is assumed to be <format>, so if you want to give <start> and <stop> you need to put an empty argument in between. This is similar to the two optional arguments of \cite.
    – moewe
    Aug 12 '19 at 15:53
  • @moewe, yeah. should have realized that logic earlier. @David Purton, can you explain why do you have to have \newunit in between field elements, e.g. between volume and number?
    – nougako
    Aug 13 '19 at 0:47
  • 1
    @nougako, you shouldn't insert punctuation directly like you have done. (\newunit will output a comma and a space.) The advantage of \newunit is that it works with biblatex's punctuation tracker and won't give you double punctuation if a field is missing. It allows for punctuation to be moved inside and outside of quote marks automatically based on settings. Have a look at the drivers in standard.bbx to learn how to output citations. Aug 13 '19 at 0:52

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.