1

Basically i want to have journal's volume 4, number 2 from

4:2 

to

4(2)

enter image description here

My MWE:

\documentclass{article}
\usepackage{xpatch}
% \usepackage[style = authoryear-comp, maxnames = 99]{biblatex}

\usepackage[backend=biber, 
% style=authoryear, 
 style=authoryear-comp,
% citestyle=authoryear, 
dashed=false,
maxcitenames=2,
maxbibnames=99,
giveninits,
uniquename=init]{biblatex}


\DeclareNameAlias{sortname}{family-given} %for second and third author name


\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

\usepackage{csquotes}

\usepackage[unicode,colorlinks,citecolor=blue]{hyperref}


% for a chapter edited by a book
\usepackage{xpatch}
% \renewcommand*{\finalnamedelim}{\addspace\&\space} 
% \renewcommand*{\intitlepunct}{\space} (to become In:)
\renewcommand{\labelnamepunct}{\space} %to delete . after (1997)
% \DeclareFieldFormat[article, incollection, unpublished]{pages}{#1} % to add in PP. (page)
\DeclareFieldFormat[article, incollection, unpublished]{title}{#1}
% \renewcommand{\bibpagespunct}{\ifentrytype{article}{\addcolon}{\addperiod\addspace}} %cancel out this in order to add in PP. (page)


% for title italic
% \DeclareFieldFormat*{title}{\mkbibemph{#1}} %for title italic in all format (conference, paper..)
\DeclareFieldFormat*{title}{#1} %for conference title delete ".."
\DeclareFieldFormat[incollection]{title}{\mkbibemph{#1}} %for incollecion title italic ONLY
\DeclareFieldFormat[thesis]{title}{\mkbibemph{#1}} %for phdthesis title italic ONLY
% for title italic

% to delete "In:" for article
\renewbibmacro{in:}{%
  \ifentrytype{article}{}{\printtext{\bibstring{in}\intitlepunct}}}
% to delete "In:" for article


% for delete comma after Author A and Aurhor b
\DefineBibliographyExtras{english}{%
   \let\finalandcomma\empty
   \let\finalandsemicolon\empty
 }
\renewcommand{\compcitedelim}{\space\&\space}
\DeclareNameAlias{editorin}{given-family}

\newbibmacro*{byeditor:in}{%
  \ifnameundef{editor}
    {}
    {\printnames[editorin]{editor}%
     \setunit{\addcomma\space}%
     \usebibmacro{editorstrg}%
     \clearname{editor}}}     


\xpatchbibdriver{inbook}
  {\usebibmacro{in:}%
   \usebibmacro{bybookauthor}%
   \newunit\newblock
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{byeditor+others}}
  {\usebibmacro{in:}%
   \usebibmacro{bybookauthor}%
   \newunit\newblock
   \usebibmacro{byeditor:in}%
   \newunit\newblock
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{byeditor+others}}
  {}{}

\xpatchbibdriver{incollection}
  {\usebibmacro{in:}%
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{byeditor+others}}
  {\usebibmacro{in:}%
   \usebibmacro{byeditor:in}%
   \setunit{\labelnamepunct}\newblock
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{byeditor}}
  {}{}

\xpatchbibdriver{inproceedings}
  {\usebibmacro{in:}%
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{event+venue+date}%
   \newunit\newblock
   \usebibmacro{byeditor+others}}
  {\usebibmacro{in:}%
   \usebibmacro{byeditor:in}%
   \setunit{\labelnamepunct}\newblock
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{event+venue+date}%
   \newunit\newblock
   \usebibmacro{byeditor+others}}
  {}{}

\xpatchbibdriver{phdthesis}
  {\usebibmacro{in:}%
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{event+venue+date}%
   \newunit\newblock
   \usebibmacro{byeditor+others}}
  {\usebibmacro{in:}%
   \usebibmacro{byeditor:in}%
   \setunit{\labelnamepunct}\newblock
   \usebibmacro{maintitle+booktitle}%
   \newunit\newblock
   \usebibmacro{event+venue+date}%
   \newunit\newblock
   \usebibmacro{byeditor+others}}
  {}{}





% for references 's studies (year)
\renewcommand*{\nameyeardelim}{\addcomma\space}
\newcommand{\mycite}[1]{\citeauthor{#1}'s \citeyear{#1}}

\DeclareCiteCommand{\citeauthor}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\ifciteindex
     {\indexnames{labelname}}
     {}%
   \printtext[bibhyperref]{\printnames{labelname}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\citeyear} % <======================================
    {}
    {(\bibhyperref{\printdate})}
    {\multicitedelim}
    {}

\DeclareCiteCommand{\parencite}[\mkbibparens]
  {\usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \printtext[bibhyperref]{\usebibmacro{cite}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}


\makeatletter
\let\abx@macro@textciteOrig\abx@macro@textcite
\renewbibmacro{textcite}{% <============================================
   \bibhyperref{%
   \let\bibhyperref\relax\relax%
   \abx@macro@textciteOrig%
   }%
}%
\makeatother
% for references 's studies (year)



\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}

@article{gaver1986auditory,
  title={Auditory icons: Using sound in computer interfaces},
  author={Gaver, William W},
  journal={Human-computer interaction},
  volume={2},
  number={2},
  pages={167--177},
  year={1986},
  publisher={Taylor \& Francis}
}

\end{filecontents*}
\addbibresource{\jobname.bib}

\begin{document}
\nocite{*}


used in analysing histograms and boxplots as is discussed by numerous other authors in \textcite{gaver1986auditory} 


\printbibliography
\end{document}
aan
  • 2,663

1 Answers1

2

With the biblatex-ext styles this only needs two lines

\renewcommand*{\volnumdelim}{}
\DeclareFieldFormat[article,periodical]{number}{\mkbibparens{#1}}

then

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[style=ext-authoryear-comp, backend=biber]{biblatex}

\renewcommand*{\volnumdelim}{}
\DeclareFieldFormat[article,periodical]{number}{\mkbibparens{#1}}

\addbibresource{biblatex-examples.bib}

\begin{document}
\cite{sigfridsson}
\printbibliography
\end{document}

produces

Sigfridsson, Emma and Ulf Ryde (1998). ‘Comparison of methods for deriving atomic charges from the electrostatic potential and moments’. In: Journal of Computational Chemistry 19(4), pp. 377–395. doi: 10.1002/(SICI)1096-987X(199803)19:4<377::AID-JCC1>3.0.CO;2-P.


In case you are stuck with an older TeX distribution without biblatex-ext or don't want to use those styles, you can emulate the behaviour by redefining the bibmacro volume+number+eid

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[style=authoryear-comp, backend=biber]{biblatex}


\newcommand*{\volnumdelim}{}
\DeclareFieldFormat[article,periodical]{number}{\mkbibparens{#1}}

\renewbibmacro*{volume+number+eid}{%
  \printfield{volume}%
  \setunit*{\volnumdelim}%
  \printfield{number}%
  \setunit{\addcomma\space}%
  \printfield{eid}}

\addbibresource{biblatex-examples.bib}

\begin{document}
\cite{sigfridsson}
\printbibliography
\end{document}

The resulting output is the same.


If you also want to change the punctuation before volume and number you want biblatex-ext's \jourvoldelim

\renewcommand*{\jourvoldelim}{\addcomma\space}

If you can't use biblatex-ext, you need to get that command first

\newcommand*{\jourvoldelim}{\addcomma\space}
\newcommand*{\jourserdelim}{\newunitpunct}
\newcommand*{\servoldelim}{\jourvoldelim}
\newcommand*{\volnumdatedelim}{\addspace}

\renewbibmacro*{journal+issuetitle}{%
  \usebibmacro{journal}%
  \setunit*{\jourvoldelim}%
  \iffieldundef{series}
    {}
    {\setunit*{\jourserdelim}%
     \printfield{series}%
     \setunit{\servoldelim}}%
  \usebibmacro{volume+number+eid}%
  \setunit{\volnumdatedelim}%
  \usebibmacro{issue+date}%
  \setunit{\addcolon\space}%
  \usebibmacro{issue}%
  \newunit}
moewe
  • 175,683
  • thanks. I tried run your MWE in overleaf using the older TeX distribution. It does not have a comma before volume (number). Is it possible to add a comma before that? Example: .....Computational Chemistry 19(4), pp. 377–395....... – aan Sep 24 '19 at 20:47
  • @aan Note that Overleaf recently made TeX live 2018 available. If you start a new project now (or clone an older project) you will get a new system that can run biblatex-ext. – moewe Sep 24 '19 at 20:49
  • thanks. I just create a new project, paste your MWE. It seemed still the same. Do i need run any biblatex-ext in overleaf? – aan Sep 24 '19 at 20:52
  • @aan Sorry, the MWE does not add a comma before volume and number (because the question didn't ask for it). I edited the answer with a suggestion for that at the end. – moewe Sep 24 '19 at 20:58
  • @aan To clarify on the biblatex-ext comment. You know that you are using biblatex-ext when the first MWE in this question runs without error. No further steps are needed on Overleaf other than to ensure you are using the new system by starting a new project. But as I commented above the MWEs don't include code for the comma before the volume that is dealt with by the edit at the end. – moewe Sep 24 '19 at 21:04
  • thanks. Is my question not clear. Sorry for that. Between, I just tried, output is prefect. But it said Latex error: \jourvoldelim undefined for these \renewcommand*{\jourvoldelim}{\addcomma\space} \newcommand*{\jourvoldelim}{\addcomma\space} – aan Sep 24 '19 at 21:07
  • @aan \jourvoldelim will be defined if you are using style=ext-authoryear-comp (as in the first MWE) or any other biblatex-ext style. In that case \renewcommand*{\jourvoldelim}{\addcomma\space} is the way to go. If you are not using biblatex-ext, then you must take the entire last code block, which defines the command and makes it available for redefinition later. – moewe Sep 24 '19 at 21:10
  • thanks. Yes, I tried changed from style=authoryear-comp to style=ext-authoryear-comp in overleaf, it create more errors. Sorry, couldn't get what you mean by you must take the entire last code block, which defines the command and makes it available for redefinition later for my case that not using biblatex-ext – aan Sep 24 '19 at 21:16
  • sorry. it works with your above answer. Thanks. I guess i am confused with mine overleaf. – aan Sep 24 '19 at 23:24