我正在撰写一篇文章,其中没有在文中引用,但我想在最后打印一堆参考书目。
我有不同类型的条目,例如“文章”、“论文”和“杂项”,我想按时间倒序分别打印它们,并合并同名的条目。
我没有定制参考书目经验,到目前为止我一直在使用默认样式。
这是我的 MWE:
\documentclass{article}
\usepackage{lipsum}
%%%%%%%%%%
% Colors %
%%%%%%%%%%
\usepackage{xcolor}
\definecolor{lightgray}{HTML}{989898}
\colorlet{textcolor}{lightgray}
%%%%%%%%%
% Fonts %
%%%%%%%%%
\usepackage[quiet]{fontspec}
\defaultfontfeatures{Mapping=tex-text}
\setmainfont[Mapping=tex-text, Color=textcolor]{Arial}
%%%%%%%%%%%%
% Geometry %
%%%%%%%%%%%%
\setlength{\parindent}{0pt}% No paragraph indentation
\setlength{\parskip}{.5\baselineskip plus 0.1\baselineskip minus 0.1\baselineskip}
\usepackage[left=2cm,top=2cm,right=2cm,bottom=2cm]{geometry}
%%%%%%%%%%%%%%%%
% Bibliography %
%%%%%%%%%%%%%%%%
\begin{filecontents}{\jobname.bib}
@article{Doe2011,
author = {Doe, John},
journal = {Nucleic Acids Research},
pages = {1--3},
title = {{Title of paper}},
volume = {39},
year = {2011}
}
@article{Smith2013,
author = {Smith, Josh},
journal = {Nature},
pages = {1--6},
title = {{Overly complicated title}},
volume = {85},
year = {2013}
}
@article{Adams2016,
author = {Adams, Brian},
journal = {Science},
pages = {10--15},
title = {{Another absurd title}},
volume = {2},
year = {2016}
}
@phdthesis{Surname2012,
author = {Surname, Name},
location = {Some University},
title = {{Some suitable thesis name}},
type = {PhD Thesis},
url = {http://thesis},
year = {2012}
}
@misc{Willis2013,
location = {Some Uni},
note = {Work In Progress report},
author = {Willis, William},
title = {{This is the same title always}},
type = {TALK},
month = {07},
year = {2013}
}
@misc{Willis2014,
location = {Another Uni},
note = {Poster Symposium},
author = {Willis, William},
title = {{This is the same title always}},
type = {POSTER},
month = {09},
year = {2014}
}
@misc{Willis2014b,
location = {Yet Another Uni},
author = {Willis, William},
title = {{This is the same title always}},
type = {TALK},
month = {09},
year = {2014}
}
@misc{Willis2015,
location = {Research Center},
author = {Willis, William},
title = {{New title}},
type = {TALK},
month = {09},
year = {2014}
}
\end{filecontents}
\usepackage{biblatex}
\addbibresource{\jobname.bib}
\begin{document}
\lipsum[1]
\nocite{*}
\printbibliography
\end{document}
使用 Biber 会产生以下内容(最终结果不必与 Biber 一致):
我想模仿使用 LibreOffice Writer 产生的以下结果,并且我想知道如果可能的话,哪种方法最好来实现它。
非常感谢!!
编辑
根据@Bernard 的回答以及从我的旧 Friggeri CV(现已损坏)借用的代码,以下是我最好的尝试(不完全确定我在做什么,只是复制和粘贴似乎有效的东西,所以如果您发现任何问题,请告诉我)。
梅威瑟:
\documentclass{article}
\usepackage{amssymb} \usepackage{lipsum}
%%%%%%%%%%
% Colors %
%%%%%%%%%%
\usepackage{xcolor}
\definecolor{lightgray}{HTML}{989898}
\colorlet{textcolor}{lightgray}
%%%%%%%%%
% Fonts %
%%%%%%%%%
\usepackage[quiet]{fontspec}
\defaultfontfeatures{Mapping=tex-text}
\setmainfont[Mapping=tex-text, Color=textcolor]{Arial}
\usepackage{fontawesome}
\newfontfamily{\FA}{FontAwesome}
%%%%%%%%%%%%
% Geometry %
%%%%%%%%%%%%
\setlength{\parindent}{0pt}% No paragraph indentation
\setlength{\parskip}{.5\baselineskip plus 0.1\baselineskip minus 0.1\baselineskip}
\usepackage[margin=2cm]{geometry}
%%%%%%%%%%%%%%%%
% Bibliography %
%%%%%%%%%%%%%%%%
\begin{filecontents}{\jobname.bib}
@article{Doe2011,
author = {Doe, John},
journal = {Nucleic Acids Research},
pages = {1--3},
title = {{Title of paper}},
volume = {39},
year = {2011}
}
@article{Smith2013,
author = {Smith, Josh},
journal = {Nature},
pages = {1--6},
title = {{Overly complicated title}},
volume = {85},
year = {2013}
}
@article{Adams2016,
author = {Adams, Brian},
journal = {Science},
pages = {10--15},
title = {{Another absurd title}},
volume = {2},
year = {2016}
}
@phdthesis{Surname2012,
author = {Surname, Name},
location = {Some University},
title = {{Some suitable thesis name}},
type = {PhD Thesis},
url = {http://thesis},
year = {2012}
}
@misc{Willis2013,
location = {Some Uni},
note = {Work In Progress report},
author = {Willis, William},
title = {{This is the same title always}},
type = {TALK},
month = {07},
year = {2013}
}
@misc{Willis2014,
location = {Another Uni},
note = {Poster Symposium},
author = {Willis, William},
title = {{This is the same title always}},
type = {POSTER},
month = {03},
year = {2014}
}
@misc{Willis2014b,
location = {Yet Another Uni},
author = {Willis, William},
title = {{This is the same title always}},
type = {TALK},
day = {12}, %I include the day in entries in the same month and year
month = {09},
year = {2014}
}
@misc{Willis2014c,
location = {Research Center},
author = {Willis, William},
title = {{This is the same title always}},
type = {TALK},
day = {25}, %I include the day in entries in the same month and year
month = {09},
year = {2014}
}
@misc{Willis2016,
location = {Another Research Center},
author = {Willis, William},
title = {{New title}},
type = {TALK},
month = {09},
year = {2016}
}
\end{filecontents}
\usepackage{xpatch}%
\usepackage[style=verbose, defernumbers=true, sorting=tyn, backend=biber, dateabbrev=true]{biblatex}%
\addbibresource{\jobname.bib}
%%SORTING
\DeclareSortingScheme{tyn}{
\sort{
\field{presort}
}
\sort[final]{
\field{sortkey}
}
\sort{
\field{sorttitle}
\field{title}
}
\sort{
\field{sortyear}
\field{year}
}
\sort{
\field{sortname}
\field{author}
\field{editor}
\field{translator}
\field{sorttitle}
\field{title}
}
\sort{
\field{volume}
\literal{0}
}
}
%%ARTICLE
\DeclareFieldFormat[article]{title}{#1\par}
\DeclareBibliographyDriver{article}{%
\textbf{\printfield{title}}%
\par\vspace{0.1\baselineskip}%
\newblock%
\printnames{author}%
\par\vspace{0.1\baselineskip}%
\newblock%
{%
\small \addfontfeature{Color=lightgray} \itshape%
\usebibmacro{journal+issuetitle}%
\setunit{\space}%
\printfield{pages}%
\newunit%
\printlist{publisher}%
%\setunit*{\addcomma\space}%
%\printfield{year}%included in issuetitle
\newunit%
}
\par\vspace{0.1\baselineskip}%
}
%%THESIS
\DeclareFieldFormat[thesis]{title}{#1\par}
\DeclareBibliographyDriver{thesis}{%
\textbf{\printfield{title}}%
\par\vspace{0.1\baselineskip}%
\newblock%
\printnames{author}%
\par\vspace{0.1\baselineskip}%
\newblock%
{%
\small \addfontfeature{Color=lightgray} \itshape%
\printfield{type}%
\setunit{\addperiod\space}%
\usebibmacro{institution+location+date}%
\setunit{\addperiod\space}%
\printfield{url}%
\newunit%
}
\par\vspace{0.1\baselineskip}
}
%%MISCELLANEA
\DeclareFieldFormat[misc]{title}{#1\\}
\newbibmacro*{bib:svtitle}{%
\savefield{title}{\lasttitle}}
\newbibmacro*{bib:svauthor}{%
\savename{author}{\lastauthor}}
\newbibmacro*{verifytitle}{%
\iffieldequals{title}{\lasttitle}{\hspace{\bibhang}}{%
\printfield{title}%
\undef\lastauthor}%
\usebibmacro{bib:svtitle}%
}
\renewbibmacro*{finentry}{\adddot\finentry}
\newbibmacro*{verifyauthor}{%
\ifnameequals{author}{\lastauthor}
{}
{\printnames{author}\\}%
\usebibmacro{bib:svauthor}}
\newbibmacro*{newtitle}{%
\usebibmacro{verifytitle}}
\newbibmacro*{newauthor}{%
\usebibmacro{verifyauthor}}
\DeclareBibliographyDriver{misc}{%
\textbf{\usebibmacro{newtitle}}%
\usebibmacro{newauthor}%
{%
\scriptsize \textcolor{lightgray}{\faCaretRight}%
}
{%
\footnotesize \addfontfeature{Color=lightgray} \itshape%
\hspace{5px}%
\printfield{type} (\printfield{month} \printfield{year})%
\setunit{\addperiod\space}%
\printfield{note}%
\setunit*{\addcomma\space}%
\printlist{location}%
}
\usebibmacro{finentry}%
}
\newcommand{\printbibsection}[1]{
\begin{refsection}
\nocite{*}
\printbibliography[type={#1}, heading=none]
\end{refsection}
}
\begin{document}
\lipsum[1]
\medskip
\section{Print articles here:}
\printbibsection{article}
\section{Print thesis here:}
\printbibsection{thesis}
\section{Print miscellanea here:}
\printbibsection{misc}
\end{document}
其结果如下:
虽然文章和论文似乎打印正确且顺序正确(可能需要更多测试),但在杂项部分仍然存在一些明显的错误。
这里我合并了标题相同的条目,但第二组条目中也应该出现名称...此外,排序不对,我需要更多最近的条目,就像文章一样。为了强调这一点,我添加了一个额外的条目,在同一个月和年份,但不同的日期(因为我知道我的真实文档中确实有这些案例),因此排序应该是按时间倒序排列,包括年、月和日。
有什么想法吗?我们快到了!
答案1
这是一个可能的解决方案,xpatch
并借用了tyn
以下问题的答案中的排序方案问题在这个网站上。我只考虑了问题中使用的条目类型,并没有检查是否有任何副作用。
\documentclass{article}
\usepackage{amssymb} \usepackage{lipsum}
%%%%%%%%%%
% Colors %
%%%%%%%%%%
\usepackage{xcolor}
\definecolor{lightgray}{HTML}{989898}
\colorlet{textcolor}{lightgray}
%%%%%%%%%
% Fonts %
%%%%%%%%%
\usepackage[quiet]{fontspec}
\defaultfontfeatures{Mapping=tex-text}
\setmainfont[Mapping=tex-text, Color=textcolor]{Arial}
%%%%%%%%%%%%
% Geometry %
%%%%%%%%%%%%
\setlength{\parindent}{0pt}% No paragraph indentation
\setlength{\parskip}{.5\baselineskip plus 0.1\baselineskip minus 0.1\baselineskip}
\usepackage[margin=2cm]{geometry}
%%%%%%%%%%%%%%%%
% Bibliography %
%%%%%%%%%%%%%%%%
\begin{filecontents}{\jobname.bib}
@article{Doe2011,
author = {Doe, John},
journal = {Nucleic Acids Research},
pages = {1--3},
title = {{Title of paper}},
volume = {39},
year = {2011}
}
@article{Smith2013,
author = {Smith, Josh},
journal = {Nature},
pages = {1--6},
title = {{Overly complicated title}},
volume = {85},
year = {2013}
}
@article{Adams2016,
author = {Adams, Brian},
journal = {Science},
pages = {10--15},
title = {{Another absurd title}},
volume = {2},
year = {2016}
}
@thesis{Surname2012,
author = {Surname, Name},
location = {Some University},
title = {{Some suitable thesis name}},
url = {http://thesis},
year = {2012}
}
@misc{Willis2013,
location = {Some Uni},
note = {Work In Progress report},
author = {Willis, William},
title = {{This is the same title always}},
type = {TALK},
month = {07},
year = {2013}
}
@misc{Willis2014,
location = {Another Uni},
note = {Poster Symposium},
author = {Willis, William},
title = {{This is the same title always}},
type = {POSTER},
month = {09},
year = {2014}
}
@misc{Willis2014b,
location = {Yet Another Uni},
author = {Willis, William},
title = {{This is the same title always}},
type = {TALK},
month = {09},
year = {2014}
}
@misc{Willis2015,
location = {Research Center},
author = {Willis, William},
title = {{New title}},
type = {TALK},
month = {09},
year = {2014}
}
\end{filecontents}
\usepackage{xpatch}%
\usepackage[bibstyle=authortitle, defernumbers=true, sorting=tyn]{biblatex}%
\addbibresource{\jobname.bib}
\DeclareSortingScheme{tyn}{
\sort{
\field{presort}
}
\sort[final]{
\field{sortkey}
}
\sort{
\field{sorttitle}
\field{title}
}
\sort{
\field{sortyear}
\field{year}
}
\sort{
\field{sortname}
\field{author}
\field{editor}
\field{translator}
\field{sorttitle}
\field{title}
}
\sort{
\field{volume}
\literal{0}
}
}
\setlength{\bibhang}{2em}
\renewcommand{\newunitpunct}{\\}
\DeclareFieldFormat{type}{\char"25BA\addspace\addthinspace\ifbibstring{#1}{\bibstring{#1}}{#1}}%
\DeclareFieldFormat
[article,inbook,incollection,inproceedings,patent,thesis,unpublished, misc]
{title}{\mkbibbold{#1}}
\xpatchbibmacro{author}{%
\usebibmacro{bbx:dashcheck}
{\bibnamedash}}
{}{}{}
%%
\xpatchbibdriver{article}{%
\usebibmacro{author/translator+others}%
\setunit{\printdelim{nametitledelim}}\newblock
\usebibmacro{title}%
}{%
\usebibmacro{title}\newblock%
\usebibmacro{author/translator+others}%
\setunit{\printdelim{nametitledelim}}%
}{}{}
%%
\xpatchbibdriver{misc}{%
\usebibmacro{author/editor+others/translator+others}%
\setunit{\printdelim{nametitledelim}}\newblock
\usebibmacro{title}%
}{%
\usebibmacro{title}\newblock%
\usebibmacro{author/editor+others/translator+others}%
\setunit{\printdelim{nametitledelim}}%
}{}{}
%%
\xpatchbibdriver{thesis}{%
\usebibmacro{author}%
\setunit{\printdelim{nametitledelim}}\newblock
\usebibmacro{title}%
}{%
\usebibmacro{title}\newblock%
\usebibmacro{author}%
\setunit{\printdelim{nametitledelim}}%
}{}{}
\begin{document}
\lipsum[1]
\nocite{*}
\printbibheading
\printbibliography[type=article,heading=subbibliography,
title={\bfseries Articles}]
\printbibliography[type=thesis, heading=subbibliography,
title={\bfseries Thesis}]
\printbibliography[type=misc, heading=subbibliography,
title={\bfseries Other}]
\end{document}
答案2
下面的代码完成了最初要求的 95%,但由于某种原因,它无法按同一年和同一月的日期条目排序(“研究中心”的谈话是在 2014 年 9 月 25 日,因此应该列在 2014 年 9 月 12 日“Yet Another Uni”的谈话之上)。
我想修复的另一件事是杂项条目末尾句号的颜色(请注意,它是黑色 - 文本的颜色 - 而不是浅灰色)。
我将针对这两个小问题提出一个新问题。
同时,当前代码如下:
\documentclass{article}
\usepackage{amssymb} \usepackage{lipsum}
%%%%%%%%%%
% Colors %
%%%%%%%%%%
\usepackage{xcolor}
\colorlet{textcolor}{black}
%%%%%%%%%
% Fonts %
%%%%%%%%%
\usepackage[quiet]{fontspec}
\defaultfontfeatures{Mapping=tex-text}
\setmainfont[Mapping=tex-text, Color=textcolor]{Arial}
\usepackage{fontawesome}
\newfontfamily{\FA}{FontAwesome}
%%%%%%%%%%%%
% Geometry %
%%%%%%%%%%%%
\setlength{\parindent}{0pt}% No paragraph indentation
\setlength{\parskip}{.5\baselineskip plus 0.1\baselineskip minus 0.1\baselineskip}
\usepackage[margin=2cm]{geometry}
%%%%%%%%%%%%%%%%
% Bibliography %
%%%%%%%%%%%%%%%%
\begin{filecontents}{\jobname.bib}
@article{Doe2011,
author = {Doe, John},
journal = {Nucleic Acids Research},
pages = {1--3},
title = {{Title of paper}},
volume = {39},
year = {2011}
}
@article{Smith2013,
author = {Smith, Josh},
journal = {Nature},
pages = {1--6},
title = {{Overly complicated title}},
volume = {85},
year = {2013}
}
@article{Adams2016,
author = {Adams, Brian},
journal = {Science},
pages = {10--15},
title = {{Another absurd title}},
volume = {2},
year = {2016}
}
@phdthesis{Surname2012,
author = {Surname, Name},
location = {Some University},
title = {{Some suitable thesis name}},
type = {PhD Thesis},
url = {http://thesis},
year = {2012}
}
@misc{Willis2013,
location = {Some Uni},
note = {Work In Progress report},
author = {Willis, William},
title = {{This is the same title always}},
type = {TALK},
month = {07},
year = {2013}
}
@misc{Willis2014,
location = {Another Uni},
note = {Poster Symposium},
author = {Willis, William},
title = {{This is the same title always}},
type = {POSTER},
month = {03},
year = {2014}
}
@misc{Willis2014b,
location = {Yet Another Uni},
author = {Willis, William},
title = {{This is the same title always}},
type = {TALK},
day = {12}, %I include the day in entries in the same month and year
month = {09},
year = {2014}
}
@misc{Willis2014c,
location = {Research Center},
author = {Willis, William},
title = {{This is the same title always}},
type = {TALK},
day = {25}, %I include the day in entries in the same month and year
month = {09},
year = {2014}
}
@misc{Willis2016,
location = {Another Research Center},
author = {Willis, William},
title = {{New title}},
type = {TALK},
month = {09},
year = {2016}
}
\end{filecontents}
\usepackage[style=verbose, defernumbers=true, sorting=ymdnt, backend=biber, dateabbrev=true, maxbibnames=7, minbibnames=7]{biblatex}%
\addbibresource{\jobname.bib}
\DeclareNameAlias{author}{first-last}
%%SORTING
\DeclareSortingScheme{ymdnt}{
\sort{
\field{presort}
}
\sort[final]{
\field{sortkey}
}
\sort[direction=descending]{
\field[strside=left,strwidth=4]{sortyear}
\field[strside=left,strwidth=4]{year}
\literal{9999}
}
\sort[direction=descending]{
\field[padside=left,padwidth=2,padchar=0]{month}
\literal{00}
}
\sort[direction=descending]{
\field[padside=left,padwidth=2,padchar=0]{day}
\literal{00}
}
\sort{
\name{sortname}
\name{author}
\name{editor}
\name{translator}
\field{sorttitle}
\field{title}
}
\sort{
\field{sorttitle}
\field{title}
}
}
%%ARTICLE
\DeclareFieldFormat[article]{title}{#1\par}
\DeclareBibliographyDriver{article}{%
\printfield{title}%
\par\vspace{0.1\baselineskip}%
\newblock%
\printnames{author}%
\par\vspace{0.1\baselineskip}%
\newblock%
{%
\small \addfontfeature{Color=lightgray} \itshape%
\usebibmacro{journal+issuetitle}%
\setunit{\space}%
\printfield{pages}%
\newunit%
\printfield{url}%
}
\par\vspace{0.1\baselineskip}%
}
%%THESIS
\DeclareFieldFormat[thesis]{title}{#1\par}
\DeclareBibliographyDriver{thesis}{%
\printfield{title}%
\par\vspace{0.1\baselineskip}%
\newblock%
\printnames{author}%
\par\vspace{0.1\baselineskip}%
\newblock%
{%
\small \addfontfeature{Color=lightgray} \itshape%
\printfield{type}%
\setunit{\addperiod\space}%
\usebibmacro{institution+location+date}%
\setunit{\addperiod\space}%
\printfield{pages}%
\newunit%
\printfield{url}%
}
\par\vspace{0.1\baselineskip}
}
%%MISCELLANEA
\DeclareFieldFormat[misc]{title}{#1\\}
\newbibmacro*{bib:svtitle}{%
\savefield{title}{\lasttitle}}
\newbibmacro*{bib:svauthor}{%
\savename{author}{\lastauthor}}
\newbibmacro*{verifytitle}{%
\iffieldequals{title}{\lasttitle}{\hspace{\bibhang}}{%
\printfield{title}%
\undef\lastauthor}%
\usebibmacro{bib:svtitle}%
}
\renewbibmacro*{finentry}{\adddot\finentry}
\newbibmacro*{verifyauthor}{%
\ifnameequals{author}{\lastauthor}
{}
{\printnames{author}\\}%
\usebibmacro{bib:svauthor}}
\newbibmacro*{newtitle}{%
\usebibmacro{verifytitle}}
\newbibmacro*{newauthor}{%
\usebibmacro{verifyauthor}}
\DeclareBibliographyDriver{misc}{%
\usebibmacro{newtitle}%
\usebibmacro{newauthor}%
{%
\scriptsize \textcolor{lightgray}{\faCaretRight}%
}
{%
\footnotesize \addfontfeature{Color=lightgray} \itshape%
\hspace{5px}%
\printfield{type} (\printfield{month} \printfield{year})%
\setunit{\addperiod\space}%
\printfield{note}%
\setunit*{\addcomma\space}%
\printlist{location}%
}
\usebibmacro{finentry}%
}
\newcommand{\printbibsection}[1]{
\begin{refsection}
\nocite{*}
\printbibliography[type={#1}, heading=none]
\end{refsection}
}
\begin{document}
\lipsum[1]
\medskip
\section{Articles}
\printbibsection{article}
\section{Thesis}
\printbibsection{thesis}
\section{Miscellanea}
\printbibsection{misc}
\end{document}
其结果为: