-
I am wondering if it's possible to generate an html document from existing latex sources using lwarp but without modifying the source files. That is, can lwarp be used solely using command line arguments? My best attempt so far looks like this but the resulting html is not complete so I guess I am missing something: #!/usr/bin/env sh
# Choose bibtex of biber - TODO automate
bibexe=bibtex
#bibexe=biber
# Get the file path without the file extension
F=$1
F=${F%.*}
Fpath=$(dirname "${F}.tex")
# Convert image files
find ${Fpath} -name "*.eps" -exec lwarpmk epstopdf {} \;
find ${Fpath} -name "*.pdf" -exec lwarpmk pdftosvg {} \;
# Compile document while injecting lwarp
pdflatex -jobname=${F} '\AtBeginDocument{\RequirePackage[mathjax]{lwarp}}\input{'${F}'.tex}'
${bibexe} ${F}
pdflatex -jobname=${F} '\AtBeginDocument{\RequirePackage[mathjax]{lwarp}}\input{'${F}'.tex}'
pdflatex -jobname=${F} '\AtBeginDocument{\RequirePackage[mathjax]{lwarp}}\input{'${F}'.tex}'
# Compile _html document while injecting lwarp
pdflatex -jobname=${F}_html '\AtBeginDocument{\RequirePackage[mathjax]{lwarp}}\input{'${F}'_html.tex}'
${bibexe} ${F}_html
pdflatex -jobname=${F}_html '\AtBeginDocument{\RequirePackage[mathjax]{lwarp}}\input{'${F}'_html.tex}'
pdflatex -jobname=${F}_html '\AtBeginDocument{\RequirePackage[mathjax]{lwarp}}\input{'${F}'_html.tex}'
# Converrt _html pdf to actual html
pdftotext -enc UTF-8 -nopgbrk -layout ${F}_html.pdf ${F}_html.html And the example file I test it with: \documentclass{article}
% lwarp loading commented out to test external injection
%\usepackage[mathjax]{lwarp}
\usepackage{blindtext}
\author{Jane Doe}
\title{Test}
\begin{document}
\maketitle
\blindtext
Test citation \cite{article-full}.
Test equation:
\begin{equation}
\frac{1}{x} = \sqrt{a^2+b^2}
\end{equation}
\bibliographystyle{plain}
\bibliography{xampl}
\end{document} Am I missing something relatively simple here or is what I am trying to achieve much more complex than I would hope for? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
Lwarp wants to be loaded early, just after the fonts are set. You could try: And to convert the PDF to HTML, use I'm guessing you have a large number of files to process in bulk, thus the desire to avoid editing each file. If you can get this to work then I'll add something about it in the Lwarp docs. |
Beta Was this translation helpful? Give feedback.
-
For docs on the hooks, These are new features as of a few years ago. |
Beta Was this translation helpful? Give feedback.
-
Found the doc: |
Beta Was this translation helpful? Give feedback.
Lwarp wants to be loaded early, just after the fonts are set. You could try:
\AddToHook{package/lmodern/after}{\RequirePackage[mathjax]{lwarp}}
or to load immediately after the class:
\AddToHook{class/article/after}{\RequirePackage[mathjax]{lwarp}}
And to convert the PDF to HTML, use
lwarpmk html
and maybe
lwarpmk limages
I'm guessing you have a large number of files to process in bulk, thus the desire to avoid editing each file. If you can get this to work then I'll add something about it in the Lwarp docs.