1

I have a book document and I want to use biblatex pacakage to cite a book (referring to author-year) and cite a url (referring to author) inside the text. It does not print any bibliography for me. Do you know how to do it?

\documentclass{book}
\usepackage[style=authoryear]{biblatex}
\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
@book{mybook,
author       = {Her Name},
date         = {2010},
title        = {Her title},
publisher    = {City: publisher},
}
@online{myurl,
author       = {his Name},
title        = {his title},
organization = {Wikibooks},
url          = {https://helping_each_other_and_i_help_u.com},
}
\end{filecontents}

\bibliography{\jobname}

\begin{document}
like to see \cite{mybook} try \cite{myurl}.
\printbibliography
\end{document}
  • 1
    It's not clear how you are processing this file. Usually, you need to run latex, then biber or bibtex, then latex twice. Are you following that sequence? I was able to create a bibliography from your example this way. – John May 12 at 17:20
  • Hello John. I only run XeLatex+MakeIndex+BibTeX. I got error when I run BibTeX – Aria May 12 at 17:26
  • you are set up to use biber, not bibtex, since you have the biblatex package loaded. The solution depends on your particular software -- to adjust, see the various examples in this question. – John May 12 at 17:37
  • I run XeLatex+MakeIndex+BibTeX and now I see the results is that correct way of running or as u said run latex, then biber or bibtex, then latex twice? – Aria May 12 at 17:40
  • Not sure what you are asking -- is it working? Then you are done. If not, what error are you seeing? – John May 12 at 18:28
2

To me it makes no real sense to cite authors in this way. However, here is a solution:

\documentclass{book}
\usepackage[style=authoryear]{biblatex}
\usepackage{filecontents}

\begin{filecontents}{\jobname.bib}
    @book{mybook,
        author       = {Her Name},
        date         = {2010},
        title        = {Her title},
        publisher    = {City: publisher},
    }
    @online{myurl,
        author       = {His Name},
        title        = {His title},
        organization = {Wikibooks},
        url          = {https://helping_each_other_and_i_help_u.com},
    }
\end{filecontents}
\DeclareNameFormat{family}{%
    \usebibmacro{name:family}
        {\namepartfamily}
        {\namepartgiven}
        {\namepartprefix}
        {\namepartsuffix}}
\newbibmacro*{name:family}[4]{\mkbibnamefamily{#1}\isdot}

\DeclareNameFormat{labelname}{\nameparts{#1}%
    \usebibmacro{name:given-family}{\namepartfamily}{\relax}{\relax}}
\DeclareNameFormat{author}{\nameparts{#1}%
    \usebibmacro{name:given-family}{\namepartfamily}{\relax}{\relax}}
\DeclareLabeldate{\field{date}\field{eventdate} \field{origdate}}

\addbibresource{\jobname.bib}

\begin{document}
    like to see \textcite{mybook} try \citeauthor{myurl}.
    \printbibliography
\end{document}

enter image description here enter image description here

  • Thanks Red-Cloud! Do you know how to get rid of H. to have:"like to see Name (2010) try Name"? – Aria May 12 at 20:21
  • Also do u know how to get rid of (n.d.) in the url bibliography? – Aria May 13 at 2:36
  • see edited answer – Red-Cloud May 13 at 6:27

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.