编辑:

编辑:

我必须为我的论文撰写一篇文献综述。在综述中,我必须使用引用作品的“简写”名称,例如“S001”和“S002”分别表示要引用的第一部作品和第二部作品。

在后面的章节中必须使用作者(年份)格式。不幸的是,这两种格式会混淆。我没有找到合适的解决方案,有人可以帮忙吗?

“最小”代码示例的结果

    \begin{filecontents}{myfilea.bib}
@book{goossens93,
    author    = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
    title     = "The LaTeX Companion",
    year      = "1993",
%    shorthand = "GMS"
}

@book{else2015,
    author    = "Someone Else",
    title     = "Interesting thing.",
    year      = "2015",
    shorthand = "ElseShort",
}

@article{borges2018,
    author = {Borges, M.  and Barros, E.  and Maia, P. H.},
    title = {Cloud restriction solver: A refactoring-based approach to migrate applications to the cloud},
    journal = {Information and Software Technology},
    uuid = {52D09357-6BA8-4CB1-91B8-8C4CDD7E351B},
    volume = {95},
    pages = {346-365},
    shorthand = {S002},
    year = {2018},
}
\end{filecontents}

\documentclass{article}

    \usepackage[automark, draft=false]{scrlayer-scrpage}
    \setcounter{secnumdepth}{3}
    \setcounter{tocdepth}{3}
    \usepackage[utf8]{inputenc}
    \usepackage[T1]{fontenc}
    \usepackage{lmodern}
    \usepackage{mathptmx}
    \usepackage{courier}
    \usepackage[protrusion,factor=900]{microtype}
    \usepackage{setspace}
    \usepackage{printlen}


\usepackage[backend=biber, %% Hilfsprogramm "biber" (statt "biblatex" oder "bibtex")
                style=authoryear, %% Zitierstil: Authorennamen lang [Jahr]
            bibencoding=utf8,
                natbib=true, %% Bereitstellen von natbib-kompatiblen Zitierkommandos
                backref=true, %% Seiten anzeigen, auf denen die Referenz vorkommt
                ibidtracker=context, %% EBENDA-Anzeige bei mehrfachen Zitierungen der selben Quelle auf einer Seite 
                block=space, %% kleiner horizontaler Platz zwischen den Feldern
                isbn=false, %% ISBN nicht anzeigen, gleiches geht mit nahezu allen anderen Feldern
                url=false, %% Url-Feld wird ausgeblendet. Ausnahme: Online-Typ
                pagetracker=true, %% ebd. bei wiederholten Angaben (false=ausgeschaltet, page=Seite, spread=Doppelseite, true=automatisch)
                citetracker=true, % Wird benötigt für kapitelweise Referenzen?
                sorting=nyt, % To get an sorted bibliography
                ]{biblatex}

% "notoccite" prevents cites in captions from misnumbering of references
\usepackage{notoccite}


% ibidem: Wenn Fußnoten mehrfach auf der selben Seite zur selben Quelle führen, so schreibe "ibidem" (=ebenda).
\providecommand*{\mkibid}[1]{#1}
\DeclareCiteCommand{\footpartcite}[\mkbibfootnote]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}
     {\printtext[bibhyperref]{\bibstring[\mkibid]{ibidem}}}
     {\printtext[brackets]{\usebibmacro{cite}}%
      \setunit{\addnbspace}%
      \printnames{labelname}%
      \setunit{\labelnamepunct}%
      \printfield[citetitle]{title}%
      \newunit
      \printfield{year}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}


%\usepackage[backend=biber,citestyle=authoryear]{biblatex}
\addbibresource{myfilea.bib}

\begin{document}

In my case I want to use the author (year) citation style: \citet{goossens93}.

But something went wrong: When I use shorthand within a bib element, shorthand and the authoryear will be mixed up: \citet{else2015} 

This is only the "shorthand"-style which I need also within my work: \cite{borges2018}. 

And this is the the Author (year) combination -- unfortunately it wrotes the shorthand into the year part!: \citet{borges2018}.

\end{document}

编辑:

这就是我想要达到的目标:

在此处输入图片描述

我现在添加一个新的代码示例:

\begin{filecontents}{myfile.bib}
@book{goossens93,
    author    = "Michel Goossens and Frank Mittelbach and Alexander Samarin",
    title     = "The LaTeX Companion",
    year      = "1993",
%    shorthand = "GMS"
}

@book{else2015,
    author    = "Someone Else",
    title     = "Interesting thing.",
    year      = "2015",
    shorthand = "S003",
}

@article{borges2018,
    author = {Borges, M.  and Barros, E.  and Maia, P. H.},
    title = {Cloud restriction solver: A refactoring-based approach to migrate applications to the cloud},
    journal = {Information and Software Technology},
    uuid = {52D09357-6BA8-4CB1-91B8-8C4CDD7E351B},
    volume = {95},
    pages = {346-365},
    shorthand = {S002},
    year = {2018},
}
\end{filecontents}

\documentclass{article}

    \usepackage[automark, draft=false]{scrlayer-scrpage}
    \setcounter{secnumdepth}{3}
    \setcounter{tocdepth}{3}
    \usepackage[utf8]{inputenc}
    \usepackage[T1]{fontenc}
    \usepackage{lmodern}
    \usepackage{mathptmx}
    \usepackage{courier}
    \usepackage[protrusion,factor=900]{microtype}
    \usepackage{setspace}
    \usepackage{printlen}
\usepackage{longtable} %needed for longtab
\LTchunksize=8 %% Row count for simplify pagebreak for longtabu environment

%% Needed for labelling longtabu!
\usepackage{caption}
\DeclareCaptionLabelSeparator{tableNewline}{\par} 
\captionsetup{
  justification=centering,
  labelsep=quad,
  }
\captionsetup[longtable]{
  justification=centering,
  labelsep=quad,
  }

\usepackage{tabu}
\usepackage{hhline} % Needed for longtabu when two hlines (==) should be drawn.

\usepackage{tabularx}
\usepackage{booktabs} %Professionelle Tabellen

\usepackage[backend=biber, %% Hilfsprogramm "biber" (statt "biblatex" oder "bibtex")
                style=authoryear, %% Zitierstil: Authorennamen lang [Jahr]
            bibencoding=utf8,
                natbib=true, %% Bereitstellen von natbib-kompatiblen Zitierkommandos
                backref=true, %% Seiten anzeigen, auf denen die Referenz vorkommt
                ibidtracker=context, %% EBENDA-Anzeige bei mehrfachen Zitierungen der selben Quelle auf einer Seite 
                block=space, %% kleiner horizontaler Platz zwischen den Feldern
                isbn=false, %% ISBN nicht anzeigen, gleiches geht mit nahezu allen anderen Feldern
                url=false, %% Url-Feld wird ausgeblendet. Ausnahme: Online-Typ
                pagetracker=true, %% ebd. bei wiederholten Angaben (false=ausgeschaltet, page=Seite, spread=Doppelseite, true=automatisch)
                citetracker=true, % Wird benötigt für kapitelweise Referenzen?
                sorting=nyt, % To get an sorted bibliography
                ]{biblatex}

\usepackage[%
% Standard options
final=true,%
pageanchor=true,%
pagebackref=false,%
hyperindex=true,%
hyperfootnotes=true,%
linktocpage=false,%
breaklinks=false,%
colorlinks=true,%
% PDF options
bookmarks=true,
bookmarksopen=true,%
bookmarksopenlevel=1,%
pdfhighlight=/N,%
allbordercolors={0.85 0.85 1},
citebordercolor={1 1 1},
urlbordercolor={1 1 1},%
% PDF entries
pdftitle={\mydoctitle},%
pdfauthor={\myname},%
pdfsubject={\mysubject},%
pdfcreator={Thomas Salzmann},%
pdfproducer={LaTeX},%
pdfkeywords={\mykeywords},%
% PDF misc settings
pdfstartpage=1,% Start PDF Viewer on Page 1
pdfduplex=Simplex,%
pdfpagelabels=true,%
pdfprintscaling=None,%
citecolor=blue,%
filecolor=blue,%
linkcolor=blue,%
urlcolor=black,%
]{hyperref}

% "notoccite" prevents cites in captions from misnumbering of references
\usepackage{notoccite}

\newcommand{\citeNotAsShorthand}[2][blue]{\textcolor{#1}{\citeauthor{#2} (\citeyear{#2}) [\citefield{#2}{shorthand}]}}

% ibidem: Wenn Fußnoten mehrfach auf der selben Seite zur selben Quelle führen, so schreibe "ibidem" (=ebenda).
\providecommand*{\mkibid}[1]{#1}
\DeclareCiteCommand{\footpartcite}[\mkbibfootnote]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \ifthenelse{\ifciteibid\AND\NOT\iffirstonpage}
     {\printtext[bibhyperref]{\bibstring[\mkibid]{ibidem}}}
     {\printtext[brackets]{\usebibmacro{cite}}%
      \setunit{\addnbspace}%
      \printnames{labelname}%
      \setunit{\labelnamepunct}%
      \printfield[citetitle]{title}%
      \newunit
      \printfield{year}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}


%\usepackage[backend=biber,citestyle=authoryear]{biblatex}
\addbibresource{myfile.bib}

\begin{document}

In my case I want to use the author (year) citation style: \citet{goossens93}.

But something went wrong: When I use shorthand within a bib element, shorthand and the authoryear will be mixed up: \citet{else2015} 

This is only the "shorthand"-style which I need also within my work: \cite{borges2018}. 

And this is the the Author (year) combination -- unfortunately it wrotes the shorthand into the year part!: \citet{borges2018}.

What I want is this version: \citeNotAsShorthand{borges2018}


\begin{longtabu} to \textwidth {| l | X[1.5,l] %aligned left, twice as wide as second column
                                | X[1,l] |} %aligned left

% Table header on first page of table
    \caption{Table of excluded studies during title- and abstract analysis} \tabularnewline  
    \hline %\toprule
    \thead{Study}& \thead{Title of excluded study (year)} & \thead{reason for exclusion} \tabularnewline 
    \hhline{===}
 %\toprule
    \endfirsthead

% Table header on every other page of table
    \caption{Table of excluded studies during title- and abstract analysis (continued)} \tabularnewline          
    \hline %\toprule
    \thead{Study}& \thead{Title of excluded study (year)} & \thead{reason for exclusion} \tabularnewline 
    \hhline{===}
    \endhead
% End of header

% SCOPUS-search new:
\cite{else2015} & \citetitle{else2015} (\citeyear{else2015}) & Primary focus is not on product management. Focus is on side effects of programs from coding perspective.  \tabularnewline 
\cite{borges2018} &  \citetitle{borges2018} (\citeyear{borges2018}) & Grey literature (article in press). \tabularnewline 
\end{longtabu}

\printbiblist[title={List of relevant studies found during literature review},notkeyword=LRexcluded]{shorthand}

\printbibliography[segment=3,heading=subbibliography]

\end{document}

答案1

正如所提到的https://github.com/plk/biblatex/issues/569 \textcite/\citet不仅仅是\cite在年份周围加上括号。如果您使用前后注释,比较\cite[cf.][380]{sigfridsson}\textcite[cf.][380]{sigfridsson},您还会看到不同的行为。

参见Sigfridsson 和 Ryde 1998,第 154 页。 380//Sigfridsson 和 Ryde(参见 1998 年,第 381 页)

这个想法是,\textcite在像 这样的句子中, 用作句子的主语\Textcite{sigfridsson} found that ...。为了确保所有\textcites 的语法结构相同,它将显示作者 ( shorthand)如果shorthand给出了字段。

\cite如果你想要在年份周围使用括号的通常行为,我建议你尝试biblatex-ext及其引用分隔符功能(§5.3引用命令的分隔符文档biblatex-ext)。

\DeclareInnerCiteDelims{cite}{\bibopenparen}{\bibcloseparen}

应该能给你你想要的东西。

此外,我认为研究 ID最好通过专用字段而不是 来处理shorthand。因此,在下面的示例中,我创建了一个新字段studyid。如果有一种算法方式来分配研究 ID,则可以进一步实现自动化(这可以成为一个很好的后续问题),目前您必须在 中手动分配字段值.bibstudyid被声明为标签字段,以便我们可以\printbiblist轻松使用。

我们定义了两个 cite 宏\citewid\citeonlyid.\citewid显示引用并与研究 ID 一起显示。\citeonlyid仅显示研究 ID。

最后,我们设置了所需的一切\printbiblist

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\usepackage{filecontents}
\begin{filecontents*}{studyid.dbx}
\DeclareDatamodelFields[type=field,datatype=literal,label=true]{studyid}
\DeclareDatamodelEntryfields{studyid}
\end{filecontents*}

\usepackage[backend=biber, style=ext-authoryear, datamodel=studyid]{biblatex}

% \cite should give author (year)
\DeclareInnerCiteDelims{cite}{\bibopenparen}{\bibcloseparen}

% define \citewid: author (year) [study-id]
\RegisterCiteDelims{outer}{citewid}
\RegisterCiteDelims{inner}{citewid}
\DeclareInnerCiteDelimsAlias{citewid}{cite}
\DeclareFieldAlias{extblx@innercitewiddelims}{extblx@innercitedelims}

\DeclareFieldFormat{citestudyid}{\mkbibbrackets{S#1}}

\newbibmacro*{citewid}{%
  \usebibmacro{cite}%
  \setunit{\addspace}%
  \printfield[citestudyid]{studyid}}

\DeclareCiteCommand{\citewid}[\mkoutercitewiddelims]
  {\usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{citewid}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

% define \citeonlyid: [study-id]
\RegisterCiteDelims{outer}{citeonlyid}
\DeclareOuterCiteDelims{citeonlyid}{\bibopenbracket}{\bibclosebracket}
\DeclareCiteCommand{\citeonlyid}[\mkouterciteonlyiddelims]
  {\usebibmacro{prenote}}
  {\iffieldundef{studyid}
     {\PackageWarning{biblatex}{%
      No 'studyid' in entry '\thefield{entrykey}'.\MessageBreak
      Add the 'studyid' field\MessageBreak
      or don't cite this entry with\MessageBreak
      '\string\citeonlyid'}}
     {\printfield[studyidwidth]{studyid}}}
  {\multicitedelim}
  {\usebibmacro{postnote}}

% \printbiblist similar to shorthand definitions
\DeclareBibliographyDriver{studyid}{%
  \usedriver
    {}
    {\thefield{entrytype}}%
  \finentry}

\DeclareFieldFormat{studyidwidth}{S#1}
\defbibenvironment{studyid}
  {\list
     {\printfield[studyidwidth]{studyid}}
     {\setlength{\labelwidth}{\studyidwidth}%
      \setlength{\leftmargin}{\labelwidth}%
      \setlength{\labelsep}{\biblabelsep}%
      \addtolength{\leftmargin}{\labelsep}%
      \setlength{\itemsep}{\bibitemsep}%
      \setlength{\parsep}{\bibparsep}%
      \renewcommand*{\makelabel}[1]{##1\hss}}}
  {\endlist}
  {\item}

\DeclareSortingTemplate{studyid}{
  \sort{
    \field{studyid}
  }
}

\begin{filecontents}{\jobname.bib}
@article{borges2018,
  author    = {Borges, M.  and Barros, E.  and Maia, P. H.},
  title     = {Cloud restriction solver:
               A refactoring-based approach to migrate applications to the cloud},
  journal   = {Information and Software Technology},
  volume    = {95},
  pages     = {346-365},
  year      = {2018},
  studyid   = {002},
}
@article{licht2009,
  author  = {Licht, Carmilla M. M. and de Geus, Eco J. C.
             and van Dyck, Richard and Penninx, Brenda W. J. H.},
  title   = {Association between anxiety disorders and
             heart rate variability in {The} {Netherlands} {Study} of
             {Depression} and {Anxiety} ({NESDA})},
  journal = {Psychosomatic medicine},
  volume  = {71},
  number  = {5},
  pages   = {508--518},
  doi     = {10.1097/PSY.0b013e3181a292a6},
  date    = {2009},
  studyid = {001},
}
\end{filecontents}

\addbibresource{\jobname.bib}
\addbibresource{biblatex-examples.bib}

\begin{document}
\cite{sigfridsson}

\cite{borges2018}

\citewid{borges2018}

\citeonlyid{borges2018,licht2009}

\printbiblist[title=List of studies]{studyid}

\printbibliography
\end{document}

引文内容为“Sigfridsson and Ryde (1998)”、“Borges, Barros, and Maia (2018)”、“Borges, Barros, and Maia (2018) [S002]”、“[S002; S001]”。MWE 还包含一个研究列表,其中“标签”位置有数字,并附有常规参考书目。

答案2

谢谢你的提示。

我现在添加了两个命令:

\newcommand{\citeNotAsShorthand}[1]{{\citeauthor{#1} (\citeyear{#1})}}%

\newcommand{\citeNotAsShorthanda}[2][blue]{\color{#1}{\citeauthor{#2} (\citeyear{#2}) [\citefield{#2}{shorthand}]}}

当我使用:\citet{IWSPM2016:Linaker2016} 时,将会打印“Linåker and Wnuk (S030)”。

当我使用 \citeNotAsShorthand{IWSPM2016:Linaker2016} 时,将打印“Linåker and Wnuk (2016)” - 这非常好。

并且 \citeNotAsShorthanda{IWSPM2016:Linaker2016} 打印“Linåker and Wnuk (2016) [S030]”。

伟大的!

相关内容