Results 1 to 10 of 10

Thread: Word Count in Texmaker

  1. #1
    Join Date
    Dec 2007
    Location
    Cambridge, MA
    Beans
    35
    Distro
    Ubuntu 10.04 Lucid Lynx

    Word Count in Texmaker

    Hey all,

    I'm trying to get Texmaker to do a word count of my latex files. I found this perl script here:

    http://wing.comp.nus.edu.sg/~min/texWordCount/

    which does what I want.

    The gold standard for me would be if I can press some keys and have the output of this script output to the Messages/Log File section for me. However, while Texmaker will run the command, it won't actually output anything there and simply says process started and exited normally. I assume this is because the command doesn't generate a log file? Is there a way to make Texmaker output the results of this script to that section?

  2. #2
    Join Date
    Feb 2009
    Location
    USA
    Beans
    3,186

    Re: Word Count in Texmaker

    Try playing with Texmaker -> User -> Commands.

  3. #3
    Join Date
    Dec 2007
    Location
    Cambridge, MA
    Beans
    35
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Word Count in Texmaker

    Yeah, I've got a user command set up with the command:

    texWordCount.pl %.tex

    which when run in the terminal gives me:

    1885 whole - dp1report.tex
    158 Section 1 - XXX
    822 Section 2 - XXX
    300 Subsection 1 - XXX
    111 Subsection 2 - XXX
    168 Subsection 3 - XXX
    207 Subsection 4 - XXX
    354 Section 3 - XXX
    327 Section 4 - XXX
    201 Section 5 - XXX

    but when done in Texmaker just gives me:

    Process started

    Process exited normally.

    So I don't know how to get the results output the messages/log file box.

  4. #4
    Join Date
    Dec 2007
    Location
    Cambridge, MA
    Beans
    35
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Word Count in Texmaker

    I figured it out. I had to find where the perl script was printing the output and append STDERR before it to make Texmaker show it.

  5. #5
    Join Date
    Feb 2006
    Location
    Belgium
    Beans
    25
    Distro
    Ubuntu 8.10 Intrepid Ibex

    Re: Word Count in Texmaker

    Using these instructions, I was able to adapt version 2.1 of the script: it now prints the statistics to texmaker. You just have to add a user-command "/path/to/script/ %.tex"
    Attached Files Attached Files
    Last edited by Pixilarion; April 23rd, 2009 at 04:18 PM.

  6. #6
    Join Date
    Aug 2008
    Location
    Los Angeles
    Beans
    16
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Word Count in Texmaker

    Another option: in User -> User commands -> Edit User Commands

    In the 'Menu Item' field put: Wordcount (or whatever you want)
    In the 'Command' field put: wc -w %.tex

    That's it. User -> User Commands -> Wordcount now gives you a straight wordcount for the entire open document in the messages pane.

    If you want # lines instead of # words change the above to wc -l %.tex. For other options (# characters, # bytes..) type wc --help on a command line.

    I have to admit that I was surprised to find Texmaker/x doesn't have a built-in wordcount utility though.

  7. #7
    Join Date
    Dec 2009
    Beans
    4

    Re: Word Count in Texmaker

    In the 'Menu Item' field put: Wordcount (or whatever you want)
    In the 'Command' field put: wc -w %.tex
    I tried this, but all I get out is "Process Started" ... "Process Exited Normally". How to I get the results?

    Thanks,
    John

  8. #8
    Join Date
    Apr 2011
    Beans
    6

    Re: Word Count in Texmaker

    Pixilarion script works just fine, but for some reason, no newlines are passed to message window in texmaker. Any way to fix it? I know a little programming, so it can be just overview of possible solution if somebody don't have time to go deep into problem.

  9. #9
    Join Date
    Mar 2012
    Beans
    3

    Re: Word Count in Texmaker

    sorry to raise this thread from the dead. but i thought someone else might find this useful.

    the first script linked in this thread is really good and can jump from tex file to tex file if your latex project has multiple tex files (e.g. one for each chapter).

    instead of trying to tweak the script to print to STDERR, i wrapped the entire perl script within a shell script that wrote to a file. After which an xmessage command in texmaker to have a pop-out message showing the breakdown of wordcount without the newline issues mentioned above.

    counter.sh:
    Code:
    #!/bin/bash
    perl texWordCount.pl $1 > count.txt

    and in texmaker user commands:
    Code:
    sh counter.sh %.tex | xmessage -file count.txt

  10. #10
    Join Date
    Jul 2007
    Location
    Magic City of the Plains
    Beans
    Hidden!
    Distro
    Xubuntu Development Release

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •