TeX 中是否有类似于 \emptyauthor 和 \emptyaffil 的符号?

TeX 中是否有类似于 \emptyauthor 和 \emptyaffil 的符号?

我尝试使用包在 TeX 文档中实现 2 个标题titling

类似的事情发生在如何重置作者列表?,但此解决方案仅适用于每个标题有 1 位作者和 1 个隶属关系的情况。相反,我每个标题有 2 位作者和 2 个隶属关系。由于代码原因,我得到第二个标题有 4 位作者和 4 个隶属关系,这并不合适!

\emptythanks正如您在 WE 中看到的,包中有一个功能对我来说很好,找到类似和的titling功能会很棒。但也许还有另一种方法可以解决这个问题……\emptyauthor\emptyaffil

有人能帮帮我吗?!

\documentclass[12pt]{article}
\usepackage[cp1251]{inputenc}
\usepackage[english]{babel}

\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amsthm}
\usepackage{dsfont}
\usepackage{amssymb}
\usepackage{csquotes}
\usepackage{titling}
\usepackage{letltxmacro}
\usepackage{xparse}
\usepackage[blocks]{authblk}

%\newcommand{\emptyauthor}{\global\let\@author\@empty}
%\newcommand{\emptyaffil}{\global\let\@affil\@empty}


\makeatletter \LetLtxMacro\@uthorfrom@uthblk\author

\RenewDocumentCommand{\author}{+o+m}{%
  \ifnum0=\value{authors}%
  \def\AB@authors{}%
  \fi
  \IfValueTF{#1}{%
    \@uthorfrom@uthblk[#1]{#2}%
  }{%
    \@uthorfrom@uthblk{#2}%
  }%
}

\def\@maketitle{%
    \begin{center}%
      \let \footnote \thanks
      {\LARGE \@title \par}%
      \vskip 1.5em%
      {\large
        \lineskip .5em%
        \begin{tabular}[t]{c}%
          \@author%
        \end{tabular}\par}%
        \vskip 1em%
        % {\large \@date}%
      \end{center}%
      \par
      \vskip 1.5em%
      % reset counters for possible next \author macro
      \setcounter{authors}{0}%
      \setcounter{affil}{0}%
    }
\makeatother


\begin{document}

%%%%%%%---------First Article-------------

\title{First Article\thanks{thanks to everyone.}}


\author[1]{Author A1}
\author[2]{Author A2}

\affil[1]{Affiliation of Author A1}
\affil[2]{Affiliation of Author
A2}

\maketitle


\begin{abstract}
  Abstract goes here...
\end{abstract}


%%%%%%%---------Second Article-------------


\emptythanks
%\emptyauthor
%\emptyaffil

\title{Second Article\thanks{thanks to your mom.}}

\author[1]{\underline{Author B1}}
\author[2]{\underline{Author B2}}

\affil[1]{Affiliation of Author B1}
\affil[2]{Affiliation of Author
B2}

\makeatletter
\makeatother
\maketitle

\begin{abstract}
    Abstract goes here...
\end{abstract}

\end{document}

在此处输入图片描述

答案1

您应该能够使用以下命令重置作者和所属机构:

\renewcommand\AB@authlist{}
\renewcommand\AB@affillist{}
\renewcommand\AB@authors{}
\renewcommand\AB@affilsep{\protect\Affilfont}
\renewcommand\AB@blk@and{\protect\Authfont\protect\AB@setsep}

前三行用于清空存储作者和所属关系的宏。最后两行是必需的,因为这些宏在第一次使用后将被设置为其他内容。因此,如果我们想重新使用它们,我们需要将它们重置为初始状态。

将此方法应用到您的示例中:

\documentclass[12pt]{article}
%\usepackage[cp1251]{inputenc}
\usepackage[english]{babel}

\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amsthm}
\usepackage{dsfont}
\usepackage{amssymb}
\usepackage{csquotes}
\usepackage{titling}
\usepackage{letltxmacro}
\usepackage{xparse}
\usepackage[blocks]{authblk}

\makeatletter 

\newcommand{\emptyauthoraffil}{
  \renewcommand\AB@authlist{}
  \renewcommand\AB@affillist{}
  \renewcommand\AB@authors{}
  \renewcommand\AB@affilsep{\protect\Affilfont}
  \renewcommand\AB@blk@and{\protect\Authfont\protect\AB@setsep}
}

\LetLtxMacro\@uthorfrom@uthblk\author

\RenewDocumentCommand{\author}{+o+m}{%
  \ifnum0=\value{authors}%
  \def\AB@authors{}%
  \fi
  \IfValueTF{#1}{%
    \@uthorfrom@uthblk[#1]{#2}%
  }{%
    \@uthorfrom@uthblk{#2}%
  }%
}

\def\@maketitle{%
    \begin{center}%
      \let \footnote \thanks
      {\LARGE \@title \par}%
      \vskip 1.5em%
      {\large
        \lineskip .5em%
        \begin{tabular}[t]{c}%
          \@author%
        \end{tabular}\par}%
        \vskip 1em%
        % {\large \@date}%
      \end{center}%
      \par
      \vskip 1.5em%
      % reset counters for possible next \author macro
      \setcounter{authors}{0}%
      \setcounter{affil}{0}%
    }
    
\makeatother

\begin{document}


%%%%%%%---------First Article-------------

\title{First Article\thanks{thanks to everyone.}}

\author[1]{Author A1}
\author[2]{Author A2}

\affil[1]{Affiliation of Author A1}
\affil[2]{Affiliation of Author
A2}

\maketitle

\begin{abstract}
  Abstract goes here ...
\end{abstract}


%%%%%%%---------Second Article-------------

\emptythanks
\emptyauthoraffil

\title{Second Article\thanks{thanks to your mom.}}

\author[1]{\underline{Author B1}}
\author[2]{\underline{Author B2}}

\affil[1]{Affiliation of Author B1}
\affil[2]{Affiliation of Author
B2}

\makeatletter
\makeatother
\maketitle

\begin{abstract}
    Abstract goes here ...
\end{abstract}

\end{document}

对于第二篇文章,您将获得以下输出:

在此处输入图片描述

相关内容