Feature Suggestionsword count

Suggestions and discussions for new TeXnicCenter features
Nasseroleslami
Posts: 1
Joined: Tue Jun 15, 2010 7:39 pm

word count

Post by Nasseroleslami »

Hi there,

In TeCnicCenter 2.0 Alpha 3, this works for me under Vista 32/MikTeX 2.8.

Code: Select all

 1. Install ActivePerl
 2. in TeXnicCenter go to /Tools/Customize/tools/new(insert)/
 3. Fill in:
 WordCount
 command: "cmd /K texcount"
 Arguments: "-inc %pm"
Now you have a menu command that does the job. Please let us know if it works for you.

Sincerly
Bahman

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics
div
Posts: 6
Joined: Tue Aug 24, 2010 6:15 pm

Re: word count

Post by div »

Thanks a lot, this works like a charm!
jason2
Posts: 10
Joined: Fri Sep 24, 2010 1:47 am

Re: word count

Post by jason2 »

Nasseroleslami, your method works fantastically! Does anyone know if there is a way to actually count the number of words in floats (e.g. numbers in a table). My word count requirements call for this, and TexCount (http://folk.uio.no/einarro/Comp/texwordcount.html) does not seem to allow for that option.

Thanks,
Jason
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

word count

Post by frabjous »

You should be able to include floats by changing the -sum flag under options. To quote the help page:

Code: Select all

-sum, -sum=  Make sum of all word and equation counts. May also
             use -sum=#[,#] with up to 7 numbers to indicate how
             each of the counts (text words, header words, caption
             words, #headers, #floats, #inlined formulae,
             #displayed formulae) are summed. The default sum (if
             only -sum is used) is the same as -sum=1,1,1,0,0,1,1.
So -sum=1,1,1,1,1,1,1 should make it include everything, including floats and headers.

(If for some reason you only wanted a count in floats, you could use -sum=0,0,0,0,1,0,0.
jason2
Posts: 10
Joined: Fri Sep 24, 2010 1:47 am

Re: word count

Post by jason2 »

Hi,

I think that's still just summing the float caption titles. I would like to sum the number of words in a table (counting each number as a word). So if I had a 3 x 4 table filled with numbers, it should report 12 words (for the 12 numbers).

Any ideas?

Jason
User avatar
frabjous
Posts: 2064
Joined: Fri Mar 06, 2009 12:20 am

word count

Post by frabjous »

Ah, I see.

Looking a bit further, if you read the full documentation (available at the link you posted), you'll see that there are comments you can insert into the file to tell it how to treat various environments. E.g., you can put something like:

Code: Select all

%TC:group table 0 1
%TC:group tabular 0 1
which will make it process numbers and words in tables and tabular environments as text rather as floats.

It's tricky though. First I tried:

Code: Select all

\documentclass{article}
%TC:group table 0 1
%TC:group tabular 0 1
\begin{document}
    \begin{table}
        \begin{tabular}{cccc}
            A & B & C & D \\
            1 & 2 & 3 & 4 \\
            5 & 6 & 7 & 8 \\
        \end{tabular}
    \end{table}
\end{document}
It gave me 13. Looks like it was treating the "cccc" setting up the alignments for the tables as a word. There's a way around that too, like this:

Code: Select all

\documentclass{article}
%TC:group table 0 1
%TC:group tabular 0 1
\begin{document}
    \begin{table}
        \begin{tabular}%
            %TC:ignore
            {cccc}
            %TC:endignore
            A & B & C & D \\
            1 & 2 & 3 & 4 \\
            5 & 6 & 7 & 8 \\
        \end{tabular}
    \end{table}
\end{document}
This gives 12 as desired, but it would be kind of a pain to code everything like that. Maybe you could figure out a way around that though. I only spent a couple of minutes with the documentation. With further study, maybe you could figure it out.
gingerella
Posts: 3
Joined: Fri Nov 06, 2009 6:11 pm

word count

Post by gingerella »

Nasseroleslami wrote:Hi there,

In TeXnicCenter 2.0 Alpha 3, this works for me under Vista 32/MikTeX 2.8.

Code: Select all

 1. Install ActivePerl
 2. in TeXnicCenter go to /Tools/Customize/tools/new(insert)/
 3. Fill in:
 WordCount
 command: "cmd /K texcount"
 Arguments: "-inc %pm"
Now you have a menu command that does the job. Please let us know if it works for you.

Sincerly
Bahman
Hi there,

this worked a treat for me (after creating an Output Profile failed miserably). However, there were a few slight differences for it to work me and so I just wanted to clarify for any others having problems.

I have a main file thesis.tex; it worked for me when I put texcount.pl and perl.exe in the same folder as this main file. I followed Bahman's instructions and a picture paints a thousand words so below is a screenshot of what I entered into the fields when creating the 'Word Count' tool to get it to work for me.
WordCount.png
WordCount.png (56.29 KiB) Viewed 22958 times
NOTES
  1. 1. Command: I had to add the .pl file extension to texcount to get it to work. Otherwise, the following was produced at the cmd prompt:
    =====================================================
    texcount: Cannot start MiKTeX package manager.
    Texcount: Data: invalid syntax
    =====================================================
    texcount: The Perl script count not be found.
    texcount: Data: texcount
  • 2. Arguments: Bahman uses -inc %pm (the -inc part includes tex files included in the main file) but I believe he missed out a set of speech marks, so it should be -inc "%pm". However, double speech marks will not work if your folders and/or files have spaces. As mentioned by a previous poster in this thread, to solve this problem, use single speech marks such that it becomes -inc '%pm'.
I finally created a shortcut 'Ctrl+Shift+W' to run the Word Count tool. :D

Thanks,
Gingerella
buster
Posts: 19
Joined: Thu Mar 04, 2010 5:49 pm

Re: word count

Post by buster »

this is amazing.
thanks kindly to Nasseroleslami and gingerella.
Post Reply