我的方法

我的方法

我正在写一些抽认卡。该命令\flashc是用于排版抽认卡内容的基本命令。它的工作原理如下:

  1. 计数器已打印(在闪存卡的第一页上)。此后,它会立即增加。

  2. 然后问题就被打印出来了。

  3. 使用 可到达新页面\newpage。在新的抽认卡的第二页(或背面)上,打印了答案。

关于内容,我想考虑以下几个特点:

  • 我正在编写的抽认卡针对的是某个领域的特定主题。我选择遵循主要作者约翰·史密斯的经文并模仿他的结构。因此每个主题都放在自己的部分中。

  • 除了主要作者之外,至少还有两位更重要的作者,我也想使用他们的作品。我想将所有作者(目前为 3 位)的内容合并到一份文档中

  • 这样就产生了以下结构:约翰·史密斯 (John Smith) 的内容放在每个部分的第一个小节中,第二作者(“机构”)放在第二个小节中,而该领域一位可以说是年轻的作者放在第三个小节中。

  • 但是,有时作者没有涵盖某个主题,因此我会调用该命令并立即继续下一个小节,即该小节将为空。

我的方法

到目前为止,我的方法是简单地“克隆”并重命名的原始定义\flashc。然后,我将 3 个不同的计数器放入命令/宏的所有版本中。

想象

我只想用\flashc而不是n它的版本。

这个新命令应该“记住”每个作者/来源相应小节中的计数器,以便可以在下一部分中继续/使用相同的n同一作者/来源的第 1 子节。这可以在 MWE 中观察到。

这可能吗而无需定义n命令重复\flashc

或者是否有另一种优雅的方式,可以使用新计数器重新使用命令定义?如果是这样,它会是什么样子?

平均能量损失

\documentclass[
german,
fontsize=11pt,
paper=a6,
landscape,
]{scrartcl}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

%%%%%%%%%%%%%%%%%%%%%%%%
% the 1st counter - used by \flashc
%%%%%%%%%%%%%%%%%%%%%%%%

\newcounter{firstcount}
\setcounter{firstcount}{1}
\newcommand{\thefirstcounter}{\arabic{firstcount}\addtocounter{firstcount}{1}}

\newcommand{\flashc}[2]{%
\begin{flushleft}
\fbox{\thefirstcounter}~%
\begin{minipage}[t]{0.9\textwidth}
{#1}
\end{minipage}\end{flushleft}\newpage%
\noindent{%
#2}\newpage}

%%%%%%%%%%%%%%%%%%%%%%%%
% the 2nd counter - used by \firstcloneofflashc
%%%%%%%%%%%%%%%%%%%%%%%%

\newcounter{secondcount}
\setcounter{secondcount}{1}
\newcommand{\thesecondcounter}{\arabic{secondcount}\addtocounter{secondcount}{1}}

\newcommand{\firstcloneofflashc}[2]{%
\begin{flushleft}
\fbox{\thesecondcounter}~%
\begin{minipage}[t]{0.9\textwidth}
{#1}
\end{minipage}\end{flushleft}\newpage%
\noindent{%
#2}\newpage}

%%%%%%%%%%%%%%%%%%%%%%%%
% the 3rd counter - used by \secondcloneofflashc
%%%%%%%%%%%%%%%%%%%%%%%%

\newcounter{thirdcount}
\setcounter{thirdcount}{1}
\newcommand{\thethirdcounter}{\arabic{thirdcount}\addtocounter{thirdcount}{1}}

\newcommand{\secondcloneofflashc}[2]{%
\begin{flushleft}
\fbox{\thethirdcounter}~%
\begin{minipage}[t]{0.9\textwidth}
{#1}
\end{minipage}\end{flushleft}\newpage%
\noindent{%
#2}\newpage}

\begin{document}
    
\section{The first field/topic, Walls}

\subsection{The first subsection is from a specific literature source, John Smith}

\flashc{Walls are\ldots}{not that exciting to look at.}

\subsection{Content in the second subsection(s) is always from a certain institute}

\firstcloneofflashc{Wall can be\ldots}{incredibly boring to observe. They just stand still!}

\subsection{The third subsection is for another author, namely Jane Doe}

\secondcloneofflashc{Walls are great, but\ldots}{need some proper building first.}

\secondcloneofflashc{The 2nd flashcard by Jane Doe about walls}{No idea.}

\secondcloneofflashc{Another flashcard to memorize}{How much can someone write about walls, really??}

\section{The second field/topic, Trees}

\subsection{Again the first subsection with content by John Smith}

\flashc{Yes}{No}

\subsection{The second subsection is again from content by that certain institute}

\firstcloneofflashc{Leafs}{Green}

\subsection{The third subsection for Jane Doe's comments on the matter}

\secondcloneofflashc{Trees are not}{my thing. Too woody.}

\end{document}

答案1

如果您希望计数器 A 用于以十.1,Bx.2等,你可以这样做:

\documentclass[
german,
fontsize=11pt,
paper=a6,
landscape,
]{scrartcl}

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}

\newcounter{cntA}\setcounter{cntA}{0}
\newcounter{cntB}\setcounter{cntB}{0}
\newcounter{cntC}\setcounter{cntC}{0}
\newcommand{\usecnt}{%
    \edef\letter{\Alph{subsection}}%
    \refstepcounter{cnt\letter}%
    \arabic{cnt\letter}%
}

\newcommand{\addpageauto}[2]{%
\begin{flushleft}
    \fbox{\usecnt}~
    \begin{minipage}[t]{0.9\textwidth}
    {#1}%
    \end{minipage}\end{flushleft}\newpage%
    \noindent{%
    #2}%
    \newpage
}


\begin{document}
\section{The first words}

\subsection{The first subsection with kk}
\addpageauto{stuff}{more words for that stuff}

\subsection{Another subsection with whatitis}

\addpageauto{jjjjjjjjjj}{gggggggggg}

\subsection{This is text with oijoij}

\addpageauto{22222222}{333333333}

\addpageauto{bla}{yes it was blaaaaaa}

\addpageauto{Lorem}{Ipsum}

\section{Another section to demonstrate}

\subsection{Again the first subsection with kk}

\addpageauto{Yup}{Stuff}

\subsection{This is for whatitis}

\addpageauto{kkkk}{lllll}

\subsection{And again oijoij}

\addpageauto{4444}{5555}

\end{document}

...显然,当没有子节或子节时,这会破坏你的调用x.4(您必须添加另一个计数器...)。

PS:使用\refstepcounter增加你的计数器将使你有机会\label\ref获得它。

相关内容