1

I have a user-defined environment \src{...} for source language and \ft{...} for free translation. I use these for 90 language examples in my findings chapter but they're eating into my word limit. I would like to get a word count for everything inside the \src{...} environment in order to make a decision about putting them into an appendix. I've been looking at the texcount manual but not seeing a solution there (which is not to say there isn't one!). Is there anyway to either get a word count for just that environment or get a word count that excludes it?

2
  • Welcome to the site. Can you include a short but working example of code that demonstrates the issue at hand? Feb 7, 2021 at 1:49
  • Thank you. I'll put one together but I thought this was pretty straight forward and wouldn't be helped by an MWE. Feb 7, 2021 at 2:16

1 Answer 1

2

You can do this with TeXcount quite easily by adding new counters for your contexts of interest.

% Add new word counters
%TC:newcounter source Source text
%TC:newcounter trans Translated

% Add counting rules for macros indicating how to count their arguments
%TC:macro \src [source]
%TC:macro \ft [trans]

This is a test of macros for counting translated examples.

\src{Source text to be counted separately.}

\ft{Translated text.}

The output may depend on the options with which TeXcount is run. You can test this out on the TeXcount web-service for which the default options produce the following summary:

    Word count
    Words in text: 10
    Words in headers: 0
    Words outside text (captions, etc.): 0
    Number of headers: 0
    Number of floats/tables/figures: 0
    Number of math inlines: 0
    Number of math displayed: 0
    Source text: 6
    Translated: 2
    Subcounts:
      text+headers+captions (#headers/#floats/#inlines/#displayed)
      10+0+0+6source+2trans (0/0/0/0) _top_

The %TC: comments are instructions to TeXcount which are included in the document. There are a number of these, which you can find summarised in the documentation web page and explained in greater depth in the PDF you have already looked at. Some of these instructions are for adding counting rules, while other enable you to change the format of the output (eg templates).

1
  • I pasted your commented lines at the top of my chapter file and ran it through TeXcount. This gave me precisely the results I wanted. Thank you for the concise explanation and references back to the documentation. Feb 7, 2021 at 5:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .