# syntax error when using tex4ht on Latex file that uses the standalone package [closed]

When I try to use htlatex to convert a latex file to html, where the latex file uses the standalone package, a syntax error is thrown from the file keyval.tex.

The Latex file works fine with pdflatex and with latex. So the issue seems to be a tex4ht only or some incompatibility between tex4ht and the standalone package.

I send an email on this to the tex4ht mailing list, but there was no resolution.

I am hoping someone here can help. I tried to find what is the problem myself, but my Latex skills are not good enough to debug this and I have no idea why this happens.

It is a very simple set up. Just one small latex file. That is all. htlatex reports an error in

   /usr/share/texlive/texmf-dist/tex/generic/xkeyval/keyval.tex


at line 227 (end of file) that there is an extra \else

Here is the file, and the command and the error message.

\documentclass{book}%
\usepackage{standalone}% this causes an error with htlatex
\begin{document}
hello
\end{document}


This the command used

htlatex main.tex

This is pdfTeX, Version 3.1415926-2.4-1.40.13 (TeX Live 2012/Debian)
restricted \write18 enabled.
entering extended mode
LaTeX2e <2011/06/27>
Babel <v3.8m> and hyphenation patterns for english, dumylang, nohyphenation, lo
(./main.tex (/usr/share/texlive/texmf-dist/tex/latex/base/book.cls
Document Class: book 2007/10/19 v1.4h Standard LaTeX document class
(/usr/share/texlive/texmf-dist/tex/latex/base/bk10.clo))
(/usr/share/texmf/tex/generic/tex4ht/tex4ht.sty)
(/usr/share/texmf/tex/generic/tex4ht/usepackage.4ht)
(/usr/share/texlive/texmf-dist/tex/latex/standalone/standalone.sty
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifluatex.sty)
(/usr/share/texlive/texmf-dist/tex/generic/oberdiek/ifpdf.sty)
(/usr/share/texlive/texmf-dist/tex/generic/ifxetex/ifxetex.sty)
(/usr/share/texlive/texmf-dist/tex/latex/xkeyval/xkeyval.sty
(/usr/share/texlive/texmf-dist/tex/generic/xkeyval/xkeyval.tex
(/usr/share/texlive/texmf-dist/tex/generic/xkeyval/keyval.tex)))
! Extra \else.
l.227     \else

?


When commenting out the standalone package, the error goes away.

specs:

4ht.c (2009-01-31-07:34 kpathsea)
>latex -v
pdfTeX 3.1415926-2.4-1.40.13 (TeX Live 2012/Debian)


There is no other way to convert this to html. I tried Latex2html and it does not support this package.

..
Warning: No implementation found for package: standalone.
*** preamble done ***


I tried latexml and it also does not support this. I tried plastex and it also does not support this.

>plastex main.tex
plasTeX version 0.9.1
( /usr/lib/pymodules/python2.7/plasTeX/Packages/book.pyc )
( /usr/share/texlive/texmf-dist/tex/latex/standalone/standalone.sty
WARNING: unrecognized command/environment: ifstandalone

-

## closed as too localized by Martin Scharrer♦Jan 28 '13 at 21:51

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. If this question can be reworded to fit the rules in the help center, please edit the question.

what would you want standalone to do in html output? Can't you simply not use the package in that case? –  David Carlisle Jan 28 '13 at 16:59
@DavidCarlisle, I need this package, since I am building a tree that has latex files and I'd like to be able build each as separate, but also be able to build it all as one document. Please see this tex.stackexchange.com/questions/94822/… The idea is that I can make an HTML tree from the same latex files using htlatex, and also be able to make one PDF file from the whole tree using pdflatex. –  Nasser Jan 28 '13 at 17:01
I figured out where the issue comes from. Some \if..tex macros don't get properly defined and therefore TeX can't match the \else and \fi to it. It turned out that this was caused because htlatex defines \IfFileExists with a different internal behaviour which brakes its use in standalone. If fixed this now in the repository. The fix will be part of the next release. Note that I never intended and tested standalone for these "special" TeX compilers, only for the normal ones (pdflatex, latex, lualatex and xelatex) –  Martin Scharrer Jan 28 '13 at 21:42
@MartinScharrer:I seem to be encountering the exact same problem with standalone 2012/09/15 v1.1b. I am using TeXLive2014 (updated as of today). –  Peter Grill Oct 1 '14 at 6:16
@MartinScharrer fyi, This issue is still in TL 2015. thanks. –  Nasser Jun 21 at 11:30