引用方式为作者标题而非作者年份;但仅适用于特定文件的参考文献

引用方式为作者标题而非作者年份;但仅适用于特定文件的参考文献

基于Biblatex:两种具有不同风格和排序的书目,我有以下 MWE。

\documentclass{article}

%%% To use with the \DeclareFieldFormat and \defbibenvironment below:
% \usepackage[backend=biber, style=alphabetic, labelnumber, defernumbers=true]{biblatex}

\usepackage[backend=biber, style=authoryear, sorting=none, natbib=true, backref]{biblatex}

% Append keywords to identify different bibliography entries.
% appendstrict only appends if the field is nonempty,
% we use that to add a comma to avoid mushing together two keywords
\DeclareSourcemap{
  \maps[datatype=bibtex, overwrite]{
    \map{
      \perdatasource{Referenzen_academic.bib}
      \step[fieldset=KEYWORDS, fieldvalue={, }, appendstrict]
      \step[fieldset=KEYWORDS, fieldvalue=primary, append]
    }
    \map{
      \perdatasource{Referenzen_popular.bib}
      \step[fieldset=KEYWORDS, fieldvalue={, }, appendstrict]
      \step[fieldset=KEYWORDS, fieldvalue=secondary, append]
    }
  }
}

\begin{filecontents}{Referenzen_academic.bib}
@BOOK{BookA03,
  author    = {Author Aaa},
  title     = {Some Title},
  publisher = {Some Publisher},
  year      = 2003,
%   keywords  = {hello},
}
@BOOK{BookB02,
  author    = {Author Bbb},
  title     = {Some Title},
  publisher = {Some Publisher},
  year      = 2002,
}
\end{filecontents}
\begin{filecontents}{Referenzen_popular.bib}
@MISC{LinkC04,
  author    = {Author Ccc},  
  title     = {Some Title},
  year      = 2004,
  url       = {www.test1.com/bild.jpg},
%   keywords  = {bye},
}
@MISC{LinkD01,
  author  = {Author Ddd},
  title   = {Some Title},
  year    = 2001,
  url     = {www.test2.com/bild.jpg},
}
\end{filecontents}
\addbibresource{Referenzen_academic.bib}
\addbibresource{Referenzen_popular.bib}

\usepackage{hyperref}

\begin{document}
The first two citations \cite{LinkD01} and \cite{BookB02}. 
The others are \cite{LinkC04} and \cite{BookA03}.

\printbibliography[title=Bibliography (academic), keyword=primary]
\newrefcontext[sorting=none]
% \printbibliography[env=bibliographyNUM, title=References, keyword=secondary, resetnumbers]
\printbibliography[title=Bibliography (conventional), keyword=secondary]

\end{document}

我有两个不同的参考书目文件。我希望参考书目本身是相同的(如图所示)。但是,我希望每个参考书目的引用不同。也就是说,我希望第二篇文章正文中的引用包含作者和标题,而不是作者和年份。我该怎么做?

答案1

我设法用以下代码回答了我的问题

\documentclass{article}
\usepackage[backend=biber, style=authoryear, sorting=none, natbib=true, backref]{biblatex}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%
%%%     Automatically adding keywords, depending on the file origin
%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Append keywords to identify different bibliography entries.
% appendstrict only appends if the field is nonempty,
% we use that to add a comma to avoid mushing together two keywords
\DeclareSourcemap{
  \maps[datatype=bibtex, overwrite]{
    \map{
      \perdatasource{Referenzen_academic.bib}
      \step[fieldset=KEYWORDS, fieldvalue={, }, appendstrict]
      \step[fieldset=KEYWORDS, fieldvalue=primary, append]
    }
    \map{
      \perdatasource{Referenzen_popular.bib}
      \step[fieldset=KEYWORDS, fieldvalue={, }, appendstrict]
      \step[fieldset=KEYWORDS, fieldvalue=secondary, append]
    }
  }
}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%
%%%     Create or Customize cite commands
%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



% Here we redefine cite and parencite:
\DeclareCiteCommand{\cite}
  {\usebibmacro{prenote}}
  {\ifkeyword{secondary}{%
        \bibhyperref{\printfield{labeltitle}\setunit{\addcomma\addspace}\printnames{labelname}}%
        }{%
        \usebibmacro{cite}%
        }%
  }
  {\multicitedelim}
  {\usebibmacro{postnote}}

\DeclareCiteCommand{\parencite}
  {\bibopenparen\usebibmacro{prenote}}
  {\ifkeyword{secondary}{%
        \bibhyperref{\printfield[citetitle]{labeltitle}\setunit{\addcomma\addspace}\printnames{labelname}}%
        }{%
        \usebibmacro{cite}%
        }%
  }
  {\multicitedelim}
  {\usebibmacro{postnote}\bibcloseparen}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%
%%%     Produce and add the bib files
%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{filecontents}{Referenzen_academic.bib}
@BOOK{BookA03,
  author    = {FirstnameXA FamilyXA},
  title     = {Some Title XA},
  publisher = {Some Publisher XA},
  year      = 2003,
  keywords  = {hello},
}
@BOOK{BookB02,
  author    = {FirstnameXB FamilyXB},
  title     = {Some Title XB},
  publisher = {Some Publisher XB},
  year      = 2002,
  keywords  = {wiki}
}
\end{filecontents}
\begin{filecontents}{Referenzen_popular.bib}
@MISC{LinkC04,
  author    = {FirstnameYC FamilyYC},  
  title     = {Some Title YC},
  year      = 2004,
  url       = {www.test1.com/bild.jpg},
  keywords  = {bye},
}
@MISC{LinkD01,
  author  = {FirstnameYD FamilyYD},
  title   = {Some Title YD},
  year    = 2001,
  url     = {www.test2.com/bild.jpg},
  keywords  = {wiki}
}
\end{filecontents}
\addbibresource{Referenzen_academic.bib}
\addbibresource{Referenzen_popular.bib}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%
%%%     use other packages
%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\usepackage{hyperref}



%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%
%%%     Document
%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}
The first two citations \cite{LinkD01} and \cite{BookB02}. 
The others are \cite{LinkC04} and \cite{BookA03}.

\cite{LinkD01}

\parencite{BookB02}

\parencite{LinkD01}


\printbibliography[title=Bibliography (academic), keyword=primary]
\printbibliography[title=Bibliography (conventional), keyword=secondary]

\end{document}

其中包括以下技巧:

  • 我们根据引用的文件添加相应的关键字
  • 我们检查关键词来更改引用命令
  • 如果相应的关键字没有改变,我们保留原始命令

答案2

\authtitcite在第二篇文章中使用不同的引用命令(在我的 MWE 中)可以吗?

\documentclass{article}

%%% To use with the \DeclareFieldFormat and \defbibenvironment below:
% \usepackage[backend=biber, style=alphabetic, labelnumber, defernumbers=true]{biblatex}

\usepackage[backend=biber, style=authoryear, sorting=none, natbib=true, backref]{biblatex}

% Append keywords to identify different bibliography entries.
% appendstrict only appends if the field is nonempty,
% we use that to add a comma to avoid mushing together two keywords
\DeclareSourcemap{
  \maps[datatype=bibtex, overwrite]{
    \map{
      \perdatasource{Referenzen_academic.bib}
      \step[fieldset=KEYWORDS, fieldvalue={, }, appendstrict]
      \step[fieldset=KEYWORDS, fieldvalue=primary, append]
    }
    \map{
      \perdatasource{Referenzen_popular.bib}
      \step[fieldset=KEYWORDS, fieldvalue={, }, appendstrict]
      \step[fieldset=KEYWORDS, fieldvalue=secondary, append]
    }
  }
}

\begin{filecontents}{Referenzen_academic.bib}
@BOOK{BookA03,
  author    = {Author Aaa},
  title     = {Some Title},
  publisher = {Some Publisher},
  year      = 2003,
%   keywords  = {hello},
}
@BOOK{BookB02,
  author    = {Author Bbb},
  title     = {Some Title},
  publisher = {Some Publisher},
  year      = 2002,
}
\end{filecontents}
\begin{filecontents}{Referenzen_popular.bib}
@MISC{LinkC04,
  author    = {Author Ccc},  
  title     = {Some Title},
  year      = 2004,
  url       = {www.test1.com/bild.jpg},
%   keywords  = {bye},
}
@MISC{LinkD01,
  author  = {Author Ddd},
  title   = {Some Title},
  year    = 2001,
  url     = {www.test2.com/bild.jpg},
}
\end{filecontents}

% Adapted from https://tex.stackexchange.com/a/123145/101651
\DeclareCiteCommand{\authtitcite}
 {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\ifciteindex
     {\indexnames{labelname}%
      \indexfield{indextitle}}
     {}%
   \printnames{labelname}%
   \setunit{\addcomma\addspace}%
   \printfield[citetitle]{labeltitle}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

\addbibresource{Referenzen_academic.bib}
\addbibresource{Referenzen_popular.bib}

\usepackage{hyperref}

\begin{document}
Do you intend this in the first article: 

The first two citations \cite{LinkD01} and \cite{BookB02}. 

and this in the second article:

The others are \authtitcite{LinkC04} and \authtitcite{BookA03}.

?
\printbibliography[title=Bibliography (academic), keyword=primary]
\newrefcontext[sorting=none]
% \printbibliography[env=bibliographyNUM, title=References, keyword=secondary, resetnumbers]
\printbibliography[title=Bibliography (conventional), keyword=secondary]

\end{document}

在此处输入图片描述

相关内容