tlienart / FranklinTemplates.jl

Simple website templates for Franklin.jl
https://tlienart.github.io/FranklinTemplates.jl/
MIT License
76 stars 24 forks source link

a slightly better \col #132

Closed ChasingZenith closed 2 years ago

ChasingZenith commented 2 years ago

Originally \col{GD update $x_{t+1} = x_t - \alpha \nabla f(x_t)$ look like this

image katex rendering is blocked.

what I did

I turn \newcommand{\col}[2]{~~~<span style="color:#1">#2</span>~~~} into \newcommand{\col}[2]{~~~<span style="color:#1">~~~#2~~~</span>~~~}

Now

image This is much more useful and friendly to LaTeX users.

I am not quite sure whether I am doing it right since I don't fully understand the difference between #1 and !#1.

ChasingZenith commented 2 years ago

I even find that if I do am more aggressive than the pull request and do

\newcommand{\col}[2]{~~~<span style="color:~~~#1~~~">~~~#2~~~</span>~~~} and \newcommand{\arxivcolor}{#b31b1b}

I can use \color{\arxivcolor}{something}

tlienart commented 2 years ago

Cool yes that's better, thanks!

For your information, the ! is just a whitespace controller and here in HTML has no effect (both would have lead to an identical result). There's an explanation here: https://franklinjl.org/syntax/divs-commands/#whitespaces 🙂

ChasingZenith commented 2 years ago

Thank you. I do some more tests. I think that the current version is still not that good. It seems that one relevant case is A\color{red}{B}. The current version will give A Bwith an unwanted space in the middle. It seems that in this whitespace-sensitive case, #2 is should be turned into !#2

I would like to change it into

\newcommand{\col}[2]{~~~<span style="color:~~~#1~~~">~~~!#2~~~</span>~~~}

I will make a new pull request now to fix this problem and use the aggressive version mentioned above.

tlienart commented 2 years ago

HTML is insensitive to whitespace so this makes no difference :-)

you can test for yourself have a HTML page with <p> A B </p> or <p>A B</p> it will give exactly the same thing

https://www.w3schools.com/code/tryit.asp?filename=GUITAADMCV2X

PS: ah ok you mean when mixing markdown and HTML, then yes.