When I put \localtableofcontents (which comes from one of these pacakges tocloft or etoc), inside the \if....\else..\fi then I get an error.
The reason I wanted to put it inside an if is because I want the file to compile both with tex4ht and pdflatex, and I do not want this when running in tex4ht mode.
\documentclass[10pt,notitlepage]{report}
\ifdefined\HCode
\else
\usepackage{tocloft}
\usepackage{etoc}
\fi
\begin{document}
\chapter{ my chapter }
\ifdefined\HCode
\else
\localtableofcontents %this gives the error
\fi
\end{document}
now pdflatex foo.tex gives
>pdflatex foo.tex
This is pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2014)
....
LaTeX2e <2014/05/01>
Babel <3.9l> and hyphenation patterns for 79 languages loaded.
(/usr/local/texlive/2014/texmf-dist/tex/latex/base/report.cls
Document Class: report 2014/09/29 v1.4h Standard LaTeX document class
(/usr/local/texlive/2014/texmf-dist/tex/latex/base/size10.clo))
(/usr/local/texlive/2014/texmf-dist/tex/latex/tocloft/tocloft.sty)
(/usr/local/texlive/2014/texmf-dist/tex/latex/etoc/etoc.sty
(/usr/local/texlive/2014/texmf-dist/tex/latex/tools/multicol.sty)) (./foo.aux)
Chapter 1.
! Extra \fi.
<recently read> \fi
l.15 \fi
How would I prevent \localtableofcontents from being used in tex4ht mode if I can't exclude it using \ifdefined\HCode logic?
>pdflatex foo.tex
This is pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2014) (preloaded format=pdflatex)
File list:
*File List*
report.cls 2014/09/29 v1.4h Standard LaTeX document class
size10.clo 2014/09/29 v1.4h Standard LaTeX file (size option)
tocloft.sty 2013/05/02 v2.3f parameterised ToC, etc., typesetting
etoc.sty 2014/04/22 v1.07l Completely customisable TOCs (jfB)
multicol.sty 2014/10/28 v1.8i multicolumn formatting (FMi)

\localtableofcontentsindeed comes frometoc, nottocloft. – Jan 05 '15 at 21:15