TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like a way to get a word count while ignoring certain environments. The reason for this is that I have quite a bit of pseudocode enclosed within multiple verbatim blocks.

Ideally, a solution would be like this, but with the ability to select which environments to not select.

edit: I am using TexStudio

share|improve this question

As far as I know there is no solution you want.

You can try to use package ifthen. Define a boolean variable (\newboolean{WordCount}), set it to true (\setboolean{WordCount}{true}) or false (\setboolean{WordCount}{false}) and suround all environments you do not wanted to be counted with \ìfthenelse{WordCount}{}{<your environment>}. So if WordCount is false your environment is executed, if it is true your environment is not executed:

%in your praeambel:
\usepackage{ifthen}  % http://www.ctan.org/pkg/ifthen
%in your document:
   % True, no environment to be executed
}{% False, execute environment:
 <your environment here>

Please take a look to the related question is there any way to do a correct word count of a LaTeX document and combine one of the methods there with the code above.

Hope that helps.

share|improve this answer

Your Answer


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.