Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sorry this is a bit specific, but I could really use some help. I am trying to work out a good way of getting a word count for my thesis. I do most of my editing on windows, via TeXnicCenter v1 and MikTeX2.9.

The TeXCount webpage implies that MikTeX should come with TeXCount installed, and I see texcount.exe under C:\ProgramFiles\MiKTeX 2.9\miktex\bin\x64 but I don't understand how to use it.

I have seen the following question Using TeXcount with TeXnicCenter on this site, but I decided to go down the route suggested on this thread http://www.latex-community.org/forum/viewtopic.php?f=36&t=730 because it seemed to me some folks had actually got it working, but it hasn't helped me yet.

I followed the instructions

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

At this point it seems to try to run MiKTeX 2.8 but I have no idea why! And then throws up an error message saying "The Perl script could not be found."

I am not surprised, I can't find it either. It is not installed in MiKTeX 2.9\scripts. I have downloaded it myself and put TeXcount_3_0_0_24 into that directory, but I am not confident that this path is being scanned by MiKTeX, and again I am not sure how to make that happen. I tried putting it elsewhere and providing MiKTeX with a new location, but MiKTeX just told me it was "Not a TDS-compliant root directory".

I am rather stumped. I don't want to have to go putting copies of perl scripts and executables into all my directories as the final post suggested.

Alternatively, if you think I am crazy to be going down this route, can anyone recommend a free pdf word counting tool? I'd prefer texcount because my word limit does not include captions, references etc and it's a faff to strip them out.

As a last resort I can ftp everything across to linux and try to install TeXCount there, but I'd prefer to stick with my laptop if I can.

share|improve this question
    
I just tried pointing command: texcount.exe where I point to the executable in miktex2.9\bin and now it just says "file not found". It seemed to do some kind of package installation step, but I still see no sign of the .pl anywhere –  FionaSmith Apr 16 at 16:02
1  
I just installed texcount with the miktex package and it worked out-of-box without problem (but it didn't like text after \end{document}). Adding scripts manually should normally not be necessary in miktex. Imho "cmd /K texcount" in texniccenter is wrong. Use simply "texcount" as command and -inc %pm as argument. Also I certainly would never try an installation instruction that is more than 7 years old. –  Ulrike Fischer Apr 16 at 16:10
    
Thanks @UlrikeFischer, I agree it's too old, but I had no clue where to start. Anyway, I have changed my "tool settings" to match yours, but now it says no file specified. Progress at least, it looks like it is actually trying to run texcount even if it is not finding my file. –  FionaSmith Apr 16 at 16:16
    
I put double quotes around "%pm" and now it seems to run, but a box pops up for 0.2 seconds, I can't see what it's saying because it then closes instantly. I have used -html and >texcount.html but the resulting file is blank. Guess I need to know how to forward stderr to a file under windows! –  FionaSmith Apr 16 at 16:27
    
I didn't test texcount in texniccenter (which I don't use) but on the command line. I don't know what you should do in texniccenter to see the output of the command line. Redirection to a file should work with %pm >texcount.log –  Ulrike Fischer Apr 16 at 16:37
show 2 more comments

2 Answers 2

I guess I will answer my question, although it isn't solved as such - but at least I can use TeXcount on windows via what seems to me a very linuxy method!

  1. I installed ActivePerl
  2. I have MikTex installed which has texcount.exe as listed in the question
  3. I hunted around for texcount.pl but still haven't found it - which makes me wonder whether the executable actually contains compiled perl?
  4. I did attempt to run the commands as stated in the original question, and MiKTex did claim to be doing a package install, but I stopped watching so I don't know what it actually did!

Anyway, the outcome is that I can now fire up a command prompt, go to the directory containing my tex file, and run texcount -html my_file.tex >my_file_wc.html and get sensible readable output.

share|improve this answer
add comment

The original TeXcount is a Perl script, which would typically be called texcount.pl (or with version codes attached). To run this, you need Perl installed: ActivePerl and StrawberryPerl are two popular options on Windows. Apart from this, TeXcount requires no installation: the texcount.pl Perl script is entirely self-contained.

As Ulrike Fisher has pointed out, the texcount.exe file is just a wrapper for calling texcount.pl. MiKTeX has TeXcount version 3.0 (latest release); in my MiKTeX installation, I only find TeXcount version 2.3, but my MiKTeX may be dated. You can run texcount -ver to check the version, but that shouldn't be the problem.

If you have downloaded the script from the TeXcount web site as texcount_3_0_0_24.pl, you might want to rename it texcount.pl, or next time when you upgrade to a new version you'll have all references pointing to the older version.

When you're trying to run TeXcount, be that texcount.exe or texcount.pl, you may need to specify the full path or add the location to the PATH environment variable. In some cases, you might also have to execute the Perl script using perl texcount.pl if the file type .pl is not associated with Perl.

If you run TeXcount using the command texcount only, I suspect it is the texcount.exe executable that is being run.

If you are running TeXcount from within another program (e.g. TeXnicCenter) and the piping to file using texcount ... > outfile causes problems, as I know it does with some applications, you can use the -out= option instead: texcount ... -out=outfile.

Another alternative is to make a file texcount.bat as described in the TeXcount FAQ or using the provided script file (texcount.bat) which you'd probably have to modify a bit to run. This could do the word count and open the output in a browser, which is the solution I tend to use.

share|improve this answer
    
I expect you are right @Einar - I am sure it is running the one contained in MiKTeX - interesting to know that is an old version. I don't really need to run it through TeXnicCenter now I have it working via other means, but it's useful to know about -out - I might try it just to see if it works for me. Since I have installed texcount.pl (the _3_0_0_24 was the directory name, not the perl itself), I would prefer to run the newer version - I guess I need to work out how to fiddle with "$PATH" on Windoze. I asked for .pl to be associated with perl so should be OK on that front... –  FionaSmith Apr 17 at 8:27
    
Just an update. -out does now write something to the file, but it is just a list of the formatting for verbose output: for some reason the actual counts do not appear - I expect it is not picking up the file specified by "%pm". On the other hand, it does seem to be version 3.0 so I am not going to bother trying to work out how to use my downloaded version –  FionaSmith Apr 17 at 10:09
2  
No that's wrong. The texcount.exe in miktex is not a "compiled version". It is a simple wrapper for a "perl texcount.pl" call (as you see by its size of only 33kb). You need perl to run it. Also in the scripts folder of miktex there is a texcount.pl (if the package has been installed correctly) and it contains the message my $versionnumber="3.0";. So it is version 3.0. –  Ulrike Fischer Apr 17 at 11:58
    
@UlrikeFischer: Thanks for the correction. I have updated the answer accordingly. Maybe my MiKTeX installation is old as it only gives me TeXcount v2.3 (even after attempting an update). –  Einar Rødland Apr 17 at 20:44
    
@UlrikeFischer I do not have a texcount.pl anywhere (at least, I did a file search on the whole C:\ drive) and certainly not in the scripts directory, which was the first place I looked, but I can run texcount. –  FionaSmith Apr 22 at 7:57
show 4 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.