LaTeX forum ⇒ Feature Suggestionsword count

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

Re: word count

Postby Nasseroleslami » Wed Jun 16, 2010 1:50 am

Hi there,

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

  1. 1. Install ActivePerl
  2. 2. in TeXnicCenter go to /Tools/Customize/tools/new(insert)/
  3. 3. Fill in:
  4. WordCount
  5. command: "cmd /K texcount"
  6. Arguments: "-inc %pm"


Now you have a menu command that does the job. Please let us know if it works for you.

Sincerly
Bahman

div
Posts: 6
Joined: Tue Aug 24, 2010 6:15 pm

Postby div » Mon Aug 30, 2010 12:29 pm

Thanks a lot, this works like a charm!

jason2
Posts: 10
Joined: Fri Sep 24, 2010 1:47 am

Postby jason2 » Fri Sep 24, 2010 3:37 pm

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
Location: Amherst, MA

Postby frabjous » Fri Sep 24, 2010 9:42 pm

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

  1. -sum, -sum= Make sum of all word and equation counts. May also
  2. use -sum=#[,#] with up to 7 numbers to indicate how
  3. each of the counts (text words, header words, caption
  4. words, #headers, #floats, #inlined formulae,
  5. #displayed formulae) are summed. The default sum (if
  6. 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

Postby jason2 » Sat Sep 25, 2010 1:50 am

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
Location: Amherst, MA

Postby frabjous » Sat Sep 25, 2010 2:33 am

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:
  1. %TC:group table 0 1
  2. %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:

  1. \documentclass{article}
  2. %TC:group table 0 1
  3. %TC:group tabular 0 1
  4. \begin{document}
  5. \begin{table}
  6. \begin{tabular}{cccc}
  7. A & B & C & D \\
  8. 1 & 2 & 3 & 4 \\
  9. 5 & 6 & 7 & 8 \\
  10. \end{tabular}
  11. \end{table}
  12. \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:
  1. \documentclass{article}
  2. %TC:group table 0 1
  3. %TC:group tabular 0 1
  4. \begin{document}
  5. \begin{table}
  6. \begin{tabular}%
  7. %TC:ignore
  8. {cccc}
  9. %TC:endignore
  10. A & B & C & D \\
  11. 1 & 2 & 3 & 4 \\
  12. 5 & 6 & 7 & 8 \\
  13. \end{tabular}
  14. \end{table}
  15. \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

Postby gingerella » Fri Jan 07, 2011 4:41 pm

Nasseroleslami wrote:Hi there,

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

  1. 1. Install ActivePerl
  2. 2. in TeXnicCenter go to /Tools/Customize/tools/new(insert)/
  3. 3. Fill in:
  4. WordCount
  5. command: "cmd /K texcount"
  6. 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 5768 times

NOTES

    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

Postby buster » Mon Mar 21, 2011 2:12 pm

this is amazing.
thanks kindly to Nasseroleslami and gingerella.


Return to “Feature Suggestions”

Who is online

Users browsing this forum: No registered users and 1 guest