0

I am trying to modify the citation style of biblatex for a beamer presentation. Using this question and this follow-up question of mine, I have used the resulting code (see MWE below) happily for some time, which yields the following output:

enter image description here

While working on a new talk, I have decided that I want a different (shorter) citation style that should look like this:

Wanted short style

with "author, journal journal volume, pages (year)".

Is there a way to achieve this? I have tried to use the same tricks as for the journal name to get the journal volume, but I get ! Package biblatex Error: Bibliography macro 'volume' undefined.

Could there even be a predefined citation-style? I appreciate any kind of ideas.

MWE (note: the documentclass in this MWE is article, not beamer, since it does not impact the behaviour in this case):

\documentclass{article}                                                                                              

\usepackage{filecontents}                                                                                            
\begin{filecontents}{bib.bib}                                                                                        
@article{article,                                                                                                    
author = {Vimes, Samuel},                                                                                        
title = {The Influence of Species Diversity in the City Watch},                                                  
journal = {Unseen University Non-Magical Journal},                                                               
volume  = {4}, 
pages = {42--37},                                                                                                 
date = {1988}                                                                                                    
}                                                                                                                                                                                                                                       
\end{filecontents}                                                                                                   

\usepackage[backend=biber,maxcitenames=1,maxbibnames=2,                                                              
giveninits=true]{biblatex}                                                                                           
\addbibresource{bib.bib}                                                                                               


% previous citation style                                                                                            
\DeclareCiteCommand{\citejournal}                                                                                    
  {\usebibmacro{prenote}}                                                                                            
  {\usebibmacro{citeindex}%                                                                                          
    \ifentrytype{article}{\usebibmacro{journal}\addcomma\addspace}{}}                                               

  {\multicitedelim}                                                                                                  
 {\usebibmacro{postnote}}                                                                                          

\newcommand{\cfootcite}[1]{                                                                                          
  {\tiny{\citeauthor{#1}, \citetitle{#1}, \citejournal{#1}\citeyear{#1}}}} % to get author, title, journal, year     

% attempt at new style                                                                                               
\DeclareCiteCommand{\citevolume}                                                                                     
  {\usebibmacro{prenote}}                                                                                            
  {\usebibmacro{citeindex}%                                                                                          
    \ifentrytype{article}{\usebibmacro{volume}\addcomma\addspace}{}}                                               

  {\multicitedelim}                                                                                                  
  {\usebibmacro{postnote}}                                                                                           

\DeclareFieldFormat[article]{volume}{\mkbibbold{#1\isdot}}                                                           

\newcommand{\cfootcitenew}[1]{                                                                                      

  {\tiny{\citeauthor{#1}, \citejournal{#1}\citevolume{#1}(\citeyear{#1})}}} % to get author, journal, journal number, year                                                                                                               



\begin{document}                                                                                                     

Old style:                                                                                                           

\cfootcite{article}                                                                                                  


Attempt new style:                                                                                                   

\cfootcitenew{article}

\end{document}

Output (while ignoring error):

Full output MWE

2

I strongly recommend against lobbing together several high-level \cite... commands into a \newcommand. (In some cases this can lead to actual problems with citation tracking, but usually it is just more work than necessary.)

The usual way to do create a new citation command is to define it with \DeclareCiteCommand. Usually this command delegates all the hard work to a bibmacro.

\documentclass{article}

\usepackage[backend=biber,
  maxcitenames=1,maxbibnames=2,
  giveninits=true]{biblatex}

\newcommand*{\mktexttiny}[1]{{\normalsize #1}}
% the definition should of course be {{\tiny #1}},
% but \normalsize is easier to read in the MWE

\DeclareCiteCommand{\cfootcitenew}[\mktexttiny]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cfootcitenew}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\newbibmacro*{cfootcitenew}{%
  \printnames{labelname}%
  \setunit{\addcomma\space}%
  \ifentrytype{article}
    {\printfield{journaltitle}%
     \setunit{\addspace}%
     \printfield{volume}%
     \setunit{\addcomma\space}%
     \printfield{pages}}
    {\printfield{labeltitle}}%
  \setunit{\addspace}%
  \DeclareFieldFormat{date}{\mkbibparens{##1}}%
  \printdate
}

\DeclareFieldFormat[article,periodical]{volume}{\mkbibbold{#1}}
\DeclareFieldFormat{pages}{#1}

\begin{filecontents}[force]{\jobname.bib}
@article{article,
  author  = {Vimes, Samuel},
  title   = {The Influence of Species Diversity in the City Watch},
  journal = {Unseen University Non-Magical Journal},
  volume  = {4},
  pages   = {42--37},
  date    = {1988},
}
\end{filecontents}
\addbibresource{\jobname.bib}

\begin{document}
\cfootcitenew{article}
\end{document}

Vimes, Unseen University Non-Magical Journal **4**, 42–37 (1988)

7
  • Exactly what I needed, thank you! Do you know a good tutorial/guide on how to write a new cite command like this? I find the biblatex manual more confusing than helpful... – Taunch Jan 9 '20 at 10:22
  • @Taunch Sorry, I know of no good tutorial for more advanced biblatex programming . Currently, the best way to learn it is to look at the source (biblatex.def, standard.bbx) and imitate what it does. – moewe Jan 9 '20 at 16:30
  • I see, that is unfortunate for the intimidated (like me). Maybe I will ask a separate question for a beginner's guide. – Taunch Jan 9 '20 at 17:46
  • I have one more question if you don't mind: I noticed that now the full citation output in the bibliography also follows the same style. While this doesn't bother me per se, one thing does look weird: the year is now in double parenthesis ([1988]). How can this be changed? – Taunch Jan 10 '20 at 16:56
  • @Taunch See the edit. – moewe Jan 10 '20 at 18:49

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.