使用完全相同的樣式和參數重複 \maketitle

使用完全相同的樣式和參數重複 \maketitle

我正在嘗試創建一個文檔,該文檔將在任意時刻重複首頁的標題。

\documentclass[a4paper,anonymous]{lipics-v2021}

\title{My Paper}

\titlerunning{paper} 

\author{Me}{}{}{}{}

\begin{document}

% Generate title
\maketitle

% Any amount of text/sections
lorem ipsum...

% I now want to show exactly the same title again
\maketitle

\end{document}

然而,此程式碼輸出上面給出的標題和作者參數的完全未格式化的文字。

一些連結[1,2] 建議使用該titling包,儘管這裡有兩個問題:

  1. 我似乎無法讓它使用我的專案文件\maketitle中定義的內容(在我的例子中是 lipics).cls
  2. titling包要求我重複 的所有參數\maketitle。 (例如\title{..},,\author{}等)。

答案1

在您的類別以及標準類別中, 會\maketitle自行停用,並清空包含指令 和 定義的元資料的\@title和巨集( 請參閱 [github 的 lipic-v2021 類別][1] 上的第 304 行及後續內容)。因此,您可以(在序言中)使用相同的程式碼(從第 287 行開始)除了第 304 行到第 314 行之外的命令。\@author\title{...}\author{...}\renewcomnand\maketitle

標準警告:您可以這樣做供個人使用。但如果您的文件打算提交給相應的期刊/會議/編輯(此處為 LIPIcs 系列會議),則切勿進行此類更改。 [1]:https://github.com/prosysscience/lipics/blob/master/lipics-v2021.cls

答案2

看著類別定義,你會發現(第287-315行)

\renewcommand\maketitle{\par
  \begingroup
    \thispagestyle{plain}
    \renewcommand\thefootnote{\@fnsymbol\c@footnote}%
    \if@twocolumn
      \ifnum \col@number=\@ne
        \@maketitle
      \else
        \twocolumn[\@maketitle]%
      \fi
    \else
      \newpage
      \global\@topnum\z@   % Prevents figures from going at top of page.
      \@maketitle
    \fi
    \thispagestyle{plain}\@thanks
  \endgroup
  \global\let\thanks\relax
  \global\let\maketitle\relax
  \global\let\@maketitle\relax
  \global\let\@thanks\@empty
  \global\let\@author\@empty
  \global\let\@date\@empty
  \global\let\@title\@empty
  \global\let\title\relax
  \global\let\author\relax
  \global\let\date\relax
  \global\let\and\relax
}

第二個\maketitle失敗是因為所有\global\let...\relax\global\let...\@empty

您可以嘗試重新定義它(內部\makeatletter\makeatother處理巨集名稱中的字元@)。

\makeatletter
\renewcommand\maketitle{\par
  \begingroup
    \thispagestyle{plain}
    \renewcommand\thefootnote{\@fnsymbol\c@footnote}%
    \if@twocolumn
      \ifnum \col@number=\@ne
        \@maketitle
      \else
        \twocolumn[\@maketitle]%
      \fi
    \else
      \newpage
      \global\@topnum\z@   % Prevents figures from going at top of page.
      \@maketitle
    \fi
    \thispagestyle{plain}\@thanks
  \endgroup
}
\makeatother

再次列印完整的標題頁,包括頁尾。如果您只想要標題本身,則必須查看\@maketitle定義,然後複製您需要的部分。

例子:

\documentclass[a4paper,anonymous]{lipics-v2021}

\makeatletter
\renewcommand\maketitle{\par
  \begingroup
    \thispagestyle{plain}
    \renewcommand\thefootnote{\@fnsymbol\c@footnote}%
    \if@twocolumn
      \ifnum \col@number=\@ne
        \@maketitle
      \else
        \twocolumn[\@maketitle]%
      \fi
    \else
      \newpage
      \global\@topnum\z@   % Prevents figures from going at top of page.
      \@maketitle
    \fi
    \thispagestyle{plain}\@thanks
  \endgroup
}
\makeatother

\title{My Paper}

\titlerunning{paper}

\author{Me}{}{}{}{}

\begin{document}

% Generate title
\maketitle

% Any amount of text/sections
lorem ipsum...

% I now want to show exactly the same title again
\maketitle

\end{document}

相關內容