\exclude
appropriately). Does anyone have any suggestions on how to best go about this?Code: Select all
% !TEX program = XeLaTeX
\documentclass{article}
\usepackage{xesearch}
\newcounter{counted}% for creating unique counted* macros
\newcounter{words}[counted]% let words counter be reset by counted
\makeatletter
\newenvironment{counted}{%
\newcommand{\exclude}[1]{##1}% this command should prevent the words in its argument from being included in the word count.
\par\noindent\hrulefill\par
\stepcounter{counted}%
\@ifundefined{counted\thecounted}{%
\marginpar{\footnotesize\itshape?? words}%
}{%
\marginpar{\footnotesize\itshape\@nameuse{counted\thecounted} words}%
}%
\SearchList!{wordcount}{\stepcounter{words}}
{a?,b?,c?,d?,e?,f?,g?,h?,i?,j?,k?,l?,m?,
n?,o?,p?,q?,r?,s?,t?,u?,v?,w?,x?,y?,z?}
\UndoBoundary{'}
\SearchOrder{p;}}{%
\StopSearching
\immediate\write\@auxout{\string\global\string\@namedef{counted\thecounted}{\thewords}}%
\marginpar{\raggedright\footnotesize\textit{End counting words}}
\par\noindent\hrulefill}
\makeatother
\begin{document}
\begin{counted}
In order to better understand this sentence we will expand the predicate by replacing each term with its definition. “Reverence” is an intentional action directed towards an object (using “object” in the broadest sense of the word so that it includes everything which can be thought of) for the purpose of honoring that object and/or acknowledging the subordination of the subject to the object (the actual mix being determined on a case-by-case basis). The modification by “natural” in the sentence indicates that this action is not one which is learned, but rather arises from the essence of the subject performing the action. The possessive “mind's” further modifies this action to indicate that it is one involving the active mental faculties. Further it restricts the possible domain of subjects to those which possess said active mental faculties. Putting all this together, the predicate can be expanded as “the intentional actions of a being with active mental faculties which direct said faculties towards an object for the purpose of honoring or subordinating the subject to said object and which arise from the essence of the being possessing said faculties.”
\exclude{These seven words should not be counted.}
\end{counted}
When working correctly, the count above should be 187, not 193.
\end{document}