# How can I use LaTeX to build my website?

Can I use LaTeX to specify cascading style sheet? Can someone enlighten me something about using LaTeX with my website?

Basically to setup layout like how I do for documents, setting up fonts, spacing etc

-
I am really not sure what you want to know here. LaTeX is not a system for generating websites, which in general work very differently to typeset documents. Please extend the context of the question so that we can give a clear answer. –  Joseph Wright Jun 5 '11 at 9:11
You definitely can do that. I use only latex for everything. This way, I have pdf files and also have the web pages. Try that with html only based web site. I used latex2html before, but now I am using tex4ht. With tex4ht you can inject any additional CSS configuration if you want, or just keep things simple and just do tex4ht file.tex and you get your web page with links and all. Think how nice it is to have all your web pages compiled to one book if needed. You can do that with Latex+tex4ht, but not if you just start from HTML. Also the pdf generated will have links inside it. –  Nasser May 25 '13 at 0:28

You could also look at Pandoc, which can be used as follows:

pandoc -r latex -w html -o outfile.html infile.tex


This will generate the HTML for you. You will have to specify your own stylesheets, however. Also, Pandoc only supports a subset of LaTeX.

-
+1 Forgot about Pandoc (great tool!) –  chl Jun 5 '11 at 17:59

I agree with what was already said: you won't get the flexibility of manually playing with css, jquery/ajax, etc. However, as far as structured/markup languages are concerned, you may find the following two projects interesting:

• AsciiDoc: I used it after having tried reST (though now I'm more and more versed into Markdown); it has html5/tex backend, and can be used for website management.
• plasTeX: I used it for creating a tutorial with html output; it is driven by Python and has support for a templates and themes.

However, note that in general stylesheet as well as layout are specified outside of the core document.

-

LaTeX2HTML is a powerful TeX compiler to directly render a TeX document into HTML.

However, installation of LaTeX2HTML involves several intricate steps, but not impossible. Upon compilation, all necessary pages with the corresponding CSS is also created. Note, that the look of your document on the browser is only as good as you have developed it on TeX.

LaTeX2HTML is by far the best way to put your heavily loaded scientific and mathematical content on the web.

-

This is not a particularly good idea. While there are tools to convert LaTeX into HTML/CSS, they give a result that is nowhere near as flexible as you could get with HTML directly or other meta-languages.

-

This is probably not exactly what you need, but I think it might make an interesting addition to the thread nonetheless. A few weeks ago, I stumbled across pdf2htmlEX, which can convert, as the name implies, pdf files to HTML, while maintaining the typography and layout pretty much intact.

I've tried it with some non-trivial LaTeX-generated pdfs of mine, and the results are truly impressive (they have very nice demos in their project page, too). On the other hand, the HTML markup it produces is heavy and not very editing-friendly. The point is that if you have some part of a site that you'd like to layout/typset with TeX, it is now possible to do so.

-

If you like to use LaTeX equations in your web, you can use MathJax which is commonly used in Wikipedia, arxiv etc. (http://www.mathjax.org/) You can also use Markdown to format your HTML files quickly if you'd like to create on-line documents. You can also find a collection of tools /web templates etc. for creating online articles here:(http://laplace.phas.ubc.ca/People/arman/sg/)

-