Skip to content

Instantly share code, notes, and snippets.

@njamescouk
Created September 15, 2019 11:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save njamescouk/7bc4ee42c8255cdd11192a4d494a863a to your computer and use it in GitHub Desktop.
Save njamescouk/7bc4ee42c8255cdd11192a4d494a863a to your computer and use it in GitHub Desktop.
produce fractions when using pandoc to go from latex to html
\documentclass{article}
\begin{document}
\begin{tabular}[]{ r r r r r r r r }
to the power & $^{^-1}$ & $^{^-2}$ & $^{^-3}$ & $^{^-4}$ & $^{^-5}$ & $^{^-6}$ & \ldots{}\\[.5em]
2 & $\frac{1}{2}$ & $\frac{1}{4}$ & $\frac{1}{8}$ & $\frac{1}{16}$ & $\frac{1}{32}$ & $\frac{1}{64}$ & \ldots{}\\[1em]
3 & $\frac{1}{3}$ & $\frac{1}{9}$ & $\frac{1}{27}$ & $\frac{1}{81}$ & $\frac{1}{243}$ & $\frac{1}{729}$ &\\[1ex]
\ldots{} & & & & & &\\[2ex]
10 & $\frac{1}{10}$ & $\frac{1}{100}$ & $\frac{1}{1000}$ & \ldots{} & & &\\
\end{tabular}
\begin{verbatim}
pandoc -s -t html5 -f latex -o fractions.html fractions.latex
A simple minded transformation of pandoc's html output like so:
sed s/$\\frac{/^<sup^>/ fractions.html > tmp.html
sed s#}{#^</sup^>/^<sub^># tmp.html > fractions.html
sed s#}\$#^</sub^># fractions.html > tmp.html
mv tmp.html fractions.html
is an acceptable result?
\end{verbatim}
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment