liamoc / latex-formulae Goto Github PK
View Code? Open in Web Editor NEWLibraries and tools for rendering math to images using real LaTeX, from Haskell, Pandoc and Hakyll
License: BSD 3-Clause "New" or "Revised" License
Libraries and tools for rendering math to images using real LaTeX, from Haskell, Pandoc and Hakyll
License: BSD 3-Clause "New" or "Revised" License
I was trying to use this to compile the .tex
file from this repository
to an epub book. The filter generally works really well! However, that book makes liberal use of math macros from additional packages, resulting in errors like this one instead of rendered math:
No file working.aux.
! Undefined control sequence.
<recently read> \mathbb
l.7 \mathbb
D &=& \{{\mathsf{E}}, {\mathsf{O}}, \top\} \\
[1] (./working.aux) )
(see the transcript file for additional information)
Output written on working.dvi (1 page, 1608 bytes).
Transcript written on working.log.
Is there an undocumented way to provide a template which includes those packages?
This is my post:
---
title: Hello!
tags: nontechnical
preamble: \usepackage{amsmath,amsfonts,amssymb}\usepackage{tikz}\usetikzlibrary{calc,fadings,decorations.pathreplacing}
---
Some prettier stuff:
$$ \begin{tikzpicture}
\draw (0,0)--(10,0);
\filldraw (0,0) circle (3pt);
\end{tikzpicture}
$$
This is what I get:
data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAAAGCAQAAAC/O6xzAAAAKklEQVR4nGNggIDbDP+hEAUoYhdmYOjDLszAcA67MANDGcNfbMIgO8AAAOObEODG8S5AAAAAAElFTkSuQmCC
This is an 11x6 image!
In addition, sometimes I get these weird errors while doing a ./site build
:
Compiling
cached templates/default.html
cached about.rst
formula (displaymath) "\begin{tikzpictu"
drawing...
[ERROR] ./Data/Vector/Generic.hs:235 ((!)): index out of bounds (40,40)
formula (displaymath) "\begin{tikzpictu"
drawing...
Hello! Thanks for the nice library! I just wanted to say that your example of minimal setup for Hakyll does not really work. After some playing, the simplest I got was:
customCompiler :: ReaderOptions -> WriterOptions
-> (Item Pandoc -> Compiler (Item Pandoc))
-> Compiler (Item String)
customCompiler ropt wopt f =
writePandocWith wopt <$> (f =<< readPandocWith ropt =<< getResourceBody)
main = do
renderFormulae <- initFormulaCompilerDataURI 1000 defaultEnv
hakyll $
match "posts/*" $ do
route $ setExtension "html"
compile $ customCompiler defaultHakyllReaderOptions defaultHakyllWriterOptions
(renderFormulae defaultPandocFormulaOptions)
The default compiler from Hakyll does not work because it applies traverse to f
in the first function. Adding this example to the docs would probably help new users. Adding the custom compiler would make things even easier.
Hi, I'm trying to use latex-formulae-hakyll
with GHC 9.2.8 on LTS 20.26, but I'm getting the following stack
build errors:
Error: [S-4804]
Stack failed to construct a build plan.
While constructing the build plan, Stack encountered the following errors:
In the dependencies for latex-formulae-hakyll-0.2.0.4:
base-4.16.4.0 from Stack configuration does not match >=4.7 && <4.13 (latest matching version is 4.12.0.0)
hakyll-4.15.1.1 from Stack configuration does not match >=4.6 && <4.14 (latest matching version is 4.13.4.1)
pandoc-types-1.22.2.1 from Stack configuration does not match >=1.12 && <1.18 (latest matching version is 1.17.6.1)
needed due to my-package-0.1.0.0 -> latex-formulae-hakyll-0.2.0.4
In the dependencies for latex-formulae-image-0.1.1.4:
base-4.16.4.0 from Stack configuration does not match >=4.8 && <4.14 (latest matching version is 4.13.0.0)
needed due to my-package-0.1.0.0 -> latex-formulae-image-0.1.1.4
In the dependencies for latex-formulae-pandoc-0.2.0.6:
base64-bytestring-1.2.1.0 from Stack configuration does not match >=1.0 && <1.1 (latest matching version is 1.0.0.3)
bytestring-0.11.4.0 from Stack configuration does not match >=0.10 && <0.11 (latest matching version is 0.10.12.1)
pandoc-types-1.22.2.1 from Stack configuration does not match >=1.12 && <1.18 (latest matching version is 1.17.6.1)
needed due to my-package-0.1.0.0 -> latex-formulae-pandoc-0.2.0.6
Some different approaches to resolving this:
* Set allow-newer: true in /home/edu/.stack/config.yaml to ignore all version constraints and build anyway.
* Build requires unattainable version of the base package. Since base is a part of GHC, you most likely need to use a
different GHC version with the matching base.
Unfortunately, the packages latex-formulae
packages won't work out of the box with the new dependency versions. When trying to compile my project setting allow-newer: true
, I got a few instances of an error that looks like this:
latex-formulae-pandoc> /tmp/stack-fb1a7e8d498e0991/latex-formulae-pandoc-0.2.0.6/src/Image/LaTeX/Render/Pandoc.hs:217:35: error:
latex-formulae-pandoc> • Couldn't match type ‘[Char]’
latex-formulae-pandoc> with ‘text-1.2.5.0:Data.Text.Internal.Text’
latex-formulae-pandoc> Expected: text-1.2.5.0:Data.Text.Internal.Text
latex-formulae-pandoc> Actual: String
latex-formulae-pandoc> • In the first argument of ‘Str’, namely ‘"Error:"’
latex-formulae-pandoc> In the expression: Str "Error:"
latex-formulae-pandoc> In the first argument of ‘Emph’, namely ‘[Str "Error:"]’
latex-formulae-pandoc> |
latex-formulae-pandoc> 217 | pandocError = Strong . (Emph [Str "Error:"] :)
latex-formulae-pandoc> |
It doesn't seem too hard to fix, I could try to do it if no one's available.
Thanks!
Hello,
do you mind to support newer versions of GHC and latest Haskell LTS?
Right now upper bound of base does not allow it. I would recommend changing the bound for base to base < 5.0. And remove version constraints for other packages. Like I have done here: aligusnet@55026b3
In most cases, it works just fine and allows using the package with newer compiler's versions without pain and hassle :)
Hey, thanks for the great tool!
I'm having some strange troubles when using tikzcd
package in LaTeX for Hakyll.
Namely, using this code:
---
title: Test
preamble: \usepackage{tikz-cd}\usetikzlibrary{cd}
---
This is a test.
$$
\begin{tikzcd}[column sep=large] C \ar[r, bend left=18pt, "H"]\ar[r, bend right=18pt, "G"']\ar[r, phantom, "\scriptstyle\alpha\!\Downarrow\;"]& D \\
\end{tikzcd}
$$
---
$$
\begin{tikzcd}
F(X) \ar[r, "F(f)"] & F(Y)\\
X \ar[r, "f"] \ar[u, dashed] & Y \ar[u, dashed] \\
\end{tikzcd}
$$
Another text.
This is the output I'm receiving:
As you can notice, the bottom part of these images is missing. This doesn't seem to be happening for any old latex formulae, but just when I'm using tikzcd
.
If I add an empty line such as & \\
just before \end{tikzcd}
then the problem seems to go away, but that messes up alignment if I'm using tikzcd inline.
Everything else seems to be working properly, so it doesn't seem the problem is related to my code.
I've found something potentially relevant: apparently convert truncates these images? https://imagemagick.org/discourse-server/viewtopic.php?t=36176
I am trying to use colors in math mode. However the following minimal examples cannot compile since \textcolor
is apparently not available even though the package is loaded.
Tex:
\documentclass{article}
\usepackage{color}
\begin{document}
$\textcolor{red}{test}$
\end{document}
Markdown:
-----------
title: Test
header-includes:
- \usepackage{color}
-----------
$\textcolor{red}{asd}$
Do you have any idea what the problem could be?
Thanks for all the work you have put into it!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.