# Re: [xwiki-devs] [Brainstorming] LaTeX Renderer - Styling

Hello Vincent,

On 15 Feb 2018, at 7:25, Vincent Massol wrote:

having some experience with TeX I would implement CSS with macro-definitions… Every element start would be a call to a macro that would check for rules that would apply to its element, including passing parameters of their ancestry.



Could you give an example of what you mean by macro-definitions? Is this something that exist in TeX?

Definitely. The complete TeX is based on macros.
Basic macros are created using the \def macro.
See e.g. http://www.tex.ac.uk/FAQ-whatmacros.html


Closer to the HTML world, there are the LaTeX environments. They are nestable and extensible: see http://www.tex.ac.uk/FAQ-whatenv.html

This would be the way to create styles I think.

Paths are not transported, as far as I know (would they be called maybe environment stack?). That would need to be carried as an extra parameter produced by the renderer. I would also think that recognising complex rules with such as classes would need an amount of coding before the LaTeX is processed.


However, I guess that your solution seems probably more ad hoc and more practical.


Is there any reason that you don’t use the XSL-FO renderer that use LaTeX? I thought there were several of them.


Do you have a pointer? As I said in my original mail I tried to search for an XHTML to LaTeX converter/XSLT but couldn’t. If you know of one, I’ll gladly have a look.

The world is thinner than I thought.
The closest I could find are the TEI renderers:
http://www.tei-c.org/release/doc/tei-xsl/
https://www.tug.org/TUGboat/tb27-0/rahtz.pdf
or DocBookLaTeX
https://sourceforge.net/projects/dblatex/

paul



On 14 Feb 2018, at 21:01, Vincent Massol wrote:


Hi devs,


I’m currently working on improving our TeX renderer (which is really a POC ATM), in an effort to see if it could be used to generate nice PDF exports (you generate LaTeX and then you convert to PDF).


The main issue is that LaTeX doesn’t have any technology for applying style to it (like CSS has for HTML). In addition I wasn’t able to find any good HTML+CSS to TeX converter (as we have for PDFs with XSLT+FOP).


So right now my idea is to implement some default behavior in the Tex Renderer (that could be configured globally in xwiki.properties and/or in the Admin UI) and give the ability to override specifically in the content.


For example, imagine that you need to decide how to position table column content (left, centered, right) or whether the rows and/or columns of your table have vertical and horizontal lines (or other configs, autowrap, etc).


The idea is that the Tex Renderer would support some custom tex-specific parameters. For example:


(% tex-table-spec=“c | c | c" tex-table-floating="true" tex-table-caption="caption" %)
|=A|=B
(% tex-table-row-ending="\hline" %)|a|b


(by default the table spec would be left aligned with vertical lines, and rows would be separated by horizontal lines).