# Remove all tables from document

I need to do a wordcount of my thesis that excludes tables, but not their legends. I need to remove all of my tables, ideally with a command in the preable. I am currently using Foxit reader's wordcount tool.

MWE:

\documentclass{article}
\usepackage{multirow}

\begin{document}

\begin{table}[h!]
\centering
\begin{tabular}{l l l l}
\hline
Foo & Bar \\ bar bar bar & Sum & Foo \\ \hline
Foo & Bar & Sum & Foo \\
Foo & Bar & Sum & Foo \\
Foo & Bar & Sum & Foo  \\ \hline
\end{tabular}
\caption[Contexts]{Le Table}
\label{table:tisch}
\end{table}

The table is Table \ref{table:tisch}.

\end{document}

• Just an idea: How about using the comment package and redefining the tabular environment to act as a comment environment? – user36296 Aug 22 '16 at 13:47
• Yes that works. If you would like to submit this as answer I will accept it, otherwise I will answer my own question incorporating your suggestion. – George Vousden Aug 22 '16 at 15:34
• Thanks for asking! But please add an answer yourself, I would have to create an example first and you seem to already have the code. – user36296 Aug 22 '16 at 15:39

As suggested in the comments tabular environments are now ignored through redefinition of this command with the comment package. This is based on this answer.

\documentclass{article}
\usepackage{multirow}
\usepackage{comment}
\excludecomment{tabular}
\let\endtabular\relax

\begin{document}

\begin{table}[h!]
\centering
\begin{tabular}{l l l l}
\hline
Foo & Bar \\ bar bar bar & Sum & Foo \\ \hline
Foo & Bar & Sum & Foo \\
Foo & Bar & Sum & Foo \\
Foo & Bar & Sum & Foo  \\ \hline
\end{tabular}
\caption[Contexts]{Le Table}
\label{table:tisch}
\end{table}

The table is Table \ref{table:tisch}.

\end{document}


One solution is to use TeXcount, which should most likely come along with your TeX installation, which defaults to ignoring tables but counting their captions. By default, headlines, regular text, and caption texts are counted separately, but this can be modified if desired.

It is possible to call TeXcount from the TeX/LaTeX document, and include the word count: see details in the FAQ, or StackExchanges questions here and here.