I am keeping track of all the journal papers I review, and of course I'm using LaTeX.
There are different journals I review for and I have different tables and counters keeping track of papers. Each journal has it's own section---something similar to this:
IEEE Transactions on Power Systems (2)
- Title of the first paper, my decision, editor's decision.
- Title of the second paper, my decision, editor's decision.
IEEE Transactions on Power Delivery (1)
- Title of the first paper, my decision, editor's decision.
I have defined environments and commands to automate things as much as possible. I want to be able to show the number of papers at the beginning of my document; therefore, I'm using totcount package. Then simply writing something like (after defining TPWRD as a "total" counter)
Total number of TPWRD papers: \total{TPWRD}
does the trick. But I also want to show this number in the section title, as shown above in the parenthesis, and in the table of contents. My problem is that using \total as part of a section/subsection title gives me the error "Undefined control sequence." This happens without any parametrization. That is, even
\section{Simple Section \total{TPWRD}}
results in an error. Using
\section[Simple Section]{Simple Section \total{TPWRD}}
avoids the problem by showing the counter value only in the section title and not in the table of contents. How can I have both?
I have also tried \protect\total{TPWRD}, but it results in another error: Missing number, treated as zero.
Here's a MWE:
\documentclass{article}
\usepackage{hyperref}
\usepackage{totcount}
\newtotcounter{TPWRD}
\begin{document}
\tableofcontents
\section{Journals \total{TPWRD}}
\stepcounter{TPWRD}
\end{document}

\protect\total{TPWRD}? – Harish Kumar Apr 27 '12 at 7:51\protectdoes the trick. You should make an answer. – Stephan Lehmke Apr 27 '12 at 8:43hyperrefis that the computation for\totalcannot be performed when preparing the bookmark text. So a non perfect remedy is to say\section{Journals \texorpdfstring{\protect\total{TPWRD}}{}}. It's not perfect because the number won't appear in the bookmark. – egreg Apr 27 '12 at 15:46\protectas you said. BTW your acceptance rate is only 25% which may not match with the tradition here. Please consider visiting all your questions and if they were useful pl. consider upvoting and accepting them. – Harish Kumar Apr 27 '12 at 15:53