如何根据单个输入创建表输出?

如何根据单个输入创建表输出?

我正在尝试根据各个 orcid 编号生成作者 orcid 编号列表。作者的每个 orcid 编号由\orcid中的命令给出\author。但是,我无法从谷歌搜索中找到足够的信息。我的 MWE 如下;

\documentclass[11pt, a4paper, twocolumn]{article}
\usepackage{lipsum}

% Any configuration that should be done before the end of the preamble:
\usepackage[super,comma,sort&compress]{natbib}
\usepackage{newtxtext,newtxmath}
\usepackage{hyperref}
\hypersetup{colorlinks=true, urlcolor=blue, linkcolor=blue, citecolor=blue}

\usepackage{geometry}
\geometry{top=1cm,bottom=1.5cm,left=2cm,right=2cm,footskip=1cm,includehead,includefoot,columnsep=6mm,showframe}

\usepackage{abstract}
\usepackage{authblk}
\usepackage{graphicx}

\renewcommand{\abstractnamefont}{\normalfont\bfseries}
\renewcommand{\abstracttextfont}{\normalfont\small}
\renewcommand{\thefootnote}{\alph{footnote}}
\renewcommand\Authands{ and }
\newcommand{\abstractText}{\noindent\lipsum[8]}

\makeatletter
\newbox{\orcidbox}
\sbox{\orcidbox}{\includegraphics[width=4mm]{orcidid.png}}
\newcommand{\orcid}[1]{%
    \href{https://orcid.org/#1}{\usebox{\orcidbox}}
    %
    % add item to list enviroment   <------------------------
}

\newcommand{\listoforcids}{
    \vspace*{5mm}
    \noindent\bfseries{\large List of Author orcids}
    %
    % create a tabular list from \orcid items    <------------------------
    \normalfont
    \par
    \hfil$\vdots$\hfil\par
    \hfil$\vdots$\hfil
}
\makeatother
%%%%%%%%%%%%%%%%%
% Configuration %
%%%%%%%%%%%%%%%%%
\title{Article Title}

\author[1]{Author A \orcid{0000-000X-AAAA-BBBB}}
\author[2]{Author B \orcid{0000-000X-AAAA-CCCC}}
\author[2]{Author C \orcid{0000-000X-AAAA-DDDD}}
\affil[1]{Department of Computer Science}
\affil[2]{Department of Mechanical Engineering}

\begin{document}
    %%%%%%%%%%%%
    % Abstract %
    %%%%%%%%%%%%
    
    \twocolumn[
    \begin{@twocolumnfalse}
        \maketitle
        \begin{abstract}
            \abstractText
            \newline
            \newline
        \end{abstract}
    \end{@twocolumnfalse}
    ]
    
    %%%%%%%%%%%
    % Article %
    %%%%%%%%%%%
    
    \section{Section Title 1}
    This is the first sentence\cite{ref1}.
    
    \section{Section Title 2}
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque\footnote{First footnote}. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem. Nulla et lectus vestibulum urna fringilla ultrices. Phasellus eu tellus sit amet tortor gravida placerat\cite{ref2}. Integer sapien est, iaculis in, pretium quis, viverra ac, nunc. Praesent eget sem vel leo ultrices bibendum. Aenean faucibus. Morbi dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla. Curabitur auctor semper nulla. Donec varius orci eget risus\cite{ref3}. Duis nibh mi, congue eu, accumsan eleifend, sagittis quis, diam. Duis eget orci sit amet orci dignissim rutrum\footnote{Second footnote}.
    
    \section{Section Title 3}
    \lipsum[2]
    
    \subsection{Section Title 3.1}
    \lipsum[3]
    
    \section{Section Title 4}
    \lipsum[4-5]
    
    
    \listoforcids
    
    \par\vspace*{3cm}
    \noindent expected output from \verb'\listoforcids' command
    \begin{table}[!h]
        \begin{tabular}{ll}
            Author A & https://orcid.org/0000-000X-AAAA-BBBB\\
            Author B & https://orcid.org/0000-000X-AAAA-CCCC\\
            Author C & https://orcid.org/0000-000X-AAAA-DDDD\\
        \end{tabular}
    \end{table}
        
    %%%%%%%%%%%%%%
    % References %
    %%%%%%%%%%%%%%
    
    \begin{thebibliography}{99}
        \bibitem[Ref1, (2003)]{ref1} Ref1 journal, 2003
        \bibitem[Ref2, (2006)]{ref2} Ref2 journal, 2006
        \bibitem[Ref3, (2009)]{ref3} Ref3 journal, 2009
    \end{thebibliography}   
\end{document}

如何使用\orcid命令将每个作者姓名和 orcid 编号添加到列表中?如何使用\listoforcids命令生成表格?预期输出作为示例显示在参考文献之前。感谢所有提供解决方案的人。

答案1

编辑 1:为类的作者声明添加代码mnras

编辑 2:消除 orcids 列表中的多余空间

\documentclass[11pt, a4paper, twocolumn]{article}
\usepackage{lipsum}

% Any configuration that should be done before the end of the preamble:
\usepackage[super,comma,sort&compress]{natbib}
\usepackage{newtxtext,newtxmath}
\usepackage{hyperref}
\hypersetup{colorlinks=true, urlcolor=blue, linkcolor=blue, citecolor=blue}

\usepackage{geometry}
\geometry{top=1cm,bottom=1.5cm,left=2cm,right=2cm,footskip=1cm,includehead,includefoot,columnsep=6mm,showframe}

\usepackage{abstract}
\usepackage{authblk}
\usepackage{graphicx}

\renewcommand{\abstractnamefont}{\normalfont\bfseries}
\renewcommand{\abstracttextfont}{\normalfont\small}
\renewcommand{\thefootnote}{\alph{footnote}}
\renewcommand\Authands{ and }
\newcommand{\abstractText}{\noindent\lipsum[8]}

\newbox{\orcidbox}
\sbox{\orcidbox}{\includegraphics[width=4mm]{orcidid.png}}
\newcommand{\orcid}[1]{%
    \href{https://orcid.org/#1}{\usebox{\orcidbox}}%
    %
    % add item to list enviroment   <------------------------
}

%% Generate List of Author orcids
\usepackage{xpatch}
\newcommand{\AuthorOrcidList}{}
\newcommand{\innerorcid}[1]{& https://orcid.org/#1}
\xapptocmd{\author}{{\let\orcid\innerorcid
                    \xappto{\AuthorOrcidList}{#2\\}}}{}{\FAIL}

\newcommand{\listoforcids}{
%    \vspace*{5mm}
    \section*{List of Author orcids}
    %
    % create a tabular list from \orcid items    <------------------------
    \begin{tabular}{@{}ll@{}}% <<<< EDIT 2
      \AuthorOrcidList
    \end{tabular}
  }
%% End generate List of Author orcids

%%%%%%%%%%%%%%%%%
% Configuration %
%%%%%%%%%%%%%%%%%
\title{Article Title}

\author[1]{Author A \orcid{0000-000X-AAAA-BBBB}}
\author[2]{Author B \orcid{0000-000X-AAAA-CCCC}}
\author[2]{Author C \orcid{0000-000X-AAAA-DDDD}}
\affil[1]{Department of Computer Science}
\affil[2]{Department of Mechanical Engineering}

\begin{document}
    %%%%%%%%%%%%
    % Abstract %
    %%%%%%%%%%%%
    
    \twocolumn[
    \begin{@twocolumnfalse}
        \maketitle
        \begin{abstract}
            \abstractText
            \newline
            \newline
        \end{abstract}
    \end{@twocolumnfalse}
    ]
    
    %%%%%%%%%%%
    % Article %
    %%%%%%%%%%%
    
    \section{Section Title 1}
    This is the first sentence\cite{ref1}.
    
    \section{Section Title 2}
    Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibulum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna. Donec vehicula augue eu neque\footnote{First footnote}. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Mauris ut leo. Cras viverra metus rhoncus sem. Nulla et lectus vestibulum urna fringilla ultrices. Phasellus eu tellus sit amet tortor gravida placerat\cite{ref2}. Integer sapien est, iaculis in, pretium quis, viverra ac, nunc. Praesent eget sem vel leo ultrices bibendum. Aenean faucibus. Morbi dolor nulla, malesuada eu, pulvinar at, mollis ac, nulla. Curabitur auctor semper nulla. Donec varius orci eget risus\cite{ref3}. Duis nibh mi, congue eu, accumsan eleifend, sagittis quis, diam. Duis eget orci sit amet orci dignissim rutrum\footnote{Second footnote}.
    
    \section{Section Title 3}
    \lipsum[2]
    
    \subsection{Section Title 3.1}
    \lipsum[3]
    
    \section{Section Title 4}
    \lipsum[4-5]
    
    
    \listoforcids
    
    \par\vspace*{3cm}
    \noindent expected output from \verb'\listoforcids' command
    \begin{table}[!h]
        \begin{tabular}{ll}
            Author A & https://orcid.org/0000-000X-AAAA-BBBB\\
            Author B & https://orcid.org/0000-000X-AAAA-CCCC\\
            Author C & https://orcid.org/0000-000X-AAAA-DDDD\\
        \end{tabular}
    \end{table}
        
    %%%%%%%%%%%%%%
    % References %
    %%%%%%%%%%%%%%
    
    \begin{thebibliography}{99}
        \bibitem[Ref1, (2003)]{ref1} Ref1 journal, 2003
        \bibitem[Ref2, (2006)]{ref2} Ref2 journal, 2006
        \bibitem[Ref3, (2009)]{ref3} Ref3 journal, 2009
    \end{thebibliography}   
\end{document}

以下是 documentclass 的代码mnras。假设authblk未使用包,即的定义\author来自mnras.cls


%% Generate List of Author orcids
\newcommand{\AuthorOrcidList}{}
\newcommand{\innerorcid}[1]{& https://orcid.org/#1\\}

% \author saves the authors in \@author, but \maketitle clears it
% So we save \@author at the beginning of \maketitle
\makeatletter
\pretocmd{\maketitle}{\global\let\AuthorOrcidList\@author}{}{\FAIL}
\makeatother

\ExplSyntaxOn
\tl_new:N \l_authors_tl

\newcommand\splitauthors{
  \tl_set:NV \l_authors_tl \AuthorOrcidList
  % Remove all commas, superscripts, the word 'and' and the part starting with \\
  \regex_replace_all:nnN {,|\$.*?\$|\band\b|\c{\\}.*} {}  \l_authors_tl
  \tl_use:N \l_authors_tl
}
\ExplSyntaxOff

\newcommand{\listoforcids}{
    \section*{List of Author orcids}
    %
    % create a tabular list from \orcid items    <------------------------
    {\let\orcid\innerorcid
    \begin{tabular}{@{}ll@{}}% <<<<<< EDIT 2
      \splitauthors
    \end{tabular}}
  }
%% End generate List of Author orcids

在此处输入图片描述

相关内容