一个文档中包含两个参考列表

一个文档中包含两个参考列表

我需要为文内引用创建自定义命令,以便将条目自动添加到两个表中,如图所示我需要的

根据引用的文档类型

我正在尝试对此进行一些操作,到目前为止,下面的代码产生了类似这样的结果。因此,我不知道是否可以根据使用的命令(ADcitevs RDcite)或基于 *bib 文件(usera字段)中的条目以某种方式决定描述应归入哪个参考列表。一般来说,是否可以制作两个列表?您能帮忙吗?

我现在拥有的

\documentclass{article}
\usepackage[style=numeric, backend=biber]{biblatex}
\usepackage{biblatex-ext-tabular}
\usepackage{biblatex}
\usepackage[table,dvipsnames]{xcolor}
\usepackage{multirow}
\usepackage[hypcap=false]{caption}
\usepackage{longtable}
\usepackage{hyperref}



\newcolumntype{L}[1]{%
  >{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}
\newcolumntype{C}[1]{%
  >{\centering\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}

\definecolor{lightgray}{gray}{0.9}



\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=identifier, fieldtarget=userb]
    }
    \map{
      \step[fieldsource=revision, fieldtarget=userc]
    }
    % Map entries to the "AD" category if "bibtype" is "AD"
    \map[overwrite]
    {
      \step[fieldsource=usera, match=\regexp{AD}, final]
      %\step[category=AD, final]
    }
    % Map entries to the "RD" category if "bibtype" is "RD"
    \map[overwrite]
    {
      \step[fieldsource=usera, match=\regexp{RD}, final]
      %\step[category=RD, final]
    }
  }
}



%%%%%%%%%%%%%%%%%% AD
\newcommand*{\ADcitenum}[1]{AD#1}
\DeclareCiteCommand{\ADcite}
  {\printfield{userb}\space}
  {\bibhyperref{\mkbibbrackets{AD\thefield{labelnumber}}}}
  {\addcomma\space}
  {}

% Use the custom citation command as the default
\DeclareFieldFormat{labelnumber}{\ADcitenum{#1}}

\defbibtabular{bibtabular1}
  {\setlength{\LTpre}{0pt}%
   \setlength{\LTpost}{0pt}%
   \renewcommand*{\arraystretch}{2}%
   \begin{longtable}{| C{\dimexpr0.08\textwidth-\tabcolsep\relax} | L{\dimexpr0.5\textwidth-2\tabcolsep\relax} | L{\dimexpr0.2\textwidth-\tabcolsep\relax} | L{\dimexpr0.2\textwidth-\tabcolsep\relax} |}
     \hline
     \rowcolor{lightgray} % Apply the custom row color to the first row
     \textbf{No.} & \textbf{Title} & \textbf{Identifier} & \textbf{Revision}\\
     \hline
     \endfirsthead
     \hline
     \endhead
     \hline
     \endfoot
     \hline
     \endlastfoot}
  {\end{longtable}}
  {\anchorlang{%
     \printtext[labelnumberwidth]{%
       \printfield{labelprefix}%
       \printfield{labelnumber}}}
   & \plainlang{\usebibmacro{title}}
   & \plainlang{\printfield{userb}}
   & \plainlang{\printfield{userc}} \\}



\addbibresource{applicable.bib}

%%%%%%%%%%%%%%%%%% RD
\newcommand*{\RDcitenum}[1]{RD#1}
\DeclareCiteCommand{\RDcite}
  {\printfield{userb}\space}
  {\bibhyperref{\mkbibbrackets{RD\thefield{labelnumber}}}}
  {\addcomma\space}
  {}
  
% Use the custom citation command as the default
\DeclareFieldFormat{labelnumber}{\RDcitenum{#1}}

\defbibtabular{bibtabular2}
  {\setlength{\LTpre}{0pt}%
   \setlength{\LTpost}{0pt}%
   \renewcommand*{\arraystretch}{2}%
   \begin{longtable}{| C{\dimexpr0.08\textwidth-\tabcolsep\relax} | L{\dimexpr0.5\textwidth-2\tabcolsep\relax} | L{\dimexpr0.2\textwidth-\tabcolsep\relax} | L{\dimexpr0.2\textwidth-\tabcolsep\relax} |}
     \hline
     \rowcolor{lightgray} % Apply the custom row color to the first row
     \textbf{No.} & \textbf{Title} & \textbf{Identifier} & \textbf{Revision}\\
     \hline
     \endfirsthead
     \hline
     \endhead
     \hline
     \endfoot
     \hline
     \endlastfoot}
  {\end{longtable}}
  {\anchorlang{%
     \printtext[labelnumberwidth]{%
       \printfield{labelprefix}%
       \printfield{labelnumber}}}
   & \plainlang{\usebibmacro{title}}
   & \plainlang{\printfield{userb}}
   & \plainlang{\printfield{userc}} \\}
   
   

\addbibresource{references.bib}


% No title at the start of the bibliography
\defbibheading{bibliography}[]{}




\begin{document}

\section{Applicable and reference documents}

\subsection{Applicable documents}
\begin{center}
    \printbibtabular[env=bibtabular1]
    \captionof{table}{Applicable documents}
\end{center}

\subsection{Reference documents}
\begin{center}
\printbibtabular[env=bibtabular2]
\captionof{table}{Reference documents}
\end{center}

Test
\\  
\ADcite{doc1}
\\
\RDcite{doc2}
\end{document}

适用的.bib文件:

@misc{doc1,
  usera = {AD},
  title = {Document Title 1},
  identifier = {ID-001},
  revision = {Rev-1},
}

references.bib 文件:

@misc{doc2,
  usera = {RD},
  title = {Document Title 2},
  identifier = {ID-002},
  revision = {Rev-2},
}

编辑:使用的关键字:所以我在 *.bib 文件中应用了关键字,它就像:

@misc{doc1,
  keywords = {AD},
  title = {Document Title 1},
  identifier = {ID-001},
  revision = {Rev-1},
}

\documentclass{article}
\usepackage[style=numeric, backend=biber]{biblatex}
\usepackage{biblatex-ext-tabular}
\usepackage{biblatex}
\usepackage[table,dvipsnames]{xcolor}
\usepackage{multirow}
\usepackage[hypcap=false]{caption}
\usepackage{longtable} % Required for customizing glossary column widths
\usepackage{hyperref}



\newcolumntype{L}[1]{%
  >{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}
\newcolumntype{C}[1]{%
  >{\centering\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}

\definecolor{lightgray}{gray}{0.9}



\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=keywords, match={AD}, final] % Filter for AD
      \step[fieldsource=identifier, fieldtarget=userb]
    }
    \map{
      \step[fieldsource=keywords, match={RD}, final] % Filter for RD
      \step[fieldsource=identifier, fieldtarget=userb]
    }
    \map{
      \step[fieldsource=revision, fieldtarget=userc]
    }
  }
}



%%%%%%%%%%%%%%%%%% AD
\newcommand*{\ADcitenum}[1]{AD#1}
\DeclareCiteCommand{\ADcite}
  {\printfield{labelprefix}} % Print the correct labelprefix for AD
  {\bibhyperref{\mkbibbrackets{AD\thefield{labelnumber}}}}
  {\addcomma\space}
  {}

% Use the custom citation command as the default
\DeclareFieldFormat{labelnumber}{\ADcitenum{#1}}

\defbibtabular{bibtabular1}
  {\setlength{\LTpre}{0pt}%
   \setlength{\LTpost}{0pt}%
   \renewcommand*{\arraystretch}{2}%
   \begin{longtable}{| C{\dimexpr0.08\textwidth-\tabcolsep\relax} | L{\dimexpr0.5\textwidth-2\tabcolsep\relax} | L{\dimexpr0.2\textwidth-\tabcolsep\relax} | L{\dimexpr0.2\textwidth-\tabcolsep\relax} |}
     \hline
     \rowcolor{lightgray} % Apply the custom row color to the first row
     \textbf{No.} & \textbf{Title} & \textbf{Identifier} & \textbf{Revision}\\
     \hline
     \endfirsthead
     \hline
     \endhead
     \hline
     \endfoot
     \hline
     \endlastfoot}
  {\end{longtable}}
  {\anchorlang{%
     \printtext[labelnumberwidth]{%
       \printfield{labelprefix}%
       \printfield{labelnumber}}}
   & \plainlang{\usebibmacro{title}}
   & \plainlang{\printfield{userb}}
   & \plainlang{\printfield{userc}} \\}



\addbibresource{applicable.bib}

%%%%%%%%%%%%%%%%%% RD
\newcommand*{\RDcitenum}[1]{RD#1}
\DeclareCiteCommand{\RDcite}
  {\printfield{labelprefix}} % Print the correct labelprefix for RD
  {\bibhyperref{\mkbibbrackets{RD\thefield{labelnumber}}}}
  {\addcomma\space}
  {}
  
% Use the custom citation command as the default
\DeclareFieldFormat{labelnumber}{\RDcitenum{#1}}

\defbibtabular{bibtabular2}
  {\setlength{\LTpre}{0pt}%
   \setlength{\LTpost}{0pt}%
   \renewcommand*{\arraystretch}{2}%
   \begin{longtable}{| C{\dimexpr0.08\textwidth-\tabcolsep\relax} | L{\dimexpr0.5\textwidth-2\tabcolsep\relax} | L{\dimexpr0.2\textwidth-\tabcolsep\relax} | L{\dimexpr0.2\textwidth-\tabcolsep\relax} |}
     \hline
     \rowcolor{lightgray} % Apply the custom row color to the first row
     \textbf{No.} & \textbf{Title} & \textbf{Identifier} & \textbf{Revision}\\
     \hline
     \endfirsthead
     \hline
     \endhead
     \hline
     \endfoot
     \hline
     \endlastfoot}
  {\end{longtable}}
  {\anchorlang{%
     \printtext[labelnumberwidth]{%
       \printfield{labelprefix}%
       \printfield{labelnumber}}}
   & \plainlang{\usebibmacro{title}}
   & \plainlang{\printfield{userb}}
   & \plainlang{\printfield{userc}} \\}
   
   

\addbibresource{references.bib}


% No title at the start of the bibliography
\defbibheading{bibliography}[]{}




\begin{document}

\section{Applicable and reference documents}

\subsection{Applicable documents}
\begin{center}
    \printbibtabular[env=bibtabular1, keyword=AD] % Filter for AD
    \captionof{table}{Applicable documents}
\end{center}

\subsection{Reference documents}
\begin{center}
\printbibtabular[env=bibtabular2, keyword=RD] % Filter for RD
\captionof{table}{Reference documents}
\end{center}

Test \\
\ADcite{doc1} \\
\RDcite{doc2}

\end{document}

现在情况好多了,但表格中的“适用文件”标签前缀不正确(RD1 而不是 AD1)。目前找不到修复它的方法:

在此处输入图片描述

答案1

使用 ,事情就简单多了labelprefix。该功能biblatex会根据需要自动添加“RD”或“AD”,您甚至不需要定义两个单独的\...cite命令。您也不需要定义两个单独的书目环境。(在问题的代码中,两者\DeclareFieldFormat{labelnumber}会相互覆盖,因此只有第二个占上风,让您始终使用“RD”。)

\documentclass{article}
\usepackage[style=numeric, backend=biber, defernumbers]{biblatex}
\usepackage{biblatex-ext-tabular}
\usepackage[table,dvipsnames]{xcolor}
\usepackage{multirow}
\usepackage[hypcap=false]{caption}
\usepackage{longtable} % Required for customizing glossary column widths
\usepackage{hyperref}

\newcolumntype{L}[1]{%
  >{\raggedright\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}
\newcolumntype{C}[1]{%
  >{\centering\let\newline\\\arraybackslash\hspace{0pt}}p{#1}}

\definecolor{lightgray}{gray}{0.9}

\DeclareSourcemap{
  \maps[datatype=bibtex]{
    \map{
      \step[fieldsource=keywords, match={AD}, final] % Filter for AD
      \step[fieldsource=identifier, fieldtarget=userb]
    }
    \map{
      \step[fieldsource=keywords, match={RD}, final] % Filter for RD
      \step[fieldsource=identifier, fieldtarget=userb]
    }
    \map{
      \step[fieldsource=revision, fieldtarget=userc]
    }
  }
}


\defbibtabular{bibtabular}
  {\setlength{\LTpre}{0pt}%
   \setlength{\LTpost}{0pt}%
   \renewcommand*{\arraystretch}{2}%
   \begin{longtable}{
     | C{\dimexpr0.1\textwidth\relax}
     | L{\dimexpr0.6\textwidth-8\tabcolsep-5\arrayrulewidth\relax}
     | L{\dimexpr0.15\textwidth\relax}
     | L{\dimexpr0.15\textwidth\relax} |}
     \hline
     \rowcolor{lightgray} % Apply the custom row color to the first row
     \textbf{No.} & \textbf{Title} & \textbf{Identifier} & \textbf{Revision}\\
     \hline
     \endfirsthead
     \hline
     \endhead
     \hline
     \endfoot
     \hline
     \endlastfoot}
  {\end{longtable}}
  {\anchorlang{%
     \printtext[labelnumberwidth]{%
       \printfield{labelprefix}%
       \printfield{labelnumber}}}
   & \plainlang{\usebibmacro{title}}
   & \plainlang{\printfield{userb}}
   & \plainlang{\printfield{userc}} \\}


\begin{filecontents}{\jobname.bib}
@misc{doc1,
  keywords = {AD},
  title = {Document Title 1},
  identifier = {ID-001},
  revision = {Rev-1},
}
@misc{doc2,
  keywords = {RD},
  title = {Document Title 2},
  identifier = {ID-002},
  revision = {Rev-2},
}
\end{filecontents}
\addbibresource{\jobname.bib}


\begin{document}

\section{Applicable and reference documents}

\subsection{Applicable documents}
\begin{center}
\newrefcontext[labelprefix=AD]
\printbibtabular[env=bibtabular, heading=none, keyword=AD] % Filter for AD
\captionof{table}{Applicable documents}
\end{center}

\subsection{Reference documents}
\begin{center}
\newrefcontext[labelprefix=RD]
\printbibtabular[env=bibtabular, heading=none, keyword=RD] % Filter for RD
\captionof{table}{Reference documents}
\end{center}

Test

\cite{doc1} 

\cite{doc2}

\end{document}

两个表格式书目。一个带有 AD1,另一个带有 RD1。

相关内容