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}
jGaboardi
  • 502
Aria
  • 1,523
  • 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 '19 at 17:20
  • Hello John. I only run XeLatex+MakeIndex+BibTeX. I got error when I run BibTeX – Aria May 12 '19 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 '19 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 '19 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 '19 at 18:28
  • In the result I get this: "like to see H. Name 2010 try Name n.d." I like to delete n.d. also I like to get 2010 in parentheses like (2010) and I do not like to see the first letter for first name H. do you know how to get this? – Aria May 12 '19 at 18:53
  • The style is controlled by the bibstyle (.bst) selected. Please read the documentation for biblatex for this question. – John May 12 '19 at 19:11
  • See also https://tex.stackexchange.com/q/63852/35864 – moewe May 12 '19 at 19:53

1 Answers1

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

user187802
  • 16,850