0

I am referring to enter link description here for citing a page number in-text

The output I get:

ABC book is done (Gaver, 1986, p. 150)
This book is done by Gaver (1986, p. 150)

How to change to:

ABC book is done (Gaver, 1986: 150)
This book is done by Gaver (1986; 150)
This book is done by Gaver (1986; 150-152)

enter image description here

Basically, delete the p and change to : for \parencite and to ; for \textcite.

is it impossible to get cross-referencing too? The page is not highlighted as blue

\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{*}

ABC book is done \parencite[150]{gaver1986auditory}\\
This book is done by \textcite[150]{gaver1986auditory}


\printbibliography
\end{document}
  • 1
    Could you please add a full minimal document to the question that shows your current output? It is partly in the linked question but it would be easier when it is in this question too, especially because you seem to have made some changes in the formatting already (author-year for example). Also, I don't really understand what "is it impossible to get cross-referencing" means, maybe you can clarify that. – Marijn Sep 24 at 17:53
  • @Marijn, thanks. I had editted – aan Sep 24 at 18:03
2

The postnote format (page prefix or not etc.) is controlled with the field format postnote. The punctuation between the postnote and the rest of the citation is controlled by postnotedelim.

In biblatex 3.13 and above postnotedelim is a context-sensitive delimiter and can easily be switched between \textcite and \parencite.

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

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

\addbibresource{biblatex-examples.bib}

\DeclareDelimFormat[textcite]{postnotedelim}{\addsemicolon\space}
\DeclareDelimFormat[parencite]{postnotedelim}{\addcolon\space}

\DeclareFieldFormat{postnote}{\mknormrange{#1}}
\DeclareFieldFormat{multipostnote}{\mknormrange{#1}}

\begin{document}
\cite[380]{sigfridsson}

\textcite[381]{sigfridsson}

\parencite[382]{sigfridsson}

\printbibliography
\end{document}

Sigfridsson and Ryde 1998, 380//Sigfridsson and Ryde (1998; 381)//(Sigfridsson and Ryde 1998: 382)


I seem to remember that you are using an outdated version of biblatex and so you probably can't make use of the context-sensitive postnotedelim.

In that case it is easiest to insert a redefinition of postnotedelim directly into the definition of \parencite and \textcite.

You already redefine \parencite in your preamble, so you only need to modify that definition a bit

\DeclareCiteCommand{\parencite}[\mkbibparens]
  {\renewcommand*{\postnotedelim}{\addcolon\space}%
   \usebibmacro{cite:init}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \printtext[bibhyperref]{\usebibmacro{cite}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

For \textcite you need to modify the internal command with the style authoryear-comp

\DeclareCiteCommand{\cbx@textcite}
  {\renewcommand*{\postnotedelim}{\addsemicolon\space}%
   \usebibmacro{cite:init}}
  {\usebibmacro{citeindex}%
   \usebibmacro{textcite}}
  {}
  {\usebibmacro{textcite:postnote}}

The postnote is usually not linked and I would leave it that way.

  • I am using out-datad version of biblatex. I redefine \parencite as your answer. and need add \DeclareFieldFormat{postnote}{\mknormrange{#1}} \DeclareFieldFormat{multipostnote}{\mknormrange{#1}}. But there is error saying The compiler is having trouble understanding a command you have used. Check that the command is spelled correctly. If the command is part of a package, make sure you have included the package in your preamble using \usepackage{...}. – aan Sep 25 at 1:04
  • 1
    just a suggestion. In your MWE: \usepackage[style=style=authoryear-comp, backend=biber]{biblatex}, there is a small typo error. Should be \usepackage[style=authoryear-comp, backend=biber]{biblatex} – aan Sep 25 at 10:09
  • @aan Argh, yes! Thanks for spotting that. Should be fixed now. – moewe Sep 28 at 9:53
  • thanks. I implement your answer in my work, but not seemed working. I had posted related question in tex.stackexchange.com/questions/510215/… – aan Sep 29 at 7:23
  • thanks. Additional question regarding cross-referencing that linke to this anwers. tex.stackexchange.com/questions/510219/… – aan Sep 29 at 7: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.