Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add blog post for LaTeXML integration #83

Closed
ronaldtse opened this issue Apr 26, 2019 · 8 comments
Closed

Add blog post for LaTeXML integration #83

ronaldtse opened this issue Apr 26, 2019 · 8 comments
Assignees
Labels
enhancement New feature or request

Comments

@ronaldtse
Copy link
Contributor

No description provided.

@ronaldtse ronaldtse added the enhancement New feature or request label Apr 26, 2019
@ronaldtse ronaldtse added this to Needs triage in Nick Nicholas via automation Apr 26, 2019
@ronaldtse
Copy link
Contributor Author

Points to address:

  • How to use LaTeX math inside Metanorma?
  • How does the integration work?
  • What LaTeX packages are supported without needing to install a TeX distribution?
  • Can I mix AsciiMath and LaTeX math? Yes, they are both converted into MathML in MN XML.

@ronaldtse ronaldtse moved this from Needs triage to High priority in Nick Nicholas Apr 27, 2019
@opoudjis
Copy link
Contributor

Particularly for the third point, I will need help.

@ronaldtse
Copy link
Contributor Author

@opoudjis here's the list for the third point:

From LaTeXML @dginev:

There is a list of all supported files, but we do not really maintain a separate one for those not needing TeX. You can simply look for the ".sty.ltxml" and ".cls.ltxml" files in the distribution, all officially supported packages have a matching ".ltxml" file, even if all it does is to load the raw TeX definitions.

The list is at:
https://github.com/brucemiller/LaTeXML/tree/master/lib/LaTeXML/Package

Starting from that list, you could exclude the packages that explicitly use "InputDefinitions" to load raw TeX dependencies. At least I think this covers all. Currently it may be safe to ignore the following on non-TeX systems:

LaTeXML/lib/LaTeXML/Package$ rg -l '^[^#]*InputDefinitions' * 
algcompatible.sty.ltxml
algc.sty.ltxml
algmatlab.sty.ltxml
algorithm2e.sty.ltxml
algorithmic.sty.ltxml
algorithmicx.sty.ltxml
algorithm.sty.ltxml
algpascal.sty.ltxml
algpseudocode.sty.ltxml
applemac.def.ltxml
babel.def.ltxml
babel.sty.ltxml
circuitikz.sty.ltxml
cleveref.sty.ltxml
cp852.def.ltxml
csquotes.def.ltxml
csquotes.sty.ltxml
color.sty.ltxml
colordvi.sty.ltxml
flowchart.sty.ltxml
frenchb.ldf.ltxml
french.ldf.ltxml
fontenc.sty.ltxml
ifthen.sty.ltxml
inputenc.sty.ltxml
keyval.sty.ltxml
latin10.def.ltxml
listings.sty.ltxml
makecell.sty.ltxml
lipsum.sty.ltxml
ntheorem.sty.ltxml
numprint.sty.ltxml
pgf.sty.ltxml
pgfplots.sty.ltxml
pgfkeys.code.tex.ltxml
pgfmath.code.tex.ltxml
siunitx.sty.ltxml
t1enc.def.ltxml
t1enc.sty.ltxml
textcase.sty.ltxml
tikz.sty.ltxml
tikz-3dplot.sty.ltxml
xkvview.sty.ltxml
xcolor.sty.ltxml
wiki.sty.ltxml

@ronaldtse
Copy link
Contributor Author

ronaldtse commented May 1, 2019

So I did some checking:

$ cd LaTeXML/lib/LaTeXML/Package

# All `RequirePackage` calls
$ grep -E "RequirePackage\(\'.*\'\)" *.ltxml | grep -vEo '#.*RequirePackage' | grep -Eo "RequirePackage\('(.*?)'" | cut -f 2 -d "'" | sort | uniq > requires.txt

# All `InputDefinitions` calls (these calls depend on other packages (some internal, some external)
$ grep -E "InputDefinitions\(\'.*?\'" *.ltxml | grep -vEo '#.*InputDefinitions' | grep -Eo "InputDefinitions\('(.*?)'" | cut -d "'" -f 2 | sort | uniq > input_definitions.txt

# These are all the dependencies used.
$ cat requires.txt input_definitions.txt | sort | uniq > all_dependencies.txt

# These are all the packages supplied natively by LaTeXML.
$ find . | cut -d'/' -f 2 | cut -d '.' -f 1 | sort | uniq > package_files.txt

# We extract the dependencies that are not provided in package_files.txt
$ comm -13 package_files.txt all_dependencies.txt > unresolved.txt

# These are the packages that depend on a TeX distribution (external),
# as they use `InputDefinitions('foo')` where `foo` is not defined in LaTeXML.
$ for package in `cat unresolved.txt`; do grep -l "InputDefinitions..$package" *; done | sort | uniq > depends_on_tex.txt

# These packages depend on other packages (via `InputDefinitions`) that
# are not provided by LaTeXML.
$ cat depends_on_tex.txt | cut -f1,2 -d '.'
color.sty
colordvi.sty
ntheorem.sty
pgfkeys.code
pgfmath.code
siunitx.sty
tikz.sty
xcolor.sty

Therefore the list of packages that require a TeX dependency are these:

color.sty
colordvi.sty
ntheorem.sty
pgfkeys.code
pgfmath.code
siunitx.sty
tikz.sty
xcolor.sty

And it seems that none of these relate to real “math” (ntheorem is for laying out theorems, pgfmath is a graphics package)?

This means all other packages supplied by LaTeXML are available without any TeX distribution; the list is here:

$ comm -23 package_files.txt depends_on_tex.txt 

AmSTeX
BibTeX
IEEEtran
JHEP
JHEP2
JHEP3
LaTeX
OmniBus
TeX
a0poster
a0size
a4
a4wide
aa
aa_support
aas_macros
aas_support
aasms
aaspp
aastex
aastex6
aastex61
accents
acmart
acronym
ae
aecompl
afterpage
algc
algcompatible
algmatlab
algorithm
algorithm2e
algorithmic
algorithmicx
algpascal
algpseudocode
all_dependencies
alltt
ams_core
ams_support
amsa
amsart
amsb
amsbook
amsbsy
amscd
amsfonts
amsgen
amsmath
amsopn
amsppt
amsproc
amsrefs
amssymb
amstex
amstext
amsthm
amsxtra
apjfonts
appendix
applemac
array
article
attachfile
authblk
avant
babel
balance
bbm
bbold
beton
bm
book
bookman
booktabs
braket
breakurl
calc
cancel
caption
cases
ccfonts
chancery
charter
chngcntr
circuitikz
cite
citesort
cleveref
cmbright
color
colordvi
colortbl
comment
concmath
courier
cp852
crop
cropmark
csquotes
dcolumn
deluxetable
doublespace
dsfont
eTeX
ellipsis
elsart
elsart_support
elsarticle
empheq
emulateapj
emulateapj5
endnotes
enumerate
enumitem
epigraph
epsf
epsfig
epstopdf
esint
etex
etoolbox
eucal
eufrak
euler
eulervm
eurosym
euscript
exscale
fancyhdr
fix-cm
fixltx2e
flafter
fleqn
float
floatfig
floatflt
floatpag
flowchart
flushend
fontenc
fontspec
footmisc
fourier
framed
french
frenchb
fullpage
gen-j-l
gen-m-l
gen-p-l
gensymb
geometry
german
graphics
graphicx
grffile
helvet
here
hhline
html
hyperref
hyperxmp
icml2016
icml2017
icml2018
icml_support
ieeeconf
ifluatex
ifpdf
ifthen
ifvtex
ifxetex
import
indentfirst
input_definitions
inputenc
inst_support
iopams
iopart
iopart_support
jheppub
keyval
lastpage
latexml
latexsym
latin10
lgr
lineno
lipsum
listings
listingsutf8
llamapun
llncs
lmodern
longtable
lscape
luximono
lxRDFa
ly1
makecell
makeidx
marvosym
mathbbol
mathpazo
mathpple
mathptm
mathptmx
mathrsfs
mathtools
microtype
mleftright
mn
mn2e
mn2e_support
mnras
moderncv
multicol
multido
multirow
nameref
natbib
newcent
newfloat
newlfont
newtxmath
newtxtext
ngerman
nicefrac
ntheorem
numprint
ot4
package_files
palatino
paralist
parskip
pdfTeX
pdflscape
pdfpages
pdfsync
pgf
pgfkeys
pgfmath
pgfplots
pgfsys-latexml
pifont
placeins
preview
psfig
pslatex
pspicture
pst-grad
pst-node
pstricks
pxfonts
pzd
quantumarticle
ragged2e
relsize
remreset
report
requires
revsymb
revtex
revtex3_support
revtex4
revtex4-1
revtex4_support
rotate
rotating
rsfs
scalefnt
sectsty
setspace
showkeys
siunitx
slashed
slides
soul
srcltx
stfloats
stmaryrd
subcaption
subfig
subfigure
subfloat
supertabular
sv_support
svg
svjour
svjour3
svmult
t1
t1enc
t2a
t2b
t2c
tablefootnote
tabularx
tabulary
textcase
textcomp
texvc
theorem
thmtools
threeparttable
tikz
tikz-3dplot
times
titlesec
titling
tocbibind
todonotes
tracefnt
transparent
ts1
turing
txfonts
type1cm
ulem
units
upgreek
upref
url
utf8
utf8x
utopia
verbatim
wasysym
wiki
wrapfig
xargs
xcolor
xkeyval
xkvview
xspace
xunicode
yfonts

So in Metanorma we only need the packages that generate MathML, it looks like all the LaTeXML packages that deal with MathML are already useable natively (without an external TeX distribution).

@opoudjis
Copy link
Contributor

  1. How to use LaTeX math inside Metanorma?
  2. How does the integration work?
  3. What LaTeX packages are supported without needing to install a TeX distribution?
  4. Can I mix AsciiMath and LaTeX math? Yes, they are both converted into MathML in MN XML.

I will write 1 and 4.

I will not write 2 and 3. I will not write stuff I don't know, it wastes the time of me, and of the person who would have to explain it to me. That will be a task for @CAMOBAP795 presumably. @CAMOBAP795, this is about writing a joint blog post; I'm fine for you to take the credit, and I will write the Asciidoctor and Metanorma-specific material, but not the TeX and deployment content.

@opoudjis
Copy link
Contributor

opoudjis commented May 20, 2019

This comment is my draft of the blog post, but it is missing "How does the integration work?" and "What LaTeX packages are supported without needing to install a TeX distribution?" @CAMOBAP795, those will have to be written by you. Once you've done that, I'll post it on metanorma.com. @strogonoff, can blog posts be coauthored?

The following is natively in asciidoc syntax, btw. Please edit source, rather than trying to get GitHub's Markdown to show it nicely.


There are many ways to write mathematical formulas in a way that non-WYSIWYG systems like Metanorma can accept. There are two that Asciidoctor, the markup toolset underlying Metanorma, can process: http://asciimath.org[AsciiMath], and https://www.latex-project.org[LaTeX]. And there is a third that Metanorma will accept on top of those: https://www.w3.org/Math/[MathML].

Until recently, Metanorma has only processed AsciiMath and MathML. AsciiMath, that most elegant, parsimonious, human-readable and human-pleasing format (why yes, your humble wizard is biased), is recognised by default by Asciidoctor: anything inside of a stem macro or stem block is assumed by default to be in AsciiMath:

[source,asciidoctor]

The formula is stem:[sum_(i=1)^n i^3=((n(n+1))/2)^2]

The formula is:

[stem]
++++
sum_(i=1)^n i^3=((n(n+1))/2)^2
++++

MathML is not parsimonious or human-readable, but it is fairly widespread and supported, and is in fact what Metanorma by default converts AsciiMath into in Metanorma XML. (You can prevent that through the document attribute :mn-keep-asciimath:, or the metanorma option metanorma --asciimath.) Metanorma will also recognise MathML injected into a stem macro or block, provided the root element is <math>.

[source,asciidoctor]

The formula is:

[stem]
++++
∑i=1ni3=nn+122
++++

(Insert cartoon of wizard bamboozled by MathML)

But what of LaTeX?

LaTeX is supported by Asciidoctor, and now is fully supported by Metanorma as well. Asciidoctor allows you to specify that a mathematical expression is LaTeX and AsciiMath, in two ways:

  1. By using [latexmath] as the style attribute, instead of [stem]
  2. By setting the document attribute :stem: latexmath, meaning that all [stem] expressions are taken as being LaTeX instead of AsciiMath. (In that case, you need to use [asciimath] to indicate that a mathematical expression is in AsciiMath.

(Read more about
link:/author/topics/document-format/text/#mathematical-expressions[mathematical expressions] in Asciidoctor.)

[source,asciidoctor]

The formula is latexmath:[\displaystyle{\sum_{{{i}={1}}}^{{n}}}{i}^{3}={\left(\frac{{{n}{\left({n}+{1}\right)}}}{{2}}\right)}^{2}]

The formula is:

[stem]
++++
\displaystyle{\sum_{{{i}={1}}}^{{n}}}{i}^{3}={\left(\frac{{{n}{\left({n}+{1}\right)}}}{{2}}\right)}^{2}
++++

So Asciidoctor allows you to mix AsciiMath and LaTeX in the same document. Metanorma does too, because by default it converts both to MathML.

Now, to convert LaTeX to MathML, and make it usable downstream, Metanorma needs your system to be able to process LaTeX.

@CAMOBAP795, continue from here...

@opoudjis opoudjis moved this from High priority to On hold in Nick Nicholas May 20, 2019
@CAMOBAP
Copy link
Contributor

CAMOBAP commented May 22, 2019

How does the integration work?

Under the hood metanorm use exection latexmlmath --preload=amsmath -- - command

NOTE:

On windows important to use UTF-8 encoding in cmd. To accomplish this execute chcp 65001

What LaTeX packages are supported without needing to install a TeX distribution?

There is no clear separation between TeX bound packages and TeX independent packages. Better to say that some packages contain functions which require TeX, list provided by @ronaldtse

@opoudjis let me know if more information needs to be provided

@strogonoff
Copy link
Contributor

strogonoff commented May 22, 2019 via email

@opoudjis opoudjis moved this from On hold to High priority in Nick Nicholas May 25, 2019
opoudjis added a commit that referenced this issue May 27, 2019
Nick Nicholas automation moved this from High priority to Closed May 27, 2019
ronaldtse pushed a commit that referenced this issue May 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
No open projects
Nick Nicholas
  
Closed
Development

No branches or pull requests

4 participants