# A different counter for each subsection subsection, but called by the same command

I am writing some flashcards. The command \flashc is the essential one which is used to typeset the content of a flashcard. It works like this:

1. The counter is printed (on the first page of the flashcard). It gets incremented immediately after that.

2. Then the question gets printed.

3. A new page is reached by using \newpage. On that new, second page (or backside) of the flashcard, the reply is printed.

There are a few characteristics in regards to the content I want to consider:

• The flashcards I am writing are on specific topics in a field. I chose to follow the scripture of the main author John Smith and mirror his structure. So every topic gets put in its own section.

• Besides the main author, there are at least 2 more important authors whose work I would like to use as well. I would like to incorporate the content of all authors (3, at the moment) in one document.

• This yields the following structure: content by John Smith is put in the first subsection of each section, the second author (an "institute") is featured in the second subsection and an arguably young-ish author in the field gets put in the third subsection.

• However, sometimes an author has not covered a topic, so I would then call the command and the immediately continue with the next subsection, i.e. the subsection would be empty.

# My approach

My approach so far has been to simply "clone" and rename the original definition of \flashc. Then I worked 3 different counters into all versions of the command/macro.

# Vision

I would just like to use \flashc instead of n versions of it.

This new command should "remember" the counter in the corresponding subsection for each author/source, so it can be continued/used in the next section, for the same nth subsection for the same author/source. This can be observed in the MWE.

Is this possible without defining n command duplicates of \flashc?

Or is there another elegant way to re-use the command definition with a new counter perhaps? If so, what could it look like?

# MWE

\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{\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{\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{\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}

• @UlrichDiez I edited the op. Upon re-reading it, it wasn't really well-explained and easy to comprehend at all. Sorry for that. I hope now it is relatively ok to understand. May 30, 2020 at 16:03

If you want that the counter A is used in any subsection ending in x.1, B on x.2, etc, you can do this:

\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}%
}

\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}

\subsection{Another subsection with whatitis}

\subsection{This is text with oijoij}

\section{Another section to demonstrate}

\subsection{Again the first subsection with kk}

\subsection{This is for whatitis}

\subsection{And again oijoij}


PS: using \refstepcounter to increase your counter will give you the possibility to \label and the \reference it.
• I've combined your solution with the "nominative" code from my updated op. The code can be found here. I have encountered an unforeseen problem with it, unfortunately: if I leave the second argument of \addpageauto empty, LaTeX does not produce the second page (which is an unintended consequence, I hope?). I would still like to have it, for writing the solution on it by hand. Could you perhaps consider this with your code? May 31, 2020 at 16:01
• I have to check it, but you can try to add a \null before the last \noindent. May 31, 2020 at 20:50