I have made a rather long list using the enumerate package. Part of my list (with preamble) is in the attached file.
Problem:
I would like LaTeX to print the total number of \item entries in my list.
In my attached example the number I would like LaTeX to print is 6, but there are over 500 entries in my ``real'' list.
P.S. I'm new at LaTeX...
Text Formatting ⇒ Print total number of \item entries in an enumerate list
- svend_tveskaeg
- Posts: 478
- Joined: Sun Jul 12, 2009 5:31 am
Print total number of \item entries in an enumerate list
- Attachments
-
- list.tex
- Part of my enumerate list.
- (987 Bytes) Downloaded 285 times
Last edited by svend_tveskaeg on Sun Jul 12, 2009 9:43 pm, edited 1 time in total.
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
-- Zapp Brannigan, Futurama (season 1, episode 4)
- localghost
- Site Moderator
- Posts: 9201
- Joined: Fri Feb 02, 2007 12:06 pm
Print total number of \item entries in an enumerate list
Try the totcount package. The concerning counter would be enumi (first level enumeration) in this case.
Best regards and welcome to the board
Thorsten
Best regards and welcome to the board
Thorsten
How to make a "Minimal Example"
Board Rules
Avoidable Mistakes[/size]
¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
Board Rules
Avoidable Mistakes[/size]
¹ System: openSUSE 42.2 (Linux 4.4.52), TeX Live 2016 (vanilla), TeXworks 0.6.1
- svend_tveskaeg
- Posts: 478
- Joined: Sun Jul 12, 2009 5:31 am
Re: Print total number of \item entries in an enumerate list
Thank you for the reply!
I don't know exactly what to write in my document---can you please help me? I'm probably just ``dumb'' but I can't figure out what the problem is.
See the attached file for my poor attempt. LaTeX doesn't print anything when I try this.
I don't know exactly what to write in my document---can you please help me? I'm probably just ``dumb'' but I can't figure out what the problem is.
See the attached file for my poor attempt. LaTeX doesn't print anything when I try this.
- Attachments
-
- list.tex
- (999 Bytes) Downloaded 297 times
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
-- Zapp Brannigan, Futurama (season 1, episode 4)
- svend_tveskaeg
- Posts: 478
- Joined: Sun Jul 12, 2009 5:31 am
Re: Print total number of \item entries in an enumerate list
Wauw; I was indeed ``dumb''! I forgot to load the keyval package, but it still won't produce anything.
I have attached the updated (La)TeX file together with the log file.
I hope you can and will help me.
I have attached the updated (La)TeX file together with the log file.
I hope you can and will help me.

``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
-- Zapp Brannigan, Futurama (season 1, episode 4)
- svend_tveskaeg
- Posts: 478
- Joined: Sun Jul 12, 2009 5:31 am
Re: Print total number of \item entries in an enumerate list
Problem solved!
I have attached my TeX file so other people who are interested can see a possible solution.

I have attached my TeX file so other people who are interested can see a possible solution.
- Attachments
-
- list.tex
- (1.03 KiB) Downloaded 299 times
``In the game of chess, you can never let your adversary see your pieces.''
-- Zapp Brannigan, Futurama (season 1, episode 4)
-- Zapp Brannigan, Futurama (season 1, episode 4)
Print total number of \item entries in an enumerate list
Hi,
you can create a new counter and use it to keep record of the total number of times that the \movie command was used, as the following code illustrates:
you can create a new counter and use it to keep record of the total number of times that the \movie command was used, as the following code illustrates:
Code: Select all
\documentclass[a4paper,12pt]{article}
\usepackage{enumerate}
\usepackage{color}
\usepackage{mathtools}
\usepackage[colorlinks=true,urlcolor=black]{hyperref}
\newcounter{mycounter}
\newcommand{\options}[3]{\color{#1}#2\fontsize{#3}{#3}\selectfont}
\newcommand{\movie}[4]{\stepcounter{mycounter}%
\item \fontsize{12pt}{12pt}\selectfont
\textsf{[#4]\enskip\href{#1}{#2} (#3)}
}
\begin{document}
\begin{enumerate}[\options{blue}{\bfseries\sffamily}{10pt}$\star$\qquad]
\movie{http://www.imdb.com/title/tt0020629/}{All Quiet on the Western Front}{1930}{8,1}
\movie{http://www.imdb.com/title/tt0074119/}{All the President's Men}{1976}{8,0}
\movie{http://www.imdb.com/title/tt0765429/}{American Gangster}{2007}{8,0}
\movie{http://www.imdb.com/title/tt0120586/}{American History X}{1998}{8,6}
\movie{http://www.imdb.com/title/tt0052561/}{Anatomy of a Murder}{1959}{8,1}
\movie{http://www.imdb.com/title/tt0078788/}{Apocalypse Now}{1979}{8,6}
\end{enumerate}
My total number of movies is \themycounter.
\setcounter{mycounter}{0} % to reinitialize the counter, if necessary
\end{document}
1,1,2,3,5,8,13,21,34,55,89,144,233,...