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.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've done ab bit of web-searching and found nothing. Are there any attempts on using CSS for LaTeX formatting? For example:

body { font-family: Helvetica,Arial,sans-serif; }
section { font-size: 16pt; }
/* or: */
h1 { font-size: 16pt; }

I know that this approach is limited compared to the classic approach, but it could be a nice attempt. So are there any published papers or code pieces?

I'd like to write in the preamble of my LaTeX document: \usestylefile{foo.css} and have the text rendered as written in the given style file (and its linked style files).

share|improve this question
Could you be a bit more specific about the background of your approach? Most of these things can be set up, but none of them so simple as in CSS and in some cases it is not even a good idea to do it the css way. – Matthias Pospiech Nov 21 '11 at 13:56
Using CSS directly is not likely to be possible. You might, however, be interested in things such as the work on a 'LaTeX3 database' to define relationships between document items. – Joseph Wright Nov 21 '11 at 14:05
Does it have to be css or are you happy to use a css-like configuration. For example, if you define a consistent key-value driven configuration system for your style (for example, as done in ConTeXt), then you can set-up the configuration and let a script (possibly a lua script) read the "css" and convert it into the appropriate tex code. For example head .section {text-color: blue; text-style: bold} could be translated to \setuphead[section][textcolor=blue, textstyle=bold], so you will get the corresponding style in the output. – Aditya Nov 21 '11 at 19:48
OK, let me clarify. Does it has to be CSS tuned to HTML or it can be any valid CSS. The snippet that I posted is actually valid CSS (if you replace text-color by color). So, IMO, all you need to do is come up with a consistent, key-value driven document mode. Then translating CSS style to TeX style is easy. – Aditya Nov 21 '11 at 22:14
Here's an example. This uses CSS to style an HTML page like the default LaTeX style. Enjoy! – user19535 Oct 4 '12 at 18:29
up vote 6 down vote accepted

I'll take the comments as "there is no css-TeX yet".

share|improve this answer
I think/hope the key word here is "yet". – Bruno Le Floch Feb 4 '12 at 23:19

Not quite gentlemen. With the combination of markdown, KaTeX, and this (look at the witex example). I think we're super close to realizing a CSS LaTeX.

Here's an example:

  1. I start by writing my text in markdown (I usually find it simpler than LaTeX, plus, LaTeXian, my favorite app, is no longer supported on the mac).
  2. The markdown is then generated into HTML using markdown-styles, something available via npm.
  3. I add KaTeX/MathJax for equation rendering.

I know, I know, a lot of stuff like numbering equations, ToC etc aren't there yet. But even as a proof of concept for tiny college assignments and other things, this is pretty awesome. As an added bonus, you can modify the CSS to customize stuff pretty easily.

enter image description here

share|improve this answer
Hi and welcome, can you extend your answer a little bit? Right now it is just Look at the link, but the link could be gone tomorrow. With the content here (properly cited), the problem disappears ;-) – Johannes_B Sep 8 '15 at 20:06
A couple of questions: which example is that? I can't find the word "witex" anywhere in that page. Second, this doesn't really use LaTeX at all though, does it? MathJaX/KaTeX is not LaTeX, they are math rendering engines that can use a subset of LaTeX syntax, but are otherwise unrelated, LaTeX is much more than math. The question doesn't really have anything to with HTML pages I think, while your example is only about generating HTML (from Markdown). – Torbjørn T. Sep 9 '15 at 7:42
I'm only talking about the most common use cases(college assignments, term papers etc). I've said it isn't a replacement. Also, witex is in the screenshot, not in the text. raw.githubusercontent.com/mixu/markdown-styles/master/… – Robin Thuran Malhotra Sep 9 '15 at 8:10
Ah, I only searched the page, sorry. I won't argue that it is a useful tool, but it still doesn't really answer the question as I see it, as it isn't something you can use in a LaTeX document. If you read the comments you'll see that topskip wants to be able to say \documentclass{article}\usestylefile{file.css}\begin{document}\section{Foo}Text‌​\end{document}, where file.css defines the styling of the \section. While interesting, I don't think this is what was asked for. (By the way, use @username to make sure other commenters are notified of your replies.) – Torbjørn T. Sep 10 '15 at 8:59

Your Answer


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.