我收到了一个很棒的参考书目自定义代码,它很棒,但现在(突然?)参考书目中的年份前面有大空格(biblatex
)。我该如何去掉它们?
\documentclass[a4paper,12pt,numbers=endperiod]{scrartcl}
\usepackage[left=2.5cm,right=2.5cm,top=2.5cm,bottom=2cm,footskip=1cm]{geometry}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage{caption}
\usepackage{filecontents}
\usepackage{lipsum}
\usepackage{lmodern}
\usepackage{CJKutf8}
\usepackage[footnote,printonlyused]{acronym}
\usepackage[utf8]{inputenc}
\usepackage[T2A,T1]{fontenc}
\usepackage[russian,ngerman]{babel}
\usepackage{tipa}
\usepackage{csquotes}
\usepackage[nottoc,notlot,notlof]{tocbibind}
\usepackage[backend=biber,style=authoryear,sorting=nyt]{biblatex}
\addbibresource{graphematik.bib}
\DefineBibliographyStrings{ngerman}{references={Bibliographie}}
\DeclareFieldFormat{superedition}{\textsuperscript{#1}}
\DeclareNameAlias{sortname}{last-first}
\renewbibmacro*{date+extrayear}{\iffieldundef{\thefield{datelabelsource}year}{}{\printtext[parens]{ \iffieldnum{edition}{\printfield[superedition]{edition}\global\clearfield{edition}}{} \iffieldsequal{year}{\thefield{datelabelsource}year}{\printdateextralabel}{\printfield{labelyear} \printfield{extrayear}}}}}
\renewcommand*{\bibpagespunct}{\addcolon\space}
\DeclareFieldFormat{pages}{#1}
\DeclareFieldFormat{editortype}{\mkbibparens{#1}}
\renewbibmacro*{byeditor+others}{\ifnameundef{editor}{}{\printnames[byeditor]{editor}\setunit{\addspace} \usebibmacro{byeditor+othersstrg}\clearname{editor}\newunit}\usebibmacro{byeditorx} \usebibmacro{bytranslator+others}}
\renewbibmacro*{byeditor+othersstrg}{\usebibmacro{editor+othersstrg}}
\renewbibmacro*{bytranslator+othersstrg}{\usebibmacro{translator+othersstrg}}
\renewbibmacro*{bytypestrg}[2]{\iffieldundef{#1type}{\bibstring{#2}}{\ifbibxstring{\thefield{#1type}} {\bibstring{\thefield{#1type}}}{\printtext{\thefield{#1type}}}}}
\renewcommand*{\multinamedelim}{/}
\renewcommand*{\finalnamedelim}{/}
\renewcommand*{\postnotedelim}{\addcolon\space}
\DeclareFieldFormat{postnote}{#1}
\DeclareFieldFormat{multipostnote}{#1}
\begin{document}
A book.\parencite[][]{altmann2010}
@Book{altmann2010,
Title = {Prüfungswissen Phonetik, Phonologie und Graphemik. Arbeitstechniken – Klausurfragen – Lösungen},
Author = {Altmann, Hans and Ziegenhain, Ute},
Location = {Göttingen},
Publisher = {Vandenhoeck \& Ruprecht},
Year = {2010},
Edition = {3}
}
An article.\parencite[][]{berg2012}
@Article{berg2012,
Title = {Identifying graphematic units. Vowel and consonant letters},
Author = {Berg, Kristian},
Journal = {Written Language \& Literacy},
Pages = {26--45},
Volume = {15},
Year = {2012}
}
An inbook.\parencite[][]{fayol2014}
@Inbook{fayol2014,
Title = {Written Language: Learning to Read and to Spell},
Author = {Fayol, Michael},
Booktitle = {Manual of Language Acquisition (Manuals of Romance Linguistics 2)},
Location = {Berlin/Boston},
Pages = {162--178},
Publisher = {de Gruyter},
Year = {2014},
Editor = {Christiane Fäcke}
}
\printbibliography[heading=bibintoc]
\end{document}
答案1
问题在于以下行中的空格:
\renewbibmacro*{date+extrayear}{\iffieldundef{\thefield{datelabelsource}year}{}{\printtext[parens]{ \iffieldnum{edition}{\printfield[superedition]{edition}\global\clearfield{edition}}{} \iffieldsequal{year}{\thefield{datelabelsource}year}{\printdateextralabel}{\printfield{labelyear} \printfield{extrayear}}}}}
IE
\printtext[parens]{
和\iffieldnum{edition}
\global\clearfield{edition}}{}
和\iffieldsequal{year}
应将其关闭为:
\renewbibmacro*{date+extrayear}{%
\iffieldundef{\thefield{datelabelsource}year}%
{}{%
\printtext[parens]{%
\iffieldnum{edition}{\printfield[superedition]{edition}\global\clearfield{edition}}{}%
\iffieldsequal{year}{\thefield{datelabelsource}year}%
{\printdateextralabel}{\printfield{labelyear}\printfield{extrayear}}%
}%
}%
}
修正后的 MWE:
\documentclass[a4paper,12pt,numbers=endperiod]{scrartcl}
\usepackage[left=2.5cm,right=2.5cm,top=2.5cm,bottom=2cm,footskip=1cm]{geometry}
\usepackage{graphicx}
\usepackage{setspace}
\usepackage{caption}
\usepackage{filecontents}
\usepackage{lipsum}
\usepackage{lmodern}
\usepackage{CJKutf8}
\usepackage[footnote,printonlyused]{acronym}
\usepackage[utf8]{inputenc}
\usepackage[T2A,T1]{fontenc}
\usepackage[russian,ngerman]{babel}
\usepackage{tipa}
\usepackage{csquotes}
\usepackage[nottoc,notlot,notlof]{tocbibind}
\usepackage[backend=biber,style=authoryear,sorting=nyt]{biblatex}
\begin{filecontents}{graphematik.bib}
@Book{altmann2010,
Title = {Prüfungswissen Phonetik, Phonologie und Graphemik. Arbeitstechniken Klausurfragen Lösungen},
Author = {Altmann, Hans and Ziegenhain, Ute},
Location = {Göttingen},
Publisher = {Vandenhoeck \& Ruprecht},
Year = {2010},
Edition = {3}
}
@Article{berg2012,
Title = {Identifying graphematic units. Vowel and consonant letters},
Author = {Berg, Kristian},
Journal = {Written Language \& Literacy},
Pages = {26--45},
Volume = {15},
Year = {2012}
}
@Inbook{fayol2014,
Title = {Written Language: Learning to Read and to Spell},
Author = {Fayol, Michael},
Booktitle = {Manual of Language Acquisition (Manuals of Romance Linguistics 2)},
Location = {Berlin/Boston},
Pages = {162--178},
Publisher = {de Gruyter},
Year = {2014},
Editor = {Christiane Fäcke}
}
\end{filecontents}
\addbibresource{graphematik.bib}
\DefineBibliographyStrings{ngerman}{references={Bibliographie}}
\DefineBibliographyStrings{ngerman}{references={Bibliographie}}
\DeclareFieldFormat{superedition}{\textsuperscript{#1}}
\DeclareNameAlias{sortname}{last-first}
\renewbibmacro*{date+extrayear}{%
\iffieldundef{\thefield{datelabelsource}year}%
{}{%
\printtext[parens]{%
\iffieldnum{edition}{\printfield[superedition]{edition}\global\clearfield{edition}}{}%
\iffieldsequal{year}{\thefield{datelabelsource}year}%
{\printdateextralabel}{\printfield{labelyear}\printfield{extrayear}}%
}%
}%
}
\renewcommand*{\bibpagespunct}{\addcolon\space}
\DeclareFieldFormat{pages}{#1}
\DeclareFieldFormat{editortype}{\mkbibparens{#1}}
\renewbibmacro*{byeditor+others}{%
\ifnameundef{editor}
{}{%
\printnames[byeditor]{editor}%
\setunit{\addspace}%
\usebibmacro{byeditor+othersstrg}%
\clearname{editor}\newunit%
}%
\usebibmacro{byeditorx}%
\usebibmacro{bytranslator+others}%
}
\renewbibmacro*{byeditor+othersstrg}{\usebibmacro{editor+othersstrg}}
\renewbibmacro*{bytranslator+othersstrg}{\usebibmacro{translator+othersstrg}}
\renewbibmacro*{bytypestrg}[2]{%
\iffieldundef{#1type}{\bibstring{#2}}{%
\ifbibxstring{\thefield{#1type}}%
{\bibstring{\thefield{#1type}}}{\printtext{\thefield{#1type}}}%
}%
}
\renewcommand*{\multinamedelim}{/}
\renewcommand*{\finalnamedelim}{/}
\renewcommand*{\postnotedelim}{\addcolon\space}
\DeclareFieldFormat{postnote}{#1}
\DeclareFieldFormat{multipostnote}{#1}
\begin{document}
A book. \parencite[][]{altmann2010}
An inbook. \parencite[][]{fayol2014}
An article. \parencite[][]{berg2012}
\printbibliography[heading=bibintoc]
\end{document}