public inbox archive for pandoc-discuss@googlegroups.com
 help / color / mirror / Atom feed
* LaTeX algorithm to HTML using SVG images
@ 2019-08-27 19:00 Paul Laffitte
       [not found] ` <ad859f30-bf09-4f90-a9d9-33ed5b14cbc4-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Paul Laffitte @ 2019-08-27 19:00 UTC (permalink / raw)
  To: pandoc-discuss


[-- Attachment #1.1: Type: text/plain, Size: 2291 bytes --]

Hello,

I'm trying to figure out a way to render HTML with quality-lossless (I mean 
not in a .png format for instance) algorithms from LaTeX using extensions. 
In a more wider perspective, I would render markdown containing LaTeX using 
extensions into HTML and eventually render this HTML into PDF.

My goal is to be able to take notes and do my homework in my Scientific 
Computing class. Here are my needs points by points:
- Markdown: Because it's easy and fast to write.
- LaTeX: Because I need to write matrices, algorithms and other 
mathematical stuff.
- HTML: Because I would like to be able to use CSS to stylize my notes, and 
eventually having it in a web format. (This is kind of optional but I 
really would like to have it)
- SVG: Because text is quality-lossless, it's weird if when I zoom the text 
is fine but the maths aren't (maths are the main point of the document)
- PDF: Because having all of this and not being able to get a PDF from it 
is just non-sense.

Currently, I'm able to do all of this but using extensions in LaTeX, 
because yes, algorithms comes from extensions. I use webtex to render the 
LaTeX parts into SVG using this command:
*pandoc 22_08.2.md --from markdown+tex_math_dollars --to=pdf -o **22_08.2**.pdf 
-t html5 --webtex='https://latex.codecogs.com/svg.latex?'*

I tried other engine than webtex but they whether doesn't support 
extensions or SVG rendering.

I'm so close to have this working perfectly well, and it would be so nice. 
Does any one has any idea about how I could do? *Is there any LaTeX 
rendering engine supported by pandoc that is able to both render without 
quality loss and use LaTeX extensions?*

PS: You can find join with this thread an example of a markdown file and 
his html and pdf outputs that I generate. You can also see that on the page 
2 I had to write my pseudo-code with markdown raw code (```).

-- 
You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/ad859f30-bf09-4f90-a9d9-33ed5b14cbc4%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 2832 bytes --]

[-- Attachment #2: 22_08.2.md --]
[-- Type: text/markdown, Size: 2834 bytes --]

$$
\begin{aligned}
	x_{1} + 2x_{2} + x_{3} &= -1 \\
	-3x_{1} + x_{2} + x_{3} &= 0 \\
	x_{1} + 2x_{3} &= 1 \\
\end{aligned}
\implies
\overset{A}{
	\begin{bmatrix}
	1 & 2 & 1 \\
	-3 & 1 & 1 \\
	1 & 0 & 3 \\
	\end{bmatrix}
}
\overset{x}{
	\begin{bmatrix}
	x_{1} \\
	x_{2} \\
	x_{3} \\
	\end{bmatrix}
} =
\overset{b}{
	\begin{bmatrix}
	-1 \\
	0 \\
	1 \\
	\end{bmatrix}
}
$$

Using the formula $Row_{i} := Row_{i} - (\frac{A_{ik}}{A_{kk}}) \cdot Row_{k}$:

---

$A_{ik} = A_{21}$ hence $i = 2$ and $k = 1$

$Row_{2} := Row_{2} - (\frac{A_{21}}{A_{11}}) \cdot Row_{1}$

$= \begin{bmatrix}-3 & 1 & 1\end{bmatrix} - (\frac{-3}{1}) \cdot \begin{bmatrix}1 & 2 & 1\end{bmatrix}$

$= \begin{bmatrix}0 & 7 & 4\end{bmatrix}$

$$
\begin{bmatrix}
	1 & 2 & 1 \\
	0 & 7 & 4 \\
	1 & 0 & 3 \\
\end{bmatrix}
$$

---

$A_{ik} = A_{31}$ hence $i = 3$ and $k = 1$

$Row_{3} := Row_{3} - (\frac{A_{31}}{A_{11}}) \cdot Row_{1}$

$= \begin{bmatrix}1 & 0 & 3\end{bmatrix} - (\frac{1}{1}) \cdot \begin{bmatrix}1 & 2 & 1\end{bmatrix}$

$= \begin{bmatrix}0 & -2 & 2\end{bmatrix}$

$$
\begin{bmatrix}
	1 & 2 & 1 \\
	0 & 7 & 4 \\
	0 & -2 & 2 \\
\end{bmatrix}
$$

---

$A_{ik} = A_{32}$ hence $i = 3$ and $k = 2$

$Row_{3} := Row_{3} - (\frac{A_{32}}{A_{22}}) \cdot Row_{2}$

$= \begin{bmatrix}0 & -2 & 2\end{bmatrix} - (\frac{-2}{7}) \cdot \begin{bmatrix}0 & 7 & 4\end{bmatrix}$

$= \begin{bmatrix}0 & 0 & \frac{22}{7}\end{bmatrix}$

$$
\begin{bmatrix}
	1 & 2 & 1 \\
	0 & 7 & 4 \\
	0 & 0 & \frac{22}{7} \\
\end{bmatrix}
$$

---

$$
\overset{A}{
	\begin{bmatrix}
	1 & 2 & 1 \\
	-3 & 1 & 1 \\
	1 & 0 & 3 \\
	\end{bmatrix}
} =
\overset{L}{
	\begin{bmatrix}
	1 & 0 & 0 \\
	-3 & 1 & 0 \\
	1 & \frac{-2}{7} & 1 \\
	\end{bmatrix}
}
\overset{U}{
	\begin{bmatrix}
	1 & 2 & 1 \\
	0 & 7 & 4\\
	0 & 0 & \frac{22}{7} \\
	\end{bmatrix}
}
$$

$$
Lw = b
\implies
\overset{L}{
	\begin{bmatrix}
	1 & 0 & 0 \\
	-3 & 1 & 0 \\
	1 & \frac{-2}{7} & 1 \\
	\end{bmatrix}
}
\overset{w}{
	\begin{bmatrix}
	w_{1} \\
	w_{2} \\
	w_{3} \\
	\end{bmatrix}
} =
\overset{b}{
	\begin{bmatrix}
	-1 \\
	0 \\
	1 \\
	\end{bmatrix}
}
$$

```
for j = 1 to n:
	j = 1
	w1 = b1 / L11 = -1 / 1 = -1
	for i = j + 1 to n:
		i = 2
		b2 = b2 - L21 * w1 = 0 - (-3) * (-1) = -3
		i = 3
		b3 = b3 - L31 * w1 = 1 - 1 * (-1) = 2
	j = 2
	w2 = b2 / L22 = -3 / 1 = -3
	for i = j + 1 to n:
		i = 3
		b3 = b3 - L32 * w2 = 2 - (-2 / 7) * (-3) = 8 / 7
	j = 3
	w3 = b3 / L33 = (8 / 7) / 1 = 8 / 7
	for i = j + 1 to n:
		i = 4 -> skip
```

$$
Ux = w
\implies
\overset{U}{
	\begin{bmatrix}
	1 & 2 & 1 \\
	0 & 7 & 4 \\
	0 & 0 & \frac{22}{7} \\
	\end{bmatrix}
}
\overset{x}{
	\begin{bmatrix}
	x_{1} \\
	x_{2} \\
	x_{3} \\
	\end{bmatrix}
} =
\overset{w}{
	\begin{bmatrix}
	w_{1} \\
	w_{2} \\
	w_{3} \\
	\end{bmatrix}
} =
\overset{w}{
	\begin{bmatrix}
	-1 \\
	-3 \\
	\frac{8}{7} \\
	\end{bmatrix}
}
$$

***Paul Laffitte*** *6222808130*

[-- Attachment #3: 22_08.2.pdf --]
[-- Type: application/pdf, Size: 196578 bytes --]

[-- Attachment #4: 22_08.2.html --]
[-- Type: text/html, Size: 14350 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: LaTeX algorithm to HTML using SVG images
       [not found] ` <ad859f30-bf09-4f90-a9d9-33ed5b14cbc4-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
@ 2019-08-27 19:29   ` John MacFarlane
  0 siblings, 0 replies; 2+ messages in thread
From: John MacFarlane @ 2019-08-27 19:29 UTC (permalink / raw)
  To: Paul Laffitte, pandoc-discuss


I'm not sure what you mean by latex extensions.
But have you tried using MathJaX?  It can be configured to
generate SVG.

Paul Laffitte <paullaffitte-1ViLX0X+lBJGWvitb5QawA@public.gmane.org> writes:

> Hello,
>
> I'm trying to figure out a way to render HTML with quality-lossless (I mean 
> not in a .png format for instance) algorithms from LaTeX using extensions. 
> In a more wider perspective, I would render markdown containing LaTeX using 
> extensions into HTML and eventually render this HTML into PDF.
>
> My goal is to be able to take notes and do my homework in my Scientific 
> Computing class. Here are my needs points by points:
> - Markdown: Because it's easy and fast to write.
> - LaTeX: Because I need to write matrices, algorithms and other 
> mathematical stuff.
> - HTML: Because I would like to be able to use CSS to stylize my notes, and 
> eventually having it in a web format. (This is kind of optional but I 
> really would like to have it)
> - SVG: Because text is quality-lossless, it's weird if when I zoom the text 
> is fine but the maths aren't (maths are the main point of the document)
> - PDF: Because having all of this and not being able to get a PDF from it 
> is just non-sense.
>
> Currently, I'm able to do all of this but using extensions in LaTeX, 
> because yes, algorithms comes from extensions. I use webtex to render the 
> LaTeX parts into SVG using this command:
> *pandoc 22_08.2.md --from markdown+tex_math_dollars --to=pdf -o **22_08.2**.pdf 
> -t html5 --webtex='https://latex.codecogs.com/svg.latex?'*
>
> I tried other engine than webtex but they whether doesn't support 
> extensions or SVG rendering.
>
> I'm so close to have this working perfectly well, and it would be so nice. 
> Does any one has any idea about how I could do? *Is there any LaTeX 
> rendering engine supported by pandoc that is able to both render without 
> quality loss and use LaTeX extensions?*
>
> PS: You can find join with this thread an example of a markdown file and 
> his html and pdf outputs that I generate. You can also see that on the page 
> 2 I had to write my pseudo-code with markdown raw code (```).
>
> -- 
> You received this message because you are subscribed to the Google Groups "pandoc-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to pandoc-discuss+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To view this discussion on the web visit https://groups.google.com/d/msgid/pandoc-discuss/ad859f30-bf09-4f90-a9d9-33ed5b14cbc4%40googlegroups.com.
> $$
> \begin{aligned}
> 	x_{1} + 2x_{2} + x_{3} &= -1 \\
> 	-3x_{1} + x_{2} + x_{3} &= 0 \\
> 	x_{1} + 2x_{3} &= 1 \\
> \end{aligned}
> \implies
> \overset{A}{
> 	\begin{bmatrix}
> 	1 & 2 & 1 \\
> 	-3 & 1 & 1 \\
> 	1 & 0 & 3 \\
> 	\end{bmatrix}
> }
> \overset{x}{
> 	\begin{bmatrix}
> 	x_{1} \\
> 	x_{2} \\
> 	x_{3} \\
> 	\end{bmatrix}
> } =
> \overset{b}{
> 	\begin{bmatrix}
> 	-1 \\
> 	0 \\
> 	1 \\
> 	\end{bmatrix}
> }
> $$
>
> Using the formula $Row_{i} := Row_{i} - (\frac{A_{ik}}{A_{kk}}) \cdot Row_{k}$:
>
> ---
>
> $A_{ik} = A_{21}$ hence $i = 2$ and $k = 1$
>
> $Row_{2} := Row_{2} - (\frac{A_{21}}{A_{11}}) \cdot Row_{1}$
>
> $= \begin{bmatrix}-3 & 1 & 1\end{bmatrix} - (\frac{-3}{1}) \cdot \begin{bmatrix}1 & 2 & 1\end{bmatrix}$
>
> $= \begin{bmatrix}0 & 7 & 4\end{bmatrix}$
>
> $$
> \begin{bmatrix}
> 	1 & 2 & 1 \\
> 	0 & 7 & 4 \\
> 	1 & 0 & 3 \\
> \end{bmatrix}
> $$
>
> ---
>
> $A_{ik} = A_{31}$ hence $i = 3$ and $k = 1$
>
> $Row_{3} := Row_{3} - (\frac{A_{31}}{A_{11}}) \cdot Row_{1}$
>
> $= \begin{bmatrix}1 & 0 & 3\end{bmatrix} - (\frac{1}{1}) \cdot \begin{bmatrix}1 & 2 & 1\end{bmatrix}$
>
> $= \begin{bmatrix}0 & -2 & 2\end{bmatrix}$
>
> $$
> \begin{bmatrix}
> 	1 & 2 & 1 \\
> 	0 & 7 & 4 \\
> 	0 & -2 & 2 \\
> \end{bmatrix}
> $$
>
> ---
>
> $A_{ik} = A_{32}$ hence $i = 3$ and $k = 2$
>
> $Row_{3} := Row_{3} - (\frac{A_{32}}{A_{22}}) \cdot Row_{2}$
>
> $= \begin{bmatrix}0 & -2 & 2\end{bmatrix} - (\frac{-2}{7}) \cdot \begin{bmatrix}0 & 7 & 4\end{bmatrix}$
>
> $= \begin{bmatrix}0 & 0 & \frac{22}{7}\end{bmatrix}$
>
> $$
> \begin{bmatrix}
> 	1 & 2 & 1 \\
> 	0 & 7 & 4 \\
> 	0 & 0 & \frac{22}{7} \\
> \end{bmatrix}
> $$
>
> ---
>
> $$
> \overset{A}{
> 	\begin{bmatrix}
> 	1 & 2 & 1 \\
> 	-3 & 1 & 1 \\
> 	1 & 0 & 3 \\
> 	\end{bmatrix}
> } =
> \overset{L}{
> 	\begin{bmatrix}
> 	1 & 0 & 0 \\
> 	-3 & 1 & 0 \\
> 	1 & \frac{-2}{7} & 1 \\
> 	\end{bmatrix}
> }
> \overset{U}{
> 	\begin{bmatrix}
> 	1 & 2 & 1 \\
> 	0 & 7 & 4\\
> 	0 & 0 & \frac{22}{7} \\
> 	\end{bmatrix}
> }
> $$
>
> $$
> Lw = b
> \implies
> \overset{L}{
> 	\begin{bmatrix}
> 	1 & 0 & 0 \\
> 	-3 & 1 & 0 \\
> 	1 & \frac{-2}{7} & 1 \\
> 	\end{bmatrix}
> }
> \overset{w}{
> 	\begin{bmatrix}
> 	w_{1} \\
> 	w_{2} \\
> 	w_{3} \\
> 	\end{bmatrix}
> } =
> \overset{b}{
> 	\begin{bmatrix}
> 	-1 \\
> 	0 \\
> 	1 \\
> 	\end{bmatrix}
> }
> $$
>
> ```
> for j = 1 to n:
> 	j = 1
> 	w1 = b1 / L11 = -1 / 1 = -1
> 	for i = j + 1 to n:
> 		i = 2
> 		b2 = b2 - L21 * w1 = 0 - (-3) * (-1) = -3
> 		i = 3
> 		b3 = b3 - L31 * w1 = 1 - 1 * (-1) = 2
> 	j = 2
> 	w2 = b2 / L22 = -3 / 1 = -3
> 	for i = j + 1 to n:
> 		i = 3
> 		b3 = b3 - L32 * w2 = 2 - (-2 / 7) * (-3) = 8 / 7
> 	j = 3
> 	w3 = b3 / L33 = (8 / 7) / 1 = 8 / 7
> 	for i = j + 1 to n:
> 		i = 4 -> skip
> ```
>
> $$
> Ux = w
> \implies
> \overset{U}{
> 	\begin{bmatrix}
> 	1 & 2 & 1 \\
> 	0 & 7 & 4 \\
> 	0 & 0 & \frac{22}{7} \\
> 	\end{bmatrix}
> }
> \overset{x}{
> 	\begin{bmatrix}
> 	x_{1} \\
> 	x_{2} \\
> 	x_{3} \\
> 	\end{bmatrix}
> } =
> \overset{w}{
> 	\begin{bmatrix}
> 	w_{1} \\
> 	w_{2} \\
> 	w_{3} \\
> 	\end{bmatrix}
> } =
> \overset{w}{
> 	\begin{bmatrix}
> 	-1 \\
> 	-3 \\
> 	\frac{8}{7} \\
> 	\end{bmatrix}
> }
> $$
>
> ***Paul Laffitte*** *6222808130*
>
> \begin{aligned} x_{1} + 2x_{2} + x_{3} &= -1 \\ -3x_{1} + x_{2} + x_{3} &= 0 \\ x_{1} + 2x_{3} &= 1 \\ \end
> {aligned} \implies \overset{A}{ \begin{bmatrix} 1 & 2 & 1 \\ -3 & 1 & 1 \\ 1 & 0 & 3 \\ \end{bmatrix} } \overset{x}
> { \begin{bmatrix} x_{1} \\ x_{2} \\ x_{3} \\ \end{bmatrix} } = \overset{b}{ \begin{bmatrix} -1 \\ 0 \\ 1 \\ \end
> {bmatrix} } 
>
> Using the formula 
> Row_{i} := Row_{i} - (\frac{A_{ik}}{A_{kk}}) \cdot Row_{k}
> :
>
> -------------------------------------------------------------------------------
>
> A_{ik} = A_{21}
> hence 
> i = 2
> and 
> k = 1
>
> Row_{2} := Row_{2} - (\frac{A_{21}}{A_{11}}) \cdot Row_{1}
>
> = \begin{bmatrix}-3 & 1 & 1\end{bmatrix} - (\frac{-3}{1}) \cdot \begin{bmatrix}1 & 2 & 1\end{bmatrix}
>
> = \begin{bmatrix}0 & 7 & 4\end{bmatrix}
>
> \begin{bmatrix} 1 & 2 & 1 \\ 0 & 7 & 4 \\ 1 & 0 & 3 \\ \end{bmatrix} 
>
> -------------------------------------------------------------------------------
>
> A_{ik} = A_{31}
> hence 
> i = 3
> and 
> k = 1
>
> Row_{3} := Row_{3} - (\frac{A_{31}}{A_{11}}) \cdot Row_{1}
>
> = \begin{bmatrix}1 & 0 & 3\end{bmatrix} - (\frac{1}{1}) \cdot \begin{bmatrix}1 & 2 & 1\end{bmatrix}
>
> = \begin{bmatrix}0 & -2 & 2\end{bmatrix}
>
> \begin{bmatrix} 1 & 2 & 1 \\ 0 & 7 & 4 \\ 0 & -2 & 2 \\ \end{bmatrix} 
>
> -------------------------------------------------------------------------------
>
> A_{ik} = A_{32}
> hence 
> i = 3
> and 
> k = 2
>
> Row_{3} := Row_{3} - (\frac{A_{32}}{A_{22}}) \cdot Row_{2}
>
> = \begin{bmatrix}0 & -2 & 2\end{bmatrix} - (\frac{-2}{7}) \cdot \begin{bmatrix}0 & 7 & 4\end{bmatrix}
>
> = \begin{bmatrix}0 & 0 & \frac{22}{7}\end{bmatrix}
>
> \begin{bmatrix} 1 & 2 & 1 \\ 0 & 7 & 4 \\ 0 & 0 & \frac{22}{7} \\ \end{bmatrix} 
>
> -------------------------------------------------------------------------------
>
> \overset{A}{ \begin{bmatrix} 1 & 2 & 1 \\ -3 & 1 & 1 \\ 1 & 0 & 3 \\ \end{bmatrix} } = \overset{L}{ \begin{bmatrix}
> 1 & 0 & 0 \\ -3 & 1 & 0 \\ 1 & \frac{-2}{7} & 1 \\ \end{bmatrix} } \overset{U}{ \begin{bmatrix} 1 & 2 & 1 \\ 0 & 7 &
> 4\\ 0 & 0 & \frac{22}{7} \\ \end{bmatrix} } 
>
> Lw = b \implies \overset{L}{ \begin{bmatrix} 1 & 0 & 0 \\ -3 & 1 & 0 \\ 1 & \frac{-2}{7} & 1 \\ \end{bmatrix} }
> \overset{w}{ \begin{bmatrix} w_{1} \\ w_{2} \\ w_{3} \\ \end{bmatrix} } = \overset{b}{ \begin{bmatrix} -1 \\ 0 \\ 1
> \\ \end{bmatrix} } 
>
> for j = 1 to n:
>     j = 1
>     w1 = b1 / L11 = -1 / 1 = -1
>     for i = j + 1 to n:
>         i = 2
>         b2 = b2 - L21 * w1 = 0 - (-3) * (-1) = -3
>         i = 3
>         b3 = b3 - L31 * w1 = 1 - 1 * (-1) = 2
>     j = 2
>     w2 = b2 / L22 = -3 / 1 = -3
>     for i = j + 1 to n:
>         i = 3
>         b3 = b3 - L32 * w2 = 2 - (-2 / 7) * (-3) = 8 / 7
>     j = 3
>     w3 = b3 / L33 = (8 / 7) / 1 = 8 / 7
>     for i = j + 1 to n:
>         i = 4 -> skip
>
> Ux = w \implies \overset{U}{ \begin{bmatrix} 1 & 2 & 1 \\ 0 & 7 & 4 \\ 0 & 0 & \frac{22}{7} \\ \end{bmatrix} }
> \overset{x}{ \begin{bmatrix} x_{1} \\ x_{2} \\ x_{3} \\ \end{bmatrix} } = \overset{w}{ \begin{bmatrix} w_{1} \\ w_
> {2} \\ w_{3} \\ \end{bmatrix} } = \overset{w}{ \begin{bmatrix} -1 \\ -3 \\ \frac{8}{7} \\ \end{bmatrix} } 
>
> Paul Laffitte 6222808130


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-08-27 19:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-27 19:00 LaTeX algorithm to HTML using SVG images Paul Laffitte
     [not found] ` <ad859f30-bf09-4f90-a9d9-33ed5b14cbc4-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
2019-08-27 19:29   ` John MacFarlane

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).