
我有一個參考書目,其中包含少量期刊的大量期刊文章。我想縮寫期刊標題,但僅當它出現在\fullcite
命令中時:我希望在參考文獻列表中顯示完整的期刊標題。我怎樣才能做到這一點?引用 bib 檔案中所有條目的解決方案將不起作用,因為它包含許多我不想顯示的條目。以下程式碼在這兩種情況下縮寫了期刊標題。
\documentclass{article}
\usepackage{csquotes}
\usepackage[american]{babel}
\usepackage[style=apa,
backend=biber]{biblatex}
\DeclareLanguageMapping{american}{american-apa}
\begin{filecontents}{\jobname.bib}
@article{art,
Author = {Author, A},
Year = 2006,
Journal = {A Journal With a Long Title},
Number = 1,
Pages = {1-10},
Title = {An Article}
}
\end{filecontents}
\addbibresource{\jobname.bib}
\DeclareSourcemap{
\maps[datatype=bibtex,overwrite=true]{
\map{
\step[fieldsource=journal,
match=\regexp{A\sJournal\sWith\sa\sLong\sTitle},
replace={Journ}]
}
}
}
\begin{document}
\fullcite{art}
\printbibliography
\end{document}
答案1
您可以這樣做:首先,稍微修改您的 Sourcemapping:
\DeclareSourcemap{
\maps[datatype=bibtex,overwrite=true]{
\map{
\step[fieldsource=journal,
match=\regexp{A\sJournal\sWith\sa\sLong\sTitle},
fieldset=shortjournal, fieldvalue={Journ}
% replace={Journ}
]
}
}
}
接下來,建立一個布林開關:
\providebool{use:shortjournal}
然後,重新定義journal
bibmacro(取自biblatex.def
)以合併布林值。然而,因為這會產生一定程度的巢狀和重複,所以最好根據一些新的 bibmacros 重新定義原始巨集。也就是說,取原來的定義:
% Original definition (from biblatex.def)
% \newbibmacro*{journal}{%
% \iffieldundef{journaltitle}
% {}
% {\printtext[journaltitle]{%
% \printfield[titlecase]{journaltitle}%
% \setunit{\subtitlepunct}%
% \printfield[titlecase]{journalsubtitle}}}}
並重新表達它,使其看起來像這樣:
\renewbibmacro*{journal}{%
\ifbool{use:shortjournal}%
{\iffieldundef{shortjournal}%
{\usebibmacro{origjournal}}%
{\usebibmacro{shortjournal}}%
}%
{\usebibmacro{origjournal}}%
}
這依賴 shortjournal
和origjournal
bibmacros (其中orig
表示我只是回收原始的journal
bibmacros):
\newbibmacro*{shortjournal}{%
\printtext[journaltitle]{%
\printfield[titlecase]{shortjournal}%
\setunit{\subtitlepunct}%
\printfield[titlecase]{journalsubtitle}}%
}
\newbibmacro*{origjournal}{%
\iffieldundef{journaltitle}
{}
{\printtext[journaltitle]{%
\printfield[titlecase]{journaltitle}%
\setunit{\subtitlepunct}%
\printfield[titlecase]{journalsubtitle}}}%
}
最後,添加布林開關\fullcite
。 (請注意\makeatletter
和\makeatother
:如果直接進入文件,則需要它們.tex
。)
\makeatletter
\DeclareCiteCommand{\fullcite}
{\renewcommand{\finalnamedelim}{\ifnum\value{liststop}>2 \finalandcomma\fi\addspace\&\space}%
\usebibmacro{prenote}}
{\usedriver
{\DeclareNameAlias{sortname}{default}%
\booltrue{use:shortjournal}%
\global\boolfalse{bbx:parens}%
\global\boolfalse{bbx:volseen}%
\global\boolfalse{bbx:titleinauthpos}%
\global\boolfalse{bbx:editorinauthpos}%
\global\boolfalse{bbx:in}%
\global\let\blx@related@loop\@empty}
{\thefield{entrytype}}}
{\multicitedelim}
{\boolfalse{use:shortjournal}%
\usebibmacro{postnote}%
\usebibmacro{cite:post}}
\makeatother
把它們放在一起:
\documentclass{article}
\usepackage{csquotes}
\usepackage[american]{babel}
\usepackage[style=apa,
backend=biber]{biblatex}
\DeclareLanguageMapping{american}{american-apa}
\usepackage{filecontents}
\begin{filecontents*}{\jobname.bib}
@article{art,
Author = {Author, A},
Year = 2006,
Journal = {A Journal With a Long Title},
Number = 1,
Pages = {1-10},
Title = {An Article}
}
@article{art2,
Author = {Author, A},
Year = 2006,
Journal = {A Journal With a Non-Matching Long Title},
Number = 1,
Pages = {1-10},
Title = {An Article}
}
\end{filecontents*}
\addbibresource{\jobname.bib}
% Step 1.
\DeclareSourcemap{
\maps[datatype=bibtex,overwrite=true]{
\map{
\step[fieldsource=journal,
match=\regexp{A\sJournal\sWith\sa\sLong\sTitle},
fieldset=shortjournal, fieldvalue={Journ}
% replace={Journ}
]
}
}
}
% Step 2.
\providebool{use:shortjournal}
% Step 3.
% Original definition (from biblatex.def)
% \newbibmacro*{journal}{%
% \iffieldundef{journaltitle}
% {}
% {\printtext[journaltitle]{%
% \printfield[titlecase]{journaltitle}%
% \setunit{\subtitlepunct}%
% \printfield[titlecase]{journalsubtitle}}}}
\newbibmacro*{shortjournal}{%
\printtext[journaltitle]{%
\printfield[titlecase]{shortjournal}%
\setunit{\subtitlepunct}%
\printfield[titlecase]{journalsubtitle}}%
}
\newbibmacro*{origjournal}{%
\iffieldundef{journaltitle}
{}
{\printtext[journaltitle]{%
\printfield[titlecase]{journaltitle}%
\setunit{\subtitlepunct}%
\printfield[titlecase]{journalsubtitle}}}%
}
\renewbibmacro*{journal}{%
\ifbool{use:shortjournal}%
{\iffieldundef{shortjournal}%
{\usebibmacro{origjournal}}%
{\usebibmacro{shortjournal}}%
}%
{\usebibmacro{origjournal}}%
}
% Step 4.
\makeatletter
\DeclareCiteCommand{\fullcite}
{\renewcommand{\finalnamedelim}{\ifnum\value{liststop}>2 \finalandcomma\fi\addspace\&\space}%
\usebibmacro{prenote}}
{\usedriver
{\DeclareNameAlias{sortname}{default}%
\booltrue{use:shortjournal}% <-- the added line
\global\boolfalse{bbx:parens}%
\global\boolfalse{bbx:volseen}%
\global\boolfalse{bbx:titleinauthpos}%
\global\boolfalse{bbx:editorinauthpos}%
\global\boolfalse{bbx:in}%
\global\let\blx@related@loop\@empty}
{\thefield{entrytype}}}
{\multicitedelim}
{\usebibmacro{postnote}%
\usebibmacro{cite:post}}
\makeatother
\begin{document}
\parindent0pt
\fullcite{art}\par
\fullcite{art2}\par
\printbibliography
\end{document}
答案2
我不知道這個技巧是否適合你,但是將整個文件放在一個假refsection下並添加[refsection=1]
選項map
:
\documentclass{article}
\usepackage{csquotes}
\usepackage[american]{babel}
\usepackage[style=apa,
backend=biber]{biblatex}
\DeclareLanguageMapping{american}{american-apa}
% Declare an ad hoc category
\DeclareBibliographyCategory{quack}
% Renew fullcite command
\let\oldfullcite\fullcite % this in necessary to renew the command with the same name
\renewcommand*{\fullcite}[2][]{\addtocategory{quack}{#2}\oldfullcite[#1]{#2}}
\begin{filecontents}{\jobname.bib}
@article{art,
Author = {Author, A},
Year = 2006,
Journal = {A Journal With a Long Title},
Number = 1,
Pages = {1-10},
Title = {An Article}
}
@article{noinbib,
Author = {Buthor, A},
Year = 2006,
Journal = {A Journal With a Long Title},
Number = 1,
Pages = {1-10},
Title = {An Article that should not be listed in bibliography}
}
\end{filecontents}
\DeclareSourcemap{
\maps[datatype=bibtex,overwrite=true]{
\map[refsection=1]{% with refsection=<n> the map is valid only for the refsection with <n> number
\step[fieldsource=journal,
match=\regexp{A\sJournal\sWith\sa\sLong\sTitle},
replace={Journ}]
}
}
}
\addbibresource{\jobname.bib}
\begin{document}
\begin{refsection}% fake refsection
%\therefsection % use this to discover the number of the refsection
\section{Title 1}
A citation: \fullcite{art}
some text
\section{Title 2}
Some other text and
another citation: \fullcite{art}
\end{refsection}
\nocite{*}
\printbibliography[category=quack]
\end{document}
PS = 它僅適用於最新版本的biblatex
/biber
軟體包,請參閱這裡。
編輯:我已經根據您在評論中的要求更新了答案。
我創建了一個特別指定類別,以便.bib
在最終參考書目中僅列出引用的參考文獻(不是文件中的所有參考文獻)。
請注意,如果使用除此之外的某種引用fullcite
,則必須類似地更新相關命令。