Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I would like to differentiate the citation output for website from the setting in the MWE for books, journals, etc. (which I want to maintain).

For the website and only for the website I would like the following output:

Title. (Year). Retrieved date from URL.

Please consider the following MWE with a bibliography of one book and one website.

\RequirePackage{filecontents}

\begin{filecontents*}{mybib.bib}
@book{van_de_donk_cyberprotest_2004,
    address = {London},
    url = {www.jstor.com/somearticle.html},
    urldate = {2013-10-29},
    title = {Cyberprotest: {New} media, citizens, and social movements},
    publisher = {Routledge},
    editor = {van de Donk, Wim B. H. J.},
    year = {2004}
}
@misc{website,
    title = {This is a blog},
    url = {www.blog.com},
    urldate = {2013-08-29},
    journal = {Blog},
    month = feb,
    year = {2009}
}
}
\end{filecontents*}

\documentclass[a4paper]{article}


% Set the values for the bibliography
\usepackage[
    style=apa,
    backend=biber,
    isbn=false,
    url=false,
    doi=false,
    eprint=false,
    hyperref=true,
    backref=false,
    firstinits=false,
]{biblatex}

% Remove series & month
\AtEveryBibitem{
  \clearfield{series}
  \clearfield{labelmonth}
  \clearfield{edition}
}

% Recommended by biblatex
\usepackage[utf8]{inputenc}
\usepackage{csquotes}
\usepackage{xpatch}

% Set language
\usepackage[british]{babel}
\DeclareLanguageMapping{british}{british-apa}

\addbibresource{mybib.bib}

\begin{document}

\cite{test1} 

\cite{test2}

\printbibliography
\end{document}
share|improve this question
    
Would you be OK with using @online as entrytype for the website instead of @misc? Or are you OK with all @miscs having the proposed website format? –  moewe Nov 14 '13 at 17:54
    
I am OK with all @miscs having the proposed website format. –  Francesco Nov 15 '13 at 1:14
1  
Try \savebibmacro{url+urldate} \renewbibmacro*{url+urldate}{\ifentrytype{misc}{\restorebibmacro{url+urldate}\us‌​ebibmacro{url+urldate}}{}} –  Marco Daniel Nov 17 '13 at 12:26
    
My above solution requires url=true –  Marco Daniel Nov 17 '13 at 13:02
    
@MarcoDaniel That's it! –  Francesco Nov 19 '13 at 4:40

2 Answers 2

up vote 2 down vote accepted

As I wrote you can do the following:

  1. Use the option url=true
  2. redefine the bibmacro url+date so that it will print urls only if the entrytype is misc

    \savebibmacro{url+urldate}
    \renewbibmacro*{url+urldate}{%
       \ifentrytype{misc}{\restorebibmacro{url+urldate}\us‌​ebibmacro{url+urldate}}{}%
    } 
    
share|improve this answer

You might like the following redefinition of the *cite commands (as defined in apa.cbx). We just add a different treatment for @misc entries; the rest stays exactly the same. Put this code into your preamble.

\makeatletter
\renewbibmacro*{cite}{%
  \ifentrytype{misc}%<--- from here
    {\usebibmacro{cite:noname}%
     \newunit
     \printtext[parens]{\usebibmacro{cite:plabelyear+extrayear}}%
     \newunit
     \usebibmacro{url+urldate}%
     \printtext{\addperiod}
    }%<----- to here is new; what follows is standard apa.cbx
    {\iffieldequals{namehash}{\cbx@lasthash}
  % Multiple cites in one command
     {\setunit{\compcitedelim}%
      \usebibmacro{cite:plabelyear+extrayear}}%
  % Single cite
     {\ifthenelse{\ifnameundef{labelname}\OR\iffieldequalstr{entrytype}{patent}}
  % No author/editor
       {\usebibmacro{cite:noname}%
         \setunit{\nameyeardelim}%
         \usebibmacro{cite:plabelyear+extrayear}%
         \savefield{namehash}{\cbx@lasthash}}
  % Normal cite
       {\ifnameundef{shortauthor}
          {\printnames[labelname][-\value{listtotal}]{labelname}}%
          {\cbx@apa@ifnamesaved
            {\printnames{shortauthor}}
            {\printnames[labelname][-\value{listtotal}]{author}\addspace\printnames[sabrackets]{shortauthor}}}%
        \setunit{\nameyeardelim}%
        \usebibmacro{cite:plabelyear+extrayear}%
        \savefield{namehash}{\cbx@lasthash}}}%
     \setunit{\multicitedelim}}}
\makeatother

The MWE

\RequirePackage{filecontents}

\begin{filecontents*}{\jobname.bib}
@book{van_de_donk_cyberprotest_2004,
    address = {London},
    title = {Cyberprotest: {New} media, citizens, and social movements},
    publisher = {Routledge},
    editor = {van de Donk, Wim B. H. J.},
    year = {2004}
}
@misc{website,
    title = {This is a blog},
    url = {www.blog.com},
    urldate = {2013-08-29},
    journal = {Blog},
    month = feb,
    year = {2009}
}
}
\end{filecontents*}

\documentclass[a4paper]{article}


% Set the values for the bibliography
\usepackage[
    style=apa,
    backend=biber,
    isbn=false,
    url=false,
    doi=false,
    eprint=false,
    hyperref=true,
    backref=false,
    firstinits=false,
]{biblatex}
\usepackage{hyperref}

% Remove series & month
\AtEveryBibitem{
  \clearfield{series}
  \clearfield{labelmonth}
  \clearfield{edition}
}

% Recommended by biblatex
\usepackage[utf8]{inputenc}
\usepackage{csquotes}
\usepackage{xpatch}

% Set language
\usepackage[british]{babel}
\DeclareLanguageMapping{british}{british-apa}

\addbibresource{\jobname.bib}
\makeatletter
\renewbibmacro*{cite}{%
  \ifentrytype{misc}
    {\usebibmacro{cite:noname}%
     \newunit
     \printtext[parens]{\usebibmacro{cite:plabelyear+extrayear}}%
     \newunit
     \usebibmacro{url+urldate}%
     \printtext{\addperiod}
    }
    {\iffieldequals{namehash}{\cbx@lasthash}
  % Multiple cites in one command
     {\setunit{\compcitedelim}%
      \usebibmacro{cite:plabelyear+extrayear}}%
  % Single cite
     {\ifthenelse{\ifnameundef{labelname}\OR\iffieldequalstr{entrytype}{patent}}
  % No author/editor
       {\usebibmacro{cite:noname}%
         \setunit{\nameyeardelim}%
         \usebibmacro{cite:plabelyear+extrayear}%
         \savefield{namehash}{\cbx@lasthash}}
  % Normal cite
       {\ifnameundef{shortauthor}
          {\printnames[labelname][-\value{listtotal}]{labelname}}%
          {\cbx@apa@ifnamesaved
            {\printnames{shortauthor}}
            {\printnames[labelname][-\value{listtotal}]{author}\addspace\printnames[sabrackets]{shortauthor}}}%
        \setunit{\nameyeardelim}%
        \usebibmacro{cite:plabelyear+extrayear}%
        \savefield{namehash}{\cbx@lasthash}}}%
     \setunit{\multicitedelim}}}
\makeatother
\begin{document}

\cite{van_de_donk_cyberprotest_2004} 

\cite{website}

\printbibliography
\end{document}

yields enter image description here

share|improve this answer
    
Great! But how do you print the extended form of the website entry also within the references? I would actually prefer to have only 'title', year inline and the long version title. (year). Retrieved month day, year, from source. in the references. see here –  Francesco Nov 16 '13 at 22:19
    
@Francesco Mhhh, in that case no redefinition is needed at all, just change url=false in the options to url=true, after all you do want to see the URL. –  moewe Nov 17 '13 at 8:53
    
But if I switch the option to url=true I will output the url also for all the articles that I have in my bibliography. (Sorry I notice now that this was not clear in my question, I re-edited it) –  Francesco Nov 17 '13 at 12:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.