(This question is related to Using \total of totcount package in section title)
I'd like to keep track of the papers I review, and I have written a code (MWE shown below). The code keeps the count of papers from different journals and then also calculates total and pending journal and conference papers, as shown in the screenshot after the code.
\documentclass[11pt,landscape]{article}
\usepackage[margin=.5in,top=0.75in]{geometry}
\usepackage{booktabs}
\usepackage[table,dvipsnames]{xcolor}
\definecolor{AleeRed}{rgb}{0.5,0,0}
\usepackage[colorlinks=true,
linkcolor=AleeRed,
pdfborder={0 0 0}]{hyperref}
\usepackage{etoolbox}
\usepackage{totcount}
\newtotcounter{TPWRD}\newtotcounter{TPWRDpending}
\newtotcounter{TPWRS}\newtotcounter{TPWRSpending}
\newtotcounter{APEC}\newtotcounter{APECpending}
\newcommand{\duedate}[2]{\stepcounter{#2}\color{magenta} Due: #1}
\let\oldsubsection\subsection
\renewcommand{\subsection}[3]{%
\oldsubsection{#1%
~\texorpdfstring{(\protect\total{#2})}{}%
\ifnumcomp{\totvalue{#3}}{=}{0}%
{}%
{~\texorpdfstring{\fbox{Pending:~\protect\total{#3}}}{}}}%
}
\newcounter{reversedummy}
\newcounter{reversecounter}
\newenvironment{articlelist}[1]{% Don't show counter for the first row, which is the title row
\setcounter{reversedummy}{0}
\begin{center}\small
\rowcolors{2}{white}{gray!35}
\begin{tabular}{%
c<{\ifnumcomp{\value{reversedummy}}{=}{0}% Show decreasing counter
{}% Don't show counter for the title row
% Calculate the reverse counter as total-i+1
{\defcounter{reversecounter}{\totvalue{#1}-\value{reversedummy}+1}\arabic{reversecounter}}%
\stepcounter{#1}\stepcounter{reversedummy}}% Increment total papers, i
p{3.8cm} p{12cm} m{3.5cm} p{3.4cm}}
\toprule
No & ID & Title & My Decision (Date) & Decision (Date) \\
\midrule
}
{ \bottomrule
\end{tabular}
\end{center}
}
\begin{document}
% Prepare counters
\newcounter{JournalsTotal}\defcounter{JournalsTotal}{\totvalue{TPWRD} + \totvalue{TPWRS}}
\newcounter{JPendingsTotal}\defcounter{JPendingsTotal}{\totvalue{TPWRDpending} + \totvalue{TPWRSpending}}
\newcounter{ConferencesTotal}\defcounter{ConferencesTotal}{\totvalue{APEC}}
\newcounter{CPendingsTotal}\defcounter{CPendingsTotal}{\totvalue{APECpending}}
\newcounter{PapersTotal}\defcounter{PapersTotal}{\value{JournalsTotal} + \value{ConferencesTotal}}
\newcounter{PendingsTotal}\defcounter{PendingsTotal}{\value{JPendingsTotal} + \value{CPendingsTotal}}
\begin{center}
\textbf{\Large Reviewed Papers}\\
Last Updated \today; Last Count \thePapersTotal; Pending \thePendingsTotal.
\end{center}
\tableofcontents
\section{Journals (\theJournalsTotal)}
\subsection{IEEE Transactions on Power Delivery}{TPWRD}{TPWRDpending}
\begin{articlelist}{TPWRD}
&
TPWRD-000-2011 &
Pizza delivery vs. power delivery: top 10 differences you always missed &
\duedate{3-May-2012}{TPWRDpending} &
\\
&
TPWRD-001-2011.R1 &
Recent advances in the IEEE website &
Reject (24-Mar-2012) &
Reject (22-Apr-2012)
\\
\end{articlelist}
\subsection{IEEE Transactions on Power Systems}{TPWRS}{TPWRSpending}
\begin{articlelist}{TPWRS}
&
TPWRS-001-2012 &
How to have your own DYI power system &
\duedate{18-May-2012}{TPWRSpending} &
\\
&
TPWRS-002-2011.R1 &
How power corrupts any system, including power system itself &
Revise (15-Mar-2012) &
Revise (12-Apr-2012)
\\
\end{articlelist}
\section{Conferences (\theConferencesTotal)}
\subsection{APEC 2012}{APEC}{APECpending}
\begin{articlelist}{APEC}
&
APEC-000 &
Divide and conquer: How to produce two conferences out of one &
Accept (23-Aug-2011) &
\\
\end{articlelist}
\addtocounter{TPWRD}{-1}
\addtocounter{TPWRS}{-1}
\addtocounter{APEC}{-1}
\end{document}
The code does what I need it to do, but there are two things I don't like about my code:
- I have to manually include the "pending" counter when I call
\duedate
. - I have to manually decrement the counters at the very end of the code.
Perhaps I can use \NewDocumentEnvironment
and include \addtocounter{#1}{-1}
in the end part of environment definition to solve the second problem. But I don't know how I can solve the first. The "pending" counter information is already passed to \begin{articlelist}
.
Is there any way to modify \duedate
so it can use the parameters of \begin{articlelist}
? I also welcome any suggestions for improving the code.