Is it possible to define a new Converter in LyX so I can use texcount -sub and produce a .txt file with the statistics of the file?

I was thinking in going to

Tools -> Preferences -> Converters

and redefine the Lyx -> Plain Text option, but it does not seem to work

  • 1
    What do you mean by "does not seem to work" ? What are the exact steps you took to add a converter? What is the line in your preferences file (on Ubuntu this is ~/.lyx/preferences. On other OS's go to Help > About to find your user dir) after you create your converter? Have you read Help > Customization > 3.3 Converters ? Which version of LyX are you using?
    – scottkosty
    Dec 11 '13 at 5:37
  • Just in case you didn't know about it, does Tools > Statistics satisfy your needs?
    – scottkosty
    Dec 11 '13 at 5:38
  • Hi. I tried to use the LyX -> Plain Text converter and put the texcount -sub command. The statistics tool is too basic and I think it is counting the figures and footnotes. The -sub option in texcount gives a more detailed summary for the words number in each section. I will take a look to the customization
    – PerroNoob
    Dec 11 '13 at 9:21
  • OK, post back if you still have questions after reading it (and please answer the questions I asked you). Good luck!
    – scottkosty
    Dec 11 '13 at 17:02
  • Thanks for your help. I created a new entry in Tools -> Preferences -> File Formats called TexCounter with the txt Extension. Then in Converters I added Latex(plain) -> TeXCounter with the command: texcount -sub $$i . The new converter appears in the LyX menu (File -> Export) but I do not get a txt file with the texcount output. Am I doing something wrong? I tried to do something similar to this topic tex.stackexchange.com/questions/114285/… but I can't get what I want.
    – PerroNoob
    Dec 11 '13 at 18:29

The problem is that texcount writes to STDOUT, where I think you're assuming it's writing to a file somewhere.

The following works for me on Ubuntu:

  1. Create a file, mytexcount.sh.
  2. Make it executable.
  3. Put the following as the contents of the file:

    texcount -sub "$1" > /path/to/output/mycount.txt

  4. Change your converter command to

    /path/to/mytexcount.sh $$i

You can customize things further with other converter variables. See Help > Customization for more information.

  • Thanks a lot! It works. I realised that, to avoid creating a .sh file, it could be used texcount -sub $$i > $$o in the converter :)
    – PerroNoob
    Dec 11 '13 at 19:59
  • I had that the first time, but I had mistyped the variables. Now I can produce a Texcount without specifying paths, and it seems more general. Thanks again for your help
    – PerroNoob
    Dec 11 '13 at 20:00
  • Glad it works for you. That way wasn't working for me for some reason.
    – scottkosty
    Dec 11 '13 at 20:07
  • 2
    TeXcount also has an option -out=_filepath_ which can be used instead of > _filepath_ and may be more robust. Dec 11 '13 at 23:07
  • 2
    @EinarRødland +1. Note that texcount version 2.3 does not have this option. Version 3.0 does (and possibly earlier).
    – scottkosty
    Dec 11 '13 at 23:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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