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}
8
  • 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
    Commented May 12, 2019 at 17:20
  • Hello John. I only run XeLatex+MakeIndex+BibTeX. I got error when I run BibTeX
    – Aria
    Commented May 12, 2019 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
    Commented May 12, 2019 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
    Commented May 12, 2019 at 17:40
  • Not sure what you are asking -- is it working? Then you are done. If not, what error are you seeing?
    – John
    Commented May 12, 2019 at 18:28

1 Answer 1

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .