latex-environment icon indicating copy to clipboard operation
latex-environment copied to clipboard

some glitch when working with latex package siunitx

Open Serenade600 opened this issue 2 years ago • 2 comments

When using commands \si{} in siunitx, content \si{\meter\cubed}, [\meter\cubed]{.si}, \si{m^3}, [m^3]{.si} produed image.

The last one is different from the first three. It seems somewhere did not convert the ^3 correctly.

Serenade600 avatar Jan 15 '23 12:01 Serenade600

The LaTeX produced for the above content is the following

\si{\meter\cubed}, \si{\meter\cubed}, \si{m^3}, \si{m\^{}3}

You see in the last case that ^ is interpreted from markdown as Literal ^ and not special LaTeX character that you expect.

> quarto pandoc -t native
[m^3]{.si}
^Z
[ Para [ Span ( "" , [ "si" ] , [] ) [ Str "m^3" ] ] ]

> quarto pandoc -t latex
m^3
^Z
m\^{}3

For forcing ^ to be preserved in LaTeX from markdown, it would require raw code attributes. i.e [m^{=latex}3]{.si} but we would loose it in HTML conversion.

And if we consider the content of [content]{.cmd} to be raw LaTeX for this extension, we loose the benefit of being able to have markdown syntax in the text. Not sure it is good. We could support an option in the span syntax to consider the content as raw maybe... 🤔

So this is a special case with a special package where some specific LaTeX character is needed to be preserve.

@dragonstyle what are you thoughts on this ?

cderv avatar Jan 16 '23 13:01 cderv

I think the long term solution to this conundrum is likely to actually implement an extension that provides nice unit support across formats (like siunitx does for LaTeX). The latex environment package works best when the contents of the environment could be reasonably rendered in other formats as text and I think in this case that isn't likely to be true.

For now, I suppose the use of raw LaTeX might be the preferred solution until someone implements a nice port of siunitx as a Quarto extension...

dragonstyle avatar Jan 16 '23 13:01 dragonstyle