(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.


            pdfborder={0 0 0}]{hyperref}


\newcommand{\duedate}[2]{\stepcounter{#2}\color{magenta} Due: #1}


\newenvironment{articlelist}[1]{%  Don't show counter for the first row, which is the title row
            c<{\ifnumcomp{\value{reversedummy}}{=}{0}%          Show decreasing counter
                {}%                                             Don't show counter for the title row
                %                                               Calculate the reverse counter as total-i+1
                \stepcounter{#1}\stepcounter{reversedummy}}%    Increment total papers, i
            p{3.8cm} p{12cm} m{3.5cm} p{3.4cm}}
        No & ID & Title & My Decision (Date) & Decision (Date) \\
    {   \bottomrule


% Prepare counters
\newcounter{JournalsTotal}\defcounter{JournalsTotal}{\totvalue{TPWRD} + \totvalue{TPWRS}}
\newcounter{JPendingsTotal}\defcounter{JPendingsTotal}{\totvalue{TPWRDpending} + \totvalue{TPWRSpending}}
\newcounter{PapersTotal}\defcounter{PapersTotal}{\value{JournalsTotal} + \value{ConferencesTotal}}
\newcounter{PendingsTotal}\defcounter{PendingsTotal}{\value{JPendingsTotal} + \value{CPendingsTotal}}

\textbf{\Large Reviewed Papers}\\
Last Updated \today; Last Count \thePapersTotal; Pending \thePendingsTotal. 


\section{Journals (\theJournalsTotal)}
\subsection{IEEE Transactions on Power Delivery}{TPWRD}{TPWRDpending}
    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)

\subsection{IEEE Transactions on Power Systems}{TPWRS}{TPWRSpending}
    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)

\section{Conferences (\theConferencesTotal)}
\subsection{APEC 2012}{APEC}{APECpending}
    APEC-000 &
    Divide and conquer: How to produce two conferences out of one &
    Accept (23-Aug-2011) &




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.

2 Answers 2


You can "save" the name of the counter in \subsection:


and then

\newcommand{\duedate}[1]{\stepcounter{\pendingcountername}\color{magenta} Due: #1}

Is that what you were looking for?

  • Yes, and then I also don't really need to include the counter name in \begin{articlelist}. But I think the first \newcommand won't compile without the braces. And #1 needs to be ##1 as \duedate has to be redefined inside \subsection. Commented Apr 29, 2012 at 20:34
  • @dochar Right about the {}, sorry I didn't test this. Edited. But about the ##1: \duedate doesn't have to be redefined anywhere as it will just access whatever value the new macro \pendingcountername has when \duedate is called. This is different from Peters approach. You don't have to change anything apart from what I wrote. Commented Apr 29, 2012 at 20:50
  • You're right. I also don't need a separate \pendingcountername, can simply do #2pending (as in @Peter Grill's approach). Commented Apr 29, 2012 at 21:25
  • 1
    @dochar That's correct. I wasn't aware that the naming scheme is always like that. What is the third argument of \section for then ;-) Commented Apr 30, 2012 at 2:51
  • @Stephen, for nothing now. I have removed that too! Commented Apr 30, 2012 at 4:27

Yo could redefine \duedate within the articlelist environment.

    \renewcommand{\duedate}[1]{\stepcounter{#1pending}\color{magenta} Due: ##1}
    .... rest of environment ....

Now you call \duedate with just one parameter (but only within the articlelist environment), the appropriate counter will be incremented.


  • As Stephan Lehmke pointed out, in the \renewcommand{\duedate} the first use of #1 refers to the parameter to the articlelist environment, but the second one needs to refer to the \duedate parameter, hence the need for the ##.
  • I think the second #1 should be ##1 in this case. Commented Apr 29, 2012 at 20:03
  • Yep, was just testing to see that the output was the same in both cases... and with your fix it seems to be... Commented Apr 29, 2012 at 20:06
  • Thanks Peter. I would "accept" your answer if I could accept two. @Stephen Lehmke's answer has the bonus feature that I won't need to pass the counter name in \begin{articlelist}. Commented Apr 29, 2012 at 21:27
  • 1
    Since the same counter is being passed to the modified \section command, you could use a similar technique and redefine the \duedate macro there: \renewcommand{\duedate}[1]{\stepcounter{#3}\color{magenta} Due: ##1}. In you case this would also necessitate another command as it appears that you do need that counter in the articlelist macro as well. It would be easier if you have composed a MWE for exactly these issues, and removed the unnecessary complications that are not related, as it makes it harder to focus on the actual problem. Commented Apr 30, 2012 at 1:17
  • @PeterGrill, I had a compromise to make. Make the example "minimum" enough, while still making it informative enough if somebody wants to use the code (or know what code exactly does). Commented Apr 30, 2012 at 4:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .