如何将 \thanklessauthor 添加到 KOMA 脚本文档?

如何将 \thanklessauthor 添加到 KOMA 脚本文档?

好吧,我正在处理一个文档KOMA Script,我尝试使用\thanklessauthor我在代码中找到的命令样本Tufte-book。一开始我以为这是一个普通的TeX宏,但事实并非如此。

在网上搜索了一下,我发现这一页在第 531 行和第 543 行之间有部分代码定义了我需要的内容。但奇怪的是,我没有看到\newcommand每种情况下的完整定义。我以前从未编写过类或类似的东西,所以我不明白它是如何工作的。

到目前为止,我的 MWE 是:

\documentclass[headsepline=true,paper=letter,headings=big,bibliography=totoc,DIV=10]{scrbook}
\usepackage{typearea}
\usepackage[spanish,mexico]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[copyright]{ccicons}
\usepackage{bera}

%%%%%%% Page Style
\usepackage[nouppercase]{scrpage2}
\pagestyle{scrheadings}

% Prints the month name (e.g., January) and the year (e.g., 2008)
\newcommand{\monthyear}{%
\ifcase\month\or January\or February\or March\or April\or May\or June\or
  July\or August\or September\or October\or November\or
  December\fi\space\number\year
}

\usepackage{setspace}
%\singlespacing
\onehalfspacing
%\doublespacing

%\usepackage[stable,bottom]{footmisc}
\raggedbottom
\clubpenalty=3000
\widowpenalty=3000
\setlength{\parskip}{3pt plus 2pt minus 2pt}

\begin{document}
\frontmatter
\extratitle{\vspace*{4\baselineskip}\centering on the quiet}
    \titlehead{Opera Prima Collection}
    \title{Tales on the quiet}
    %\subtitle{}
    \author{Me}
    \date{}
    \publishers{\emph{Listopad}}
    \uppertitleback{
    Copyleft \ccShareAlike\ \the\year\ \thanklessauthor 

\textsc{Edited by \thanklesspublisher}   
}
    \lowertitleback{    
Design and typesetting: \emph{Listopad} \\    
\textit{First edition, \monthyear}.
}
    \dedication{To my thumb.}
    \maketitle    
\end{document}

那么我该如何将这些命令添加到我的文档中?


更新

在 Johannes BI 的建议和回答之后,尝试将他的建议应用到我的代码中,这是我的 MWE 更新的结果:

\documentclass[headsepline=true,paper=letter,headings=big,bibliography=totoc,DIV=10]{scrbook}
\usepackage{typearea}
\usepackage[english]{babel} % Actually in the document is in Spanish
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[copyright]{ccicons}
\usepackage{bera}

%%%%%%% Style chapter adjustments

%\makeatletter
%\renewcommand\@chapapp{}
%\renewcommand \thechapter{}
%\makeatother

%%%%%%% Page Style
\usepackage{scrlayer-scrpage} %  If I add this line I've got two figures of rulers in the head and the foot, now not.
%\usepackage[nouppercase]{scrpage2}
%\pagestyle{scrheadings}

% Prints the month name (e.g., January) and the year (e.g., 2008)
\newcommand{\monthyear}{%
\ifcase\month\or January\or February\or March\or April\or May\or June\or
  July\or August\or September\or October\or November\or
  December\fi\space\number\year
}

\usepackage{setspace}
%\singlespacing
\onehalfspacing
%\doublespacing

%\usepackage[stable,bottom]{footmisc} I want to know how to use the KOMA solution instead.
\raggedbottom
\clubpenalty=10000
\widowpenalty=10000

\KOMAoption{parskip}{half}

%%%%%%%% Automation

\usepackage{xifthen}
\makeatletter
%JB Taken from tufte-common.def
\newcommand{\plainauthor}{}%
\newcommand{\thanklessauthor}{}%
\renewcommand*{\author}[2][]{%
    \gdef\@author{#2}%
    \begingroup%
    % TODO store contents of \thanks command%
    \renewcommand{\thanks}[1]{}%
    \protected@xdef\thanklessauthor{#2}%
\endgroup%
\ifthenelse{\isempty{#1}}%
{\renewcommand{\plainauthor}{\thanklessauthor}}%
{\renewcommand{\plainauthor}{#1}}%
\@ifpackageloaded{hyperref}{\hypersetup{pdfauthor={\plainauthor}}}{}%
}%

\usepackage{xparse}

%Redefining the publishers
\RenewDocumentCommand{\publishers}{ o m o}{ % I didn't understood this line
    \def\publishernothanks{}
    \def\shortpublishers{}
    \IfValueTF{#3}{
        \gdef\@publishers{#2\thanks{#3}}
        \gdef\publishernothanks{#2}
        \gdef\publisherthanksnote{#3}
    }
    {
        \gdef\@publishers{#2}
        \let\publishernothanks\publishers
    }
    \IfNoValueTF{#1}{
        \let\shortpublishers\publishernothanks
    }{
        \gdef\shortpublishers{#1}
    }
}

\makeatother

%\addtokomafont{author}{\itshape}
%\addtokomafont{publishers}{\itshape}

\usepackage{blindtext}

\begin{document}
\frontmatter
\extratitle{\vspace*{4\baselineskip}\centering on the quiet}
\titlehead{State Fund for Culture and the Arts of Tabasco. \\
Cultural Institute of Tabasco}
\subject{Tales}
\title{ on the quiet}
%\subtitle{}
\author{Me}
\date{}
\publishers{\emph{Listopad}}
\uppertitleback{
    Copyleft \ccShareAlike\ \the\year\ \thanklessauthor 
\textsc{Edited by \thanklesspublisher}   
}
\lowertitleback{    
Design and typesetting: \thanklesspublisher \\    
\textit{First edition, \monthyear}.
}
\dedication{To my thumb.}
\maketitle    

\blinddocument
\chapter{Let's test the result}
\begin{labeling}{the thanklessauthor}
\item[The author] \makeatletter \@author \makeatother
\item[the thanklessauthor] \thanklessauthor
\item[the plainauthor] \plainauthor
\item[the publisher] \makeatletter\@publishers\makeatother
\item[the shortpublisher]\shortpublishers
\item[publishernothanks]\publishernothanks
\item[publishthanksnote]\publisherthanksnote
\end{labeling}
\end{document}

此 MNWE(最小不是工作示例)有错误,其中之一是我不能\thankslesspublisher\uppertitlebackand中使用\lowertitleback

答案1

Tufte 类以某种方式定义作者命令,即吞噬感谢并仅存储名称(thankslessauthor)。如果给出了可选参数\author,则将其存储为plainauthor,如果没有给出, thanklessauthor则和plainauthor相同。

正如您在示例最后一页所看到的,如果谢谢 没有被吞噬,脚注标记也会被输出。

根据您想要实现的目标,可能会有更多类似 KOMA 的解决方案。

对于发布者,我使用了不同的方法,即使用 package xparse。您可以使用\publishers常规方法,但如果您想包含谢谢您可以将其放在末尾的可选参数中。如果您想提供可选的 shortpublisher,则可以使用开头的可选参数。如果没有提供,则 短版出版商将是出版商

xparse使我们能够使用高级语法定义命令。定义\RenewDocumentCommand{\publishers}{ o m o }{ <definition> }我们可以 \publishers[<optional short publisher>]{<publishers>}[<optional thanks>] 在文档中使用。该{ o m o }部分定义了命令可以采用哪些参数。在本例中o可选参数(简短的发布者),和论证(出版商)和另一个 o可选参数(可能的感谢)。

\publisherthanks如果您希望稍后再次使用,感谢信息将保存在变量中。

addtokomafont您可以通过添加( ,附加到列表)或设置(setkomafont,重置列表并重新开始)字体和大小开关来更改元素的外观。

scrlayer-scrpage是 的后继scrpage2。全局选项headsepline=true被传递给包,导致头部和文本主体之间的分隔线。

关于脚注,除了使用选项stableKOMA 之外,标准类还提供可选参数。这里的 KOMA 接口更高级,您可以为标题、目录和实际章节标题选择不同的标题。KOMAbottom不提供该选项,因为该包不会干扰 KOMA,所以可以使用。

\documentclass[headsepline=true,paper=letter,headings=big,bibliography=totoc,DIV=10]{scrbook}
\usepackage[english]{babel} % Actually in the document is in Spanish
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[copyright]{ccicons}


%\makeatletter
%\renewcommand\@chapapp{}
%\renewcommand \thechapter{}
%\makeatother

\usepackage{scrlayer-scrpage} 

% Prints the month name (e.g., January) and the year (e.g., 2008)
\newcommand{\monthyear}{%
\ifcase\month\or January\or February\or March\or April\or May\or June\or
  July\or August\or September\or October\or November\or
  December\fi\space\number\year
}


%\usepackage[bottom]{footmisc} 


\usepackage{xifthen}
\makeatletter
%JB Taken from tufte-common.def
\newcommand{\plainauthor}{}%
\newcommand{\thanklessauthor}{}%
\renewcommand*{\author}[2][]{%
    \gdef\@author{#2}%
    \begingroup%
    % TODO store contents of \thanks command%
    \renewcommand{\thanks}[1]{}%
    \protected@xdef\thanklessauthor{#2}%
\endgroup%
\ifthenelse{\isempty{#1}}%
{\renewcommand{\plainauthor}{\thanklessauthor}}%
{\renewcommand{\plainauthor}{#1}}%
\@ifpackageloaded{hyperref}{\hypersetup{pdfauthor={\plainauthor}}}{}%
}%

\usepackage{xparse}

%Redefining the publishers

\RenewDocumentCommand{\publishers}{ o m o }{
    \def\publishernothanks{}
    \def\shortpublishers{}
    \def\publisherthanksnote{}
    \IfNoValueTF{#3}{
        \gdef\@publishers{#2}
        \let\publishernothanks\@publishers
    }
    {
        \gdef\@publishers{#2\thanks{#3}}
        \gdef\publishernothanks{#2}
        \gdef\publisherthanksnote{#3}
    }
    \IfNoValueTF{#1}{
        \let\shortpublishers\publishernothanks
    }{
        \gdef\shortpublishers{#1}
    }
}
\makeatother
\publishers{Listopad}

%\addtokomafont{author}{\itshape}
%\addtokomafont{publishers}{\itshape}

\usepackage{blindtext}

\extratitle{\vspace*{4\baselineskip}\centering on the quiet}
\titlehead{State Fund for Culture and the Arts of Tabasco. \\
Cultural Institute of Tabasco}
\subject{Tales}
\title{ on the quiet}
%\subtitle{}
\author{Me}
\date{}
\uppertitleback{
    Copyleft \ccShareAlike\ \the\year\ \publishernothanks \\
    \textsc{Edited by \publishernothanks}
}
\lowertitleback{%
Design and typesetting:  \publishernothanks \newline
\textit{First edition, \monthyear}.
}
\dedication{To my thumb.}
\begin{document}
\frontmatter
\maketitle    

\blinddocument
\chapter{Let's test the result}
\begin{labeling}{the thanklessauthor}
\item[The author] \makeatletter \@author \makeatother
\item[the thanklessauthor] \thanklessauthor
\item[the plainauthor] \plainauthor
\item[the publisher] \makeatletter\@publishers\makeatother{}
\item[the shortpublisher]\shortpublishers
\item[publishernothanks]\publishernothanks
\item[publishthanksnote]\publisherthanksnote
\end{labeling}
\end{document}

在此处输入图片描述

相关内容