在 \fullcite 命令中缩写期刊标题

在 \fullcite 命令中缩写期刊标题

我有一个参考书目,其中包含来自少数期刊的大量期刊文章。我想缩写期刊名称,但仅当它出现在命令中时\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}

然后,重新定义journalbibmacro(取自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}}%
}

这依赖于 shortjournalorigjournalbibmacros(其中orig表示我只是回收原始journalbibmacro):

\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}

短篇日志.png

答案2

我不知道这个技巧是否适合你,但将整个文档放在一个假的引用部分下并添加[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,则必须类似地更新相关命令。

相关内容