Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'm working on a document that has been published only as a PDF file until now. To utilize some of PDF's features, it uses the packages pdfpages and pdftex and commands like includepdf{}.

But soon that document shall be available in both PDF an HTML format. I figured out I can use htlatex / tex4ht to convert it, but it seems that this tool is not compatible with the special pdf features and packages. Once I remove them, it works.

Removing the pdf stuff, converting to html and then putting it in again manually is not an option (This is an evolving document that has been worked on for over 10 years by a large number of contributors and is still edited by several people, so we rely on an automated build process using make).

Is there any way similar to conditional compilation to ignore some \usepackage directives on some of the make runs, or do you have any other hint on how to do this?

share|improve this question
    
I'd also like to tag this question with htlatex or tex4ht but don't have enough reputation. –  Lena Schimmel Aug 10 '10 at 21:42
    
Since there can be a maximum of 5 tags- I replaced the web tag with pdf and html as those are the output formats you are targeting. –  Sharpie Aug 10 '10 at 21:45
    
One question- what kind of document are we talking about? A book? A report? Heavy on math? Heavy on figures? Does it document the source code of a software project? Some specifics may help the community suggest appropriate tools. –  Sharpie Aug 10 '10 at 21:48
    
@Sharpie: You're right, I should have been more specific. The document is a 50 page introduction into studying at our university, and contains a lot of prose text, many figures, some tables and bullet point lists, but no formulars at all. –  Lena Schimmel Aug 11 '10 at 12:43
    
Based on the accepted answer, I think you should consider changing the title of this question. –  Will Robertson Sep 8 '10 at 3:41
add comment

4 Answers

up vote 11 down vote accepted

You can use package ifpdf and enclose pdf-specific stuff in \ifpdf ... \fi

\usepackage{ifpdf}

\ifpdf
%pdf specific stuff
\fi

Alternatively, you can make the pdf-file and convert to html using a tool like pdftohtml.

share|improve this answer
    
Thanks, ifpdf did exactly what I was looking for and works great for our document. –  Lena Schimmel Aug 11 '10 at 12:44
add comment

tex2page usually produces stunning html pages; see for example its website and http://www.math.umbc.edu/~rouben/beamer/.

share|improve this answer
2  
Interesting - I'd never heard of tex2page. It appears that it cannot handle macros, is that right? –  Loop Space Aug 11 '10 at 11:46
    
Unfortunately I have no idea. I know about this tool from many years ago from a friend and it just stuck to my head. But since it is written in scheme I'd expect it to be very flexible. –  Leo Liu Aug 11 '10 at 11:56
    
Didn't know tex2page neither. Because the answer by Martin Heller worked for me, I did not try tex2page, but I added it to the list of Tex-HTML-converters in the German Wikipedia, where it was missing before. –  Lena Schimmel Aug 11 '10 at 12:52
add comment

Since the text is mainly prose + floats, you can consider writing your source in markdown and convert it to html and latex/context using pandoc, which does a fairly good job of creating predictable output.

share|improve this answer
add comment

Here's my main suggestion: use version control and have a branch for XHTML+MathML[1] and a branch for PDF. Let the version control system keep track of the changes and leave you to concentrate on making sure that both look as good as they can for the desired output.

Other possibilities spring to mind: as it's quite easy to go from XHTML to PDF (File->Print->Print_to_File!), concentrate on the XHTML version and leave the PDF to the reader.

And, slightly tongue-in-cheek, I'd consider adding a "don't do that" tag to this question (if it wasn't already at the maximum). The requirements for a document to be viewed on the screen are sufficiently different to that to be printed out that it's worth considering having two almost completely separate documents. (NB I know that PDFs are often viewed on the screen, but I'm thinking more about the interaction possible between reader and document that is possible with an XHTML document and is difficult with PDF.)

[1] I know you wrote HTML, but you meant XHTML+MathML.

share|improve this answer
    
Hmm... thanks for your answer, but none of the alternatives fitted my situation. The focus is: Some initial effort to set the two-way-conversion up, minimum contious effort (e.g. not maintaining two branches or two separate documents). On the other hand, I understand your arguments and they might in fact be useful for someone else in another situation. –  Lena Schimmel Aug 11 '10 at 12:59
    
@Brian Schimmel: Not to belabour the point, but the reason for using a version control system is so make it easy to keep two different versions of the same document. But if \ifpdf works for this situation then that's certainly the easier route. –  Loop Space Aug 11 '10 at 14:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.