Here's a LuaLaTeX-based solution. It defines a Lua function called hide_stuff
which "gobbles" the contents of all figure
, table
, and lstlisting
environments. The only input-related requirements are: (a) the environments' \begin
and \end
statements must not occur on one and the same input line, and (b) there's only one \begin{...}
or \end{...}
statement per input line.
Note that it's not necessary to modify or "prime" any of the existing figure
, table
, and lstlisting
environments. All you need to do (besides using LuaLaTeX to compile the document) is to copy the code block from \usepackage{luacode}
to \AtBeginDocument{...}
into the preamble of your LaTeX document.

% !TEX TS-program = lualatex
\documentclass{article}
\usepackage{listings} % for 'lstlistings' environment
\usepackage{luacode} % for 'luacode' environment
\begin{luacode}
in_group = false -- initialize a Boolean variable
function hide_stuff ( buff )
if string.find ( buff, "\\begin{figure}" ) or
string.find ( buff, "\\begin{table}" ) or
string.find ( buff, "\\begin{lstlisting}" ) then
-- start gobbling
buff = buff:gsub ( "\\begin%b{}.-$" , "" )
in_group = true
elseif string.find ( buff, "\\end{figure}" ) or
string.find ( buff, "\\end{table}" ) or
string.find ( buff, "\\end{lstlisting}" ) then
buff = buff:gsub ( "^.-\\end%b{}" , "" )
in_group = false -- end gobbling
elseif in_group == true then
buff = "" -- keep gobbling
end
return buff
end
\end{luacode}
%% Assign the fuction to LuaTeX's "process_input_buffer" callback
\AtBeginDocument{\directlua{luatexbase.add_to_callback (
"process_input_buffer", hide_stuff, "hide_stuff" )}}
\begin{document}
aaa\begin{figure}
\caption{AAA} \end{figure}
bbb
\begin{table} \caption{BBB}
\end{table}ccc
\begin{lstlisting}
CCC
\end{lstlisting}
uuu\begin{figure} % empty "figure" environment
\end{figure}vvv
\end{document}
listoftables
? andlistoffigures
? for me, a picture is worth 1,000 words. So I do not see how a figure is not part of document content. Your school have some really strange policy ;)