[Brainstorming] LaTeX Renderer - Styling

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

[Brainstorming] LaTeX Renderer - Styling

vmassol
Administrator
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).

If you have some comments or ideas, please let me know.

Inventing a CSS-like mechanism would just be too hard to implement IMO.

Thanks
-Vincent

PS: If you want to see table options in LaTeX, see https://en.wikibooks.org/wiki/LaTeX/Tables

Reply | Threaded
Open this post in threaded view
|

Re: [Brainstorming] LaTeX Renderer - Styling

Paul Libbrecht-2
Hello Vincent,

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.

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.

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).
>
> If you have some comments or ideas, please let me know.
>
> Inventing a CSS-like mechanism would just be too hard to implement IMO.
>
> Thanks
> -Vincent
>
> PS: If you want to see table options in LaTeX, see https://en.wikibooks.org/wiki/LaTeX/Tables

signature.asc (523 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [Brainstorming] LaTeX Renderer - Styling

vmassol
Administrator
Hi Paul,

> On 14 Feb 2018, at 23:14, Paul Libbrecht <[hidden email]> wrote:
>
> Hello Vincent,
>
> 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?

> 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.

Thanks a lot!
-Vincent

>
> 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).
>>
>> If you have some comments or ideas, please let me know.
>>
>> Inventing a CSS-like mechanism would just be too hard to implement IMO.
>>
>> Thanks
>> -Vincent
>>
>> PS: If you want to see table options in LaTeX, see https://en.wikibooks.org/wiki/LaTeX/Tables

Reply | Threaded
Open this post in threaded view
|

Re: [Brainstorming] LaTeX Renderer - Styling

Paul Libbrecht-2
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).
>>>
>>> If you have some comments or ideas, please let me know.
>>>
>>> Inventing a CSS-like mechanism would just be too hard to implement
>>> IMO.
>>>
>>> Thanks
>>> -Vincent
>>>
>>> PS: If you want to see table options in LaTeX, see
>>> https://en.wikibooks.org/wiki/LaTeX/Tables
Reply | Threaded
Open this post in threaded view
|

Re: [Brainstorming] LaTeX Renderer - Styling

vmassol
Administrator
In reply to this post by vmassol
haha seems there’s some option to use “.sty” files for styling in LaTeX! :)
* https://tug.org/pracjourn/2005-3/asknelly/nelly-sty-&-cls.pdf
* https://tex.stackexchange.com/questions/91167/why-use-sty-files

What I understand so far, is that we would redefine commands in the .sty file and then use those commands in the generated tex output.

For example instead of directly outputing "\begin{tabular}{l|ll}” for a table, we would create own own and output "\begin{xwiki}{l|ll}”, with the definition of it in a .sty file, with some default styles applied. This would then allow modifying just the .sty file to control the output.

Seems great and exactly what I need. Still digging.

Also this page explains nicely the differences between LaTeX and PDF:
https://groups.google.com/d/msg/comp.text.tex/oTaAExhAZE4/4zbqNDYUwg8J

Thanks
-Vincent

> On 15 Feb 2018, at 07:25, Vincent Massol <[hidden email]> wrote:
>
> Hi Paul,
>
>> On 14 Feb 2018, at 23:14, Paul Libbrecht <[hidden email]> wrote:
>>
>> Hello Vincent,
>>
>> 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?
>
>> 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.
>
> Thanks a lot!
> -Vincent
>
>>
>> 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).
>>>
>>> If you have some comments or ideas, please let me know.
>>>
>>> Inventing a CSS-like mechanism would just be too hard to implement IMO.
>>>
>>> Thanks
>>> -Vincent
>>>
>>> PS: If you want to see table options in LaTeX, see https://en.wikibooks.org/wiki/LaTeX/Tables
>

Reply | Threaded
Open this post in threaded view
|

Re: [Brainstorming] LaTeX Renderer - Styling

vmassol
Administrator
In reply to this post by Paul Libbrecht-2
Hi Paul,

> On 15 Feb 2018, at 08:24, Paul Libbrecht <[hidden email]> wrote:
>
> 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.

Very useful thanks. I think this is the same as what I was mentioning using .sty files. You would put the defiinition of new environments/macros/etc inside this .sty file and then have the XWiki renderer output those new environments/macros, allowing the user to tune the .sty file he/she wants to use to get the right styling.

>
>>> 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

This seems like the TEI XML format is meant to be used as the input and then transformed either to XHTML (web site) or to LaTeX/PDF for publishing. Googling quickly I couldn’t find a XHTML -> TEI XSL stylehseet.

> or DocBookLaTeX
> https://sourceforge.net/projects/dblatex/

This is interesting but we would need to have a proper DocBook renderer. We have the start of one though but it would need to be improved a lot.

I’m a bit way of going through too many intermediate tool chain as every time you get some mismatch impedance that gets in the way. So I have the feeling that for the best result/control the solution would be to directly output LaTeX using custom XWiki environments/macros.

If you don’t need this level of control, XWiki users should simply use the PDF export.

Now, I’ve just discovered TeX (typesetting engine) and LaTeX (“standard" macros on top of TeX) yesterday so this is still new to me and I’m likely to miss a lot of things at this stage :)

Opinions are more than welcome!

Thanks again for your help Paul, that’s great
-Vincent

>
> 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).
>>>>
>>>> If you have some comments or ideas, please let me know.
>>>>
>>>> Inventing a CSS-like mechanism would just be too hard to implement IMO.
>>>>
>>>> Thanks
>>>> -Vincent
>>>>
>>>> PS: If you want to see table options in LaTeX, see https://en.wikibooks.org/wiki/LaTeX/Tables

Reply | Threaded
Open this post in threaded view
|

Re: [Brainstorming] LaTeX Renderer - Styling

Guillaume Delhumeau
I cannot help more than Paul, but I'm glad you are prototyping a PDF export
using LaTeX. I've been a LaTeX user for years and I have always loved the
results. But it's a very different world than the other tools.

2018-02-15 8:46 GMT+01:00 Vincent Massol <[hidden email]>:

> Hi Paul,
>
> > On 15 Feb 2018, at 08:24, Paul Libbrecht <[hidden email]> wrote:
> >
> > 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.
>
> Very useful thanks. I think this is the same as what I was mentioning
> using .sty files. You would put the defiinition of new
> environments/macros/etc inside this .sty file and then have the XWiki
> renderer output those new environments/macros, allowing the user to tune
> the .sty file he/she wants to use to get the right styling.
>
> >
> >>> 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
>
> This seems like the TEI XML format is meant to be used as the input and
> then transformed either to XHTML (web site) or to LaTeX/PDF for publishing.
> Googling quickly I couldn’t find a XHTML -> TEI XSL stylehseet.
>
> > or DocBookLaTeX
> >       https://sourceforge.net/projects/dblatex/
>
> This is interesting but we would need to have a proper DocBook renderer.
> We have the start of one though but it would need to be improved a lot.
>
> I’m a bit way of going through too many intermediate tool chain as every
> time you get some mismatch impedance that gets in the way. So I have the
> feeling that for the best result/control the solution would be to directly
> output LaTeX using custom XWiki environments/macros.
>
> If you don’t need this level of control, XWiki users should simply use the
> PDF export.
>
> Now, I’ve just discovered TeX (typesetting engine) and LaTeX (“standard"
> macros on top of TeX) yesterday so this is still new to me and I’m likely
> to miss a lot of things at this stage :)
>
> Opinions are more than welcome!
>
> Thanks again for your help Paul, that’s great
> -Vincent
>
> >
> > 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).
> >>>>
> >>>> If you have some comments or ideas, please let me know.
> >>>>
> >>>> Inventing a CSS-like mechanism would just be too hard to implement
> IMO.
> >>>>
> >>>> Thanks
> >>>> -Vincent
> >>>>
> >>>> PS: If you want to see table options in LaTeX, see
> https://en.wikibooks.org/wiki/LaTeX/Tables
>
>


--
Guillaume Delhumeau ([hidden email])
Research & Development Engineer at XWiki SAS
Committer on the XWiki.org project
Reply | Threaded
Open this post in threaded view
|

Re: [Brainstorming] LaTeX Renderer - Styling

vmassol
Administrator
In reply to this post by vmassol
Ok I’ve now realized that the 2 approaches mentioned so far are not going to work:
* The first one mixes content and styling and is complex for the user to use
* The second one is actually very limited and doesn’t allow full control of the LaTeX markup used

So I’ve been thinking about a new approach that would both separate the content from the styling and at the same time allow full control of the produced LaTeX for perfect typesetting.

The idea is:
* Don’t provide a Listener for LaTeX in XWiki and instead only provide a BlockRenderer (i.e. no streaming generation of content). That’s the limitation.
* For each XWiki Block object, provide a default LaTeX template that is called to generate the LaTeX content.
* Allow Velocity in the LaTeX template and provide velocity tools + bind the passed Block to the $block variable.
* For example for TableBlock:

---- start here ----
## Compute the number of columns
#set ($firstRowBlock = $blocks.getChildren().get(0))
#set ($columnSize = $firstRowBlock.getChildren().size())
#set ($tableSpec = "${stringtool.repeat("l|", $columnSize - 1)}l"
\begin{tabular}{${tableSpec}}
## For all rows
#foreach ($rowBlock in $blocks.getChildren())
  ## for all cells
  #foreach ($cellBlock in $rowBlock.getChildren())
    #processTemplates($cellBlock.getChildren()) &
    ## TODO: if last cell then output ""\\"
  #end
  ## TODO: if last row then don't output \hline
  \hline
#end
\end{tabular}
---- end here -----

* Users will be able to override the default templates for each Block
* If the user wants to use a special template for a specific Block, define it using a “tex-template” parameter. For example:

(% tex-template=‘customTemplateForThisTable’ %)
|=A|=B
|a|b

* A template can set any variable in the VelocityContext so that templates downstream can access them.

There are still details to iron out ofc.

WDYT?

Thanks
-Vincent

> On 14 Feb 2018, at 21:01, Vincent Massol <[hidden email]> 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).
>
> If you have some comments or ideas, please let me know.
>
> Inventing a CSS-like mechanism would just be too hard to implement IMO.
>
> Thanks
> -Vincent
>
> PS: If you want to see table options in LaTeX, see https://en.wikibooks.org/wiki/LaTeX/Tables
>

Reply | Threaded
Open this post in threaded view
|

Re: [Brainstorming] LaTeX Renderer - Styling

Paul Libbrecht-2
You certainly need hooks for a preamble where all macros, variables, and environments are defined.

Bringing Velocity to write LaTeX is probably enjoyable since you can be very free to input text source, I am wondering if there are no escaping issues. Maybe with the $ sign which is used for math formulæ? (and $$ for “centered math”). All #-signs should be gone by the time LaTeX runs… this is still used in rare times (for special layouts). At least these escaping mechanisms should be explained close to the TeX-related documentation.

paul

On 15 Feb 2018, at 20:47, Vincent Massol wrote:

> Ok I’ve now realized that the 2 approaches mentioned so far are not going to work:
> * The first one mixes content and styling and is complex for the user to use
> * The second one is actually very limited and doesn’t allow full control of the LaTeX markup used
>
> So I’ve been thinking about a new approach that would both separate the content from the styling and at the same time allow full control of the produced LaTeX for perfect typesetting.
>
> The idea is:
> * Don’t provide a Listener for LaTeX in XWiki and instead only provide a BlockRenderer (i.e. no streaming generation of content). That’s the limitation.
> * For each XWiki Block object, provide a default LaTeX template that is called to generate the LaTeX content.
> * Allow Velocity in the LaTeX template and provide velocity tools + bind the passed Block to the $block variable.
> * For example for TableBlock:
>
> ---- start here ----
> ## Compute the number of columns
> #set ($firstRowBlock = $blocks.getChildren().get(0))
> #set ($columnSize = $firstRowBlock.getChildren().size())
> #set ($tableSpec = "${stringtool.repeat("l|", $columnSize - 1)}l"
> \begin{tabular}{${tableSpec}}
> ## For all rows
> #foreach ($rowBlock in $blocks.getChildren())
>   ## for all cells
>   #foreach ($cellBlock in $rowBlock.getChildren())
>     #processTemplates($cellBlock.getChildren()) &
>     ## TODO: if last cell then output ""\\"
>   #end
>   ## TODO: if last row then don't output \hline
>   \hline
> #end
> \end{tabular}
> ---- end here -----
>
> * Users will be able to override the default templates for each Block
> * If the user wants to use a special template for a specific Block, define it using a “tex-template” parameter. For example:
>
> (% tex-template=‘customTemplateForThisTable’ %)
> |=A|=B
> |a|b
>
> * A template can set any variable in the VelocityContext so that templates downstream can access them.
>
> There are still details to iron out ofc.
>
> WDYT?
>
> Thanks
> -Vincent
>
>> On 14 Feb 2018, at 21:01, Vincent Massol <[hidden email]> 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).
>>
>> If you have some comments or ideas, please let me know.
>>
>> Inventing a CSS-like mechanism would just be too hard to implement IMO.
>>
>> Thanks
>> -Vincent
>>
>> PS: If you want to see table options in LaTeX, see https://en.wikibooks.org/wiki/LaTeX/Tables
>>

signature.asc (523 bytes) Download Attachment