使用 xkeyval 包定义的作者属性和值

使用 xkeyval 包定义的作者属性和值

我尝试使用xkeyval包定义命令键作者属性,如“通讯作者地址、通讯作者电子邮件、当前地址、自动字符串捕获作者姓名”。

xkeyval我将尝试使用该包执行下面提到的编码逻辑

\author[aff={1},link={http://people/u/41922},coraddress={Professor of Plant Molecular Biology},email={[email protected]}]{Junli Liu}

但我不知道如何使用命令键概念来执行。目前我正在使用“authblk”包并实现我所需的作者风格。我所需的输出如下所述....

在此处输入图片描述

我目前正在使用下面提到的编码。如何通过包实现此目标xkeyval。请指教

\documentclass{article}

\usepackage{authblk}
\usepackage{xkeyval}
\usepackage{hyperref}
\makeatletter
\def\@maketitle{%
  \null
\vbox to \textheight{\vbox to \textheight{\vspace*{12pc}%\vfill%
\hbox to 10pc{\hfill%
\begin{minipage}[b]{10pc}
{\@correspondence\par}%
    \vskip 6pt%
{\@presentaddress}%
\end{minipage}}}
\hspace*{11pc}
\vbox to \textheight{\vspace*{-44pc}%
\hbox to 10pc{\hfill%
\begin{minipage}[b]{31pc}  
  \let \footnote \thanks
    {\raggedright\fontsize{18pt}{20pt}\selectfont\@title \par}%
    \vskip 1.5em%
    {\large
      \begin{tabular}[t]{l}%
        \raggedright\@author
      \end{tabular}\par}%
   \end{minipage}}}}%
  \par
  \vskip 8.5em}


\def\@correspondence{}
\def\correspondence#1{%
     \gdef\@correspondence{\textbf{\textit{*Correspondence:}}\newline%
       \raggedright  #1}}

\def\@presentaddress{}
\def\presentaddress#1{%
     \gdef\@presentaddress{\textbf{\textit{$\dagger$presentaddress:}}\newline%
       \raggedright  #1}}

\makeatother

\begin{document}

\title{Hormonal crosstalk for root development}
\author[1,]{Junli Liu}
\author[2]{James Rowe}
\author[2]{Keith Lindsey}
\affil[1]{Integrative Cell Biology Laboratory, School of Biological and Biomedical Sciences, The Bio physical Sciences Institute, Durham University, Durham, UK}
\correspondence{Junli Liu is Professor of Plant Molecular Biology \newline e-mail: \href{mailto:[email protected]}{[email protected]}}
\presentaddress{James Rowe continued from this author address\newline e-mail: [email protected] }
\maketitle
\end{document}

答案1

我不确定我是否完全理解了 OP 的要求——我没有改变的重新定义\@maketitle

xkeyval一开始有点难以理解。我使用了它的基本设置。

\define@key{authorinfo}{aff}{%
\def\VetriKVMacroAff{#1}%
}%

定义一个名为的键aff,用于关联编号。每次使用此键时,宏\VetriKVMacroAff都会保存值,例如,,aff=1即值为1。如果不使用,则宏\VetriKVMacroAff未定义,因此最好检查它是否已定义。

密钥通常按家族来组织,该家族称为authorinfo

其余键的定义类似。

为了准备xkeyval钥匙,\setkeys{authorinfo}{#1}必须被调用(最好在\author“开始”之后立即调用)

\correspondence和是全局宏\presentaddress——很难快速改变以提供更多的故障安全替代方案。

\documentclass{article}

\usepackage{authblk}
\usepackage{xkeyval}
\usepackage{etoolbox}%
\usepackage{xparse}%


\usepackage{hyperref}
\makeatletter
\def\@maketitle{%
  \null
\vbox to \textheight{\vbox to \textheight{\vspace*{12pc}%\vfill%
\hbox to 10pc{\hfill%
\begin{minipage}[b]{10pc}
{\@correspondence\par}%
    \vskip 6pt%
{\@presentaddress}%
\end{minipage}}}
\hspace*{11pc}
\vbox to \textheight{\vspace*{-44pc}%
\hbox to 10pc{\hfill%
\begin{minipage}[b]{31pc}  
  \let \footnote \thanks
    {\raggedright\fontsize{18pt}{20pt}\selectfont\@title \par}%
    \vskip 1.5em%
    {\large
      \begin{tabular}[t]{l}%
        \raggedright\@author
      \end{tabular}\par}%
   \end{minipage}}}}%
  \par
  \vskip 8.5em}


\def\@correspondence{}
\def\correspondence#1{%
  \gdef\@correspondence{\textbf{\textit{*Correspondence:}}\newline%
    \raggedright  #1\VetriKVMacroEmail%
    }}

\def\@presentaddress{}
\def\presentaddress#1{%
     \gdef\@presentaddress{\textbf{\textit{$\dagger$presentaddress:}}\newline%
       \raggedright  #1}}



\define@key{authorinfo}{aff}{%
\def\VetriKVMacroAff{#1}%
}%


\define@key{authorinfo}{coraddress}{%
\def\VetriKVMacroCorAddress{#1}%
}%

\define@key{authorinfo}{email}{%
\def\VetriKVMacroEmail{#1}%
}%

\define@key{authorinfo}{presentaddress}{%
\def\VetriKVMacroPresentAddress{#1}%
}%


\let\OriginalAuthor\author

\RenewDocumentCommand{\author}{+O{}+m}{%
\setkeys{authorinfo}{#1}%
\ifdef{\VetriKVMacroAff}{%
  \OriginalAuthor[\VetriKVMacroAff]{#2}%
}{%
  \OriginalAuthor{#2}% 
}%
\ifdef{\VetriKVMacroCorAddress}{%
  \correspondence{\VetriKVMacroCorAddress}%
}{%
}
\ifdef{\VetriKVMacroPresentAddress}{%
  \presentaddress{\VetriKVMacroPresentAddress}%
}{%
}%
\undef\VetriKVMacroAff%
}% End of RenewDocumentCommand.


\makeatother

\begin{document}

\title{Hormonal crosstalk for root development}
\author[aff={1,},coraddress={Junli Liu is Professor of Plant Molecular Biology\newline},email={\href{mailto:[email protected]}{[email protected]}}]{Junli Liu}
\author[aff={2},presentaddress=James Rowe continued from this author address\newline e-mail: [email protected]]{James Rowe}
\author[aff={2}]{Keith Lindsey}
\affil[1]{Integrative Cell Biology Laboratory, School of Biological and Biomedical Sciences, The Bio physical Sciences Institute, Durham University, Durham, UK}

\maketitle
\end{document}

相关内容