Last active
April 8, 2020 11:07
-
-
Save tvercaut/40f21031e858f31607ae4e1ceacdc9bf to your computer and use it in GitHub Desktop.
Latex to MS Word tests
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hack file to get a nicer Gist name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Temporary OS files | |
.DS_Store | |
## Core latex/pdflatex auxiliary files: | |
*.aux | |
*.lof | |
*.log | |
*.lot | |
*.fls | |
*.out | |
*.toc | |
*.fmt | |
*.fot | |
*.cb | |
*.cb2 | |
.*.lb | |
## Intermediate documents: | |
*.dvi | |
*.xdv | |
*-converted-to.* | |
# these rules might exclude image files for figures etc. | |
# *.ps | |
# *.eps | |
## Generated if empty string is given at "Please type another file name for output:" | |
## Bibliography auxiliary files (bibtex/biblatex/biber): | |
*.bbl | |
*.bcf | |
*.blg | |
*-blx.aux | |
*-blx.bib | |
*.run.xml | |
## Build tool auxiliary files: | |
*.fdb_latexmk | |
*.synctex | |
*.synctex(busy) | |
*.synctex.gz | |
*.synctex.gz(busy) | |
*.pdfsync | |
## Build tool directories for auxiliary files | |
# latexrun | |
latex.out/ | |
## Auxiliary and intermediate files from other packages: | |
# algorithms | |
*.alg | |
*.loa | |
# achemso | |
acs-*.bib | |
# amsthm | |
*.thm | |
# beamer | |
*.nav | |
*.pre | |
*.snm | |
*.vrb | |
# changes | |
*.soc | |
# comment | |
*.cut | |
# cprotect | |
*.cpt | |
# elsarticle (documentclass of Elsevier journals) | |
*.spl | |
# endnotes | |
*.ent | |
# fixme | |
*.lox | |
# feynmf/feynmp | |
*.mf | |
*.mp | |
*.t[1-9] | |
*.t[1-9][0-9] | |
*.tfm | |
#(r)(e)ledmac/(r)(e)ledpar | |
*.end | |
*.?end | |
*.[1-9] | |
*.[1-9][0-9] | |
*.[1-9][0-9][0-9] | |
*.[1-9]R | |
*.[1-9][0-9]R | |
*.[1-9][0-9][0-9]R | |
*.eledsec[1-9] | |
*.eledsec[1-9]R | |
*.eledsec[1-9][0-9] | |
*.eledsec[1-9][0-9]R | |
*.eledsec[1-9][0-9][0-9] | |
*.eledsec[1-9][0-9][0-9]R | |
# glossaries | |
*.acn | |
*.acr | |
*.glg | |
*.glo | |
*.gls | |
*.glsdefs | |
*.lzo | |
*.lzs | |
# uncomment this for glossaries-extra (will ignore makeindex's style files!) | |
# *.ist | |
# gnuplottex | |
*-gnuplottex-* | |
# gregoriotex | |
*.gaux | |
*.gtex | |
# htlatex | |
*.4ct | |
*.4tc | |
*.idv | |
*.lg | |
*.trc | |
*.xref | |
# hyperref | |
*.brf | |
# knitr | |
*-concordance.tex | |
# TODO Comment the next line if you want to keep your tikz graphics files | |
*.tikz | |
*-tikzDictionary | |
# listings | |
*.lol | |
# luatexja-ruby | |
*.ltjruby | |
# makeidx | |
*.idx | |
*.ilg | |
*.ind | |
# minitoc | |
*.maf | |
*.mlf | |
*.mlt | |
*.mtc[0-9]* | |
*.slf[0-9]* | |
*.slt[0-9]* | |
*.stc[0-9]* | |
# minted | |
_minted* | |
*.pyg | |
# morewrites | |
*.mw | |
# nomencl | |
*.nlg | |
*.nlo | |
*.nls | |
# pax | |
*.pax | |
# pdfpcnotes | |
*.pdfpc | |
# sagetex | |
*.sagetex.sage | |
*.sagetex.py | |
*.sagetex.scmd | |
# scrwfile | |
*.wrt | |
# sympy | |
*.sout | |
*.sympy | |
sympy-plots-for-*.tex/ | |
# pdfcomment | |
*.upa | |
*.upb | |
# pythontex | |
*.pytxcode | |
pythontex-files-*/ | |
# tcolorbox | |
*.listing | |
# thmtools | |
*.loe | |
# TikZ & PGF | |
*.dpth | |
*.md5 | |
*.auxlock | |
# todonotes | |
*.tdo | |
# vhistory | |
*.hst | |
*.ver | |
# easy-todo | |
*.lod | |
# xcolor | |
*.xcp | |
# xmpincl | |
*.xmpi | |
# xindy | |
*.xdy | |
# xypic precompiled matrices and outlines | |
*.xyc | |
*.xyd | |
# endfloat | |
*.ttt | |
*.fff | |
# Latexian | |
TSWLatexianTemp* | |
## Editors: | |
# WinEdt | |
*.bak | |
*.sav | |
# Texpad | |
.texpadtmp | |
# LyX | |
*.lyx~ | |
# Kile | |
*.backup | |
# gummi | |
.*.swp | |
# KBibTeX | |
*~[0-9]* | |
# TeXnicCenter | |
*.tps | |
# auto folder when using emacs and auctex | |
./auto/* | |
*.el | |
# expex forward references with \gathertags | |
*-tags.tex | |
# standalone packages | |
*.sta | |
# Makeindex log files | |
*.lpz | |
# REVTeX puts footnotes in the bibliography by default, unless the nofootinbib | |
# option is specified. Footnotes are the stored in a file with suffix Notes.bib. | |
# Uncomment the next line to have this generated file ignored. | |
#*Notes.bib |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
export clean_ext="aux bbl blg brf idx ilg ind lof log lol lot out toc synctex.gz fdb_latexmk fls dvi 4ct 4tc idv lg tmp xref" | |
export image_ext="ext png eps jpg jpeg" | |
# See https://github.com/michal-h21/make4ht/issues/6 | |
for ext in $image_ext; do | |
if [ -n "$(ls -A *.$ext 2> /dev/null)" ]; then | |
#echo "has $ext files" | |
for file in *.$ext; do | |
echo "running: ebb -x $file" | |
ebb -x $file | |
done | |
fi | |
done | |
latexmk -pdf sample | |
mv sample.pdf sample-latexmk.pdf | |
for ext in $clean_ext; do | |
echo "running:rm -f *.$ext" | |
rm -f *.$ext | |
done | |
# pandoc can't take pdf as input | |
#pandoc -s sample-latexmk.pdf -o sample-latexmkpdf_pandoc.docx | |
pandoc -s sample.tex --bibliography samplebibliography.bib --filter pandoc-citeproc -o sample-tex2word_pandoc.docx | |
make4ht -uf html5+latexmk_build+tidy -c tex4ht.cfg sample.tex | |
mv sample.html sample-make4ht.html | |
pandoc -s sample-make4ht.html -c sample.css -o sample-make4ht_then_pandoc.docx | |
for ext in $clean_ext; do | |
echo "running:rm -f *.$ext" | |
rm -f *.$ext | |
done | |
make4ht -uf html5+latexmk_build+tidy -c tex4ht_no_css.cfg sample.tex | |
mv sample.html sample-make4ht_no_css.html | |
pandoc -s sample-make4ht_no_css.html -o sample-make4ht_no_css_then_pandoc.docx | |
for ext in $clean_ext; do | |
echo "running:rm -f *.$ext" | |
rm -f *.$ext | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass[pmlr]{jmlr} | |
% The following packages will be automatically loaded: | |
% jmlr, amsmath, amssymb, natbib, graphicx, url, algorithm2e | |
% ifoddpage, relsize and probably more | |
% make sure they are installed with your latex distribution | |
\usepackage{esvect} | |
\usepackage{mwe} % to get dummy images | |
\jmlrvolume{-- Under Review} | |
\jmlryear{2020} | |
\jmlrworkshop{Full Paper -- MIDL 2020 submission} | |
\editors{Under Review for MIDL 2020} | |
\title[Short Title]{Full Title of Article} | |
% Two authors with the same address | |
\author{\Name{Author Name1} \Email{[email protected]}\and | |
\Name{Author Name2} \Email{[email protected]}\\ | |
\addr Address} | |
\begin{document} | |
\maketitle | |
\begin{abstract} | |
This is a great paper and it has a concise abstract. | |
\end{abstract} | |
\begin{keywords} | |
List of keywords, comma separated. | |
\end{keywords} | |
\section{Introduction} | |
This is where the content of your paper goes. Some random | |
notes: | |
% \footnote{Random footnote are discouraged}: | |
\begin{itemize} | |
\item You should use {\LaTeX} \cite{Lamport:Book:1989}. | |
\item JMLR/PMLR uses natbib for references. For simplicity, here, \verb|\cite| defaults to | |
parenthetical citations, i.e. \verb|\citep|. You can of course also | |
use \verb|\citet| for textual citations. | |
\item You should follow the guidelines provided by the conference. | |
\item Read through the JMLR template documentation for specific \LaTeX | |
usage questions. | |
\item Note that the JMLR template provides many handy functionalities | |
such as \verb|\figureref| to refer to a figure, | |
e.g. \figureref{fig:example}, \verb|\tableref| to refer to a table, | |
e.g. \tableref{tab:example} and \verb|\equationref| to refer to an equation, | |
e.g. \equationref{eq:example}. | |
\end{itemize} | |
\begin{table}[htbp] | |
% The first argument is the label. | |
% The caption goes in the second argument, and the table contents | |
% go in the third argument. | |
\floatconts | |
{tab:example}% | |
{\caption{An Example Table}}% | |
{\begin{tabular}{ll} | |
\bfseries Dataset & \bfseries Result\\ | |
Data1 & 0.12345\\ | |
Data2 & 0.67890\\ | |
Data3 & 0.54321\\ | |
Data4 & 0.09876 | |
\end{tabular}} | |
\end{table} | |
\begin{figure}[htbp] | |
% Caption and label go in the first argument and the figure contents | |
% go in the second argument | |
\floatconts | |
{fig:example} | |
{\caption{Example Image}} | |
{\includegraphics[width=0.5\linewidth]{sample-image}} | |
\end{figure} | |
\begin{algorithm2e} | |
\caption{Computing Net Activation} | |
\label{alg:net} | |
% older versions of algorithm2e have \dontprintsemicolon instead | |
% of the following: | |
%\DontPrintSemicolon | |
% older versions of algorithm2e have \linesnumbered instead of the | |
% following: | |
%\LinesNumbered | |
\KwIn{$x_1, \ldots, x_n, w_1, \ldots, w_n$} | |
\KwOut{$y$, the net activation} | |
$y\leftarrow 0$\; | |
\For{$i\leftarrow 1$ \KwTo $n$}{ | |
$y \leftarrow y + w_i*x_i$\; | |
} | |
\end{algorithm2e} | |
% Testing math from http://www.maths.adelaide.edu.au/anthony.roberts/LaTeX/Src/maths.tex | |
\section{Math example from Tony Roberts} | |
See \url{http://www.maths.adelaide.edu.au/anthony.roberts/LaTeX/Src/maths.tex}. | |
\section{Delimiters} | |
See how the delimiters are of reasonable size in these examples | |
\[ | |
\left(a+b\right)\left[1-\frac{b}{a+b}\right]=a\,, | |
\] | |
\[ | |
\sqrt{|xy|}\leq\left|\frac{x+y}{2}\right|, | |
\] | |
even when there is no matching delimiter | |
\[ | |
\int_a^bu\frac{d^2v}{dx^2}\,dx | |
=\left.u\frac{dv}{dx}\right|_a^b | |
-\int_a^b\frac{du}{dx}\frac{dv}{dx}\,dx. | |
\] | |
\section{Spacing} | |
Differentials often need a bit of help with their spacing as in | |
\[ | |
\iint xy^2\,dx\,dy | |
=\frac{1}{6}x^2y^3, | |
\] | |
whereas vector problems often lead to statements such as | |
\[ | |
u=\frac{-y}{x^2+y^2}\,,\quad | |
v=\frac{x}{x^2+y^2}\,,\quad\text{and}\quad | |
w=0\,. | |
\] | |
Occasionally one gets horrible line breaks when using a list in mathematics such as listing the first twelve primes \(2,3,5,7,11,13,17,19,23,29,31,37\)\,. | |
In such cases, perhaps include \verb|\mathcode`\,="213B| inside the inline maths environment so that the list breaks: \(\mathcode`\,="213B 2,3,5,7,11,13,17,19,23,29,31,37\)\,. | |
Be discerning about when to do this as the spacing is different. | |
\section{Arrays} | |
Arrays of mathematics are typeset using one of the matrix environments as | |
in | |
\[ | |
\begin{bmatrix} | |
1 & x & 0 \\ | |
0 & 1 & -1 | |
\end{bmatrix}\begin{bmatrix} | |
1 \\ | |
y \\ | |
1 | |
\end{bmatrix} | |
=\begin{bmatrix} | |
1+xy \\ | |
y-1 | |
\end{bmatrix}. | |
\] | |
Case statements use cases: | |
\[ | |
|x|=\begin{cases} | |
x, & \text{if }x\geq 0\,, \\ | |
-x, & \text{if }x< 0\,. | |
\end{cases} | |
\] | |
Many arrays have lots of dots all over the place as in | |
\[ | |
\begin{matrix} | |
-2 & 1 & 0 & 0 & \cdots & 0 \\ | |
1 & -2 & 1 & 0 & \cdots & 0 \\ | |
0 & 1 & -2 & 1 & \cdots & 0 \\ | |
0 & 0 & 1 & -2 & \ddots & \vdots \\ | |
\vdots & \vdots & \vdots & \ddots & \ddots & 1 \\ | |
0 & 0 & 0 & \cdots & 1 & -2 | |
\end{matrix} | |
\] | |
\section{Equation arrays} | |
In the flow of a fluid film we may report | |
\begin{eqnarray} | |
u_\alpha & = & \epsilon^2 \kappa_{xxx} | |
\left( y-\frac{1}{2}y^2 \right), | |
\label{equ} \\ | |
v & = & \epsilon^3 \kappa_{xxx} y\,, | |
\label{eqv} \\ | |
p & = & \epsilon \kappa_{xx}\,. | |
\label{eqp} | |
\end{eqnarray} | |
Alternatively, the curl of a vector field $(u,v,w)$ may be written | |
with only one equation number: | |
\begin{eqnarray} | |
\omega_1 & = & | |
\frac{\partial w}{\partial y}-\frac{\partial v}{\partial z}\,, | |
\nonumber \\ | |
\omega_2 & = & | |
\frac{\partial u}{\partial z}-\frac{\partial w}{\partial x}\,, | |
\label{eqcurl} \\ | |
\omega_3 & = & | |
\frac{\partial v}{\partial x}-\frac{\partial u}{\partial y}\,. | |
\nonumber | |
\end{eqnarray} | |
Whereas a derivation may look like | |
\begin{eqnarray*} | |
(p\wedge q)\vee(p\wedge\neg q) & = & p\wedge(q\vee\neg q) | |
\quad\text{by distributive law} \\ | |
& = & p\wedge T \quad\text{by excluded middle} \\ | |
& = & p \quad\text{by identity} | |
\end{eqnarray*} | |
\section{Functions} | |
Observe that trigonometric and other elementary functions are typeset | |
properly, even to the extent of providing a thin space if followed by | |
a single letter argument: | |
\[ | |
\exp(i\theta)=\cos\theta +i\sin\theta\,,\quad | |
\sinh(\log x)=\frac{1}{2}\left( x-\frac{1}{x} \right). | |
\] | |
With sub- and super-scripts placed properly on more complicated | |
functions, | |
\[ | |
\lim_{q\to\infty}\|f(x)\|_q | |
=\max_{x}|f(x)|, | |
\] | |
and large operators, such as integrals and | |
\begin{eqnarray*} | |
e^x & = & \sum_{n=0}^\infty \frac{x^n}{n!} | |
\quad\text{where }n!=\prod_{i=1}^n i\,, \\ | |
\overline{U_\alpha} & = & \bigcap_\alpha U_\alpha\,. | |
\end{eqnarray*} | |
In inline mathematics the scripts are correctly placed to the side in | |
order to conserve vertical space, as in | |
\( | |
1/(1-x)=\sum_{n=0}^\infty x^n. | |
\) | |
\section{Accents} | |
Mathematical accents are performed by a short command with one | |
argument, such as | |
\[ | |
\tilde f(\omega)=\frac{1}{2\pi} | |
\int_{-\infty}^\infty f(x)e^{-i\omega x}\,dx\,, | |
\] | |
or | |
\[ | |
\dot{\vec \omega}=\vec r\times\vec I\,. | |
\] | |
\section{Command definition} | |
\newcommand{\Ai}{\operatorname{Ai}} | |
The Airy function, $\Ai(x)$, may be incorrectly defined as this | |
integral | |
\[ | |
\Ai(x)=\int\exp(s^3+isx)\,ds\,. | |
\] | |
\newcommand{\D}[2]{\frac{\partial #2}{\partial #1}} | |
\newcommand{\DD}[2]{\frac{\partial^2 #2}{\partial #1^2}} | |
\renewcommand{\vec}[1]{\boldsymbol{#1}} | |
This vector identity serves nicely to illustrate two of the new | |
commands: | |
\[ | |
\vec\nabla\times\vec q | |
=\vec i\left(\D yw-\D zv\right) | |
+\vec j\left(\D zu-\D xw\right) | |
+\vec k\left(\D xv-\D yu\right). | |
\] | |
Recall that typesetting multi-line mathematics is an art normally too hard for computer recipes. Nonetheless, if you need to be automatically flexible about multi-line mathematics, and you do not mind some rough typesetting, then perhaps invoke \verb|\parbox| to help as follows: | |
% The \verb|breqn| package is not yet reliable enough for general use. | |
\newcommand{\parmath}[2][0.8\linewidth]{\parbox[t]{#1}% | |
{\raggedright\linespread{1.2}\selectfont\(#2\)}} | |
\[ | |
u_1=\parmath{ -2 \gamma \epsilon^{2} s_{2}+\mu \epsilon^{3} \big( \frac{3}{8} s_{2}+\frac{1}{8} s_{1} i\big)+\epsilon^{3} \big( -\frac{81}{32} s_{4} s_{2}^{2}-\frac{27}{16} s_{4} s_{2} s_{1} i+\frac{9}{32} s_{4} s_{1}^{2}+\frac{27}{32} s_{3} s_{2}^{2} i-\frac{9}{16} s_{3} s_{2} s_{1}-\frac{3}{32} s_{3} s_{1}^{2} i\big) +\int_a^b 1-2x+3x^2-4x^3\,dx } | |
\] | |
Also, sometimes use \verb|\parbox| to typeset multiline entries in tables. | |
\section{Theorems et al.} | |
%\newtheorem{theorem}{Theorem} | |
%\newtheorem{corollary}[theorem]{Corollary} | |
%\newtheorem{lemma}[theorem]{Lemma} | |
%\newtheorem{definition}[theorem]{Definition} | |
\begin{definition}[right-angled triangles] \label{def:tri} | |
A \emph{right-angled triangle} is a triangle whose sides of length~\(a\), \(b\) and~\(c\), in some permutation of order, satisfies \(a^2+b^2=c^2\). | |
\end{definition} | |
\begin{lemma} | |
The triangle with sides of length~\(3\), \(4\) and~\(5\) is right-angled. | |
\end{lemma} | |
This lemma follows from the Definition~\ref{def:tri} as \(3^2+4^2=9+16=25=5^2\). | |
\begin{theorem}[Pythagorean triplets] \label{thm:py} | |
Triangles with sides of length \(a=p^2-q^2\), \(b=2pq\) and \(c=p^2+q^2\) are right-angled triangles. | |
\end{theorem} | |
Prove this Theorem~\ref{thm:py} by the algebra \(a^2+b^2 =(p^2-q^2)^2+(2pq)^2 | |
=p^4-2p^2q^2+q^4+4p^2q^2 | |
=p^4+2p^2q^2+q^4 | |
=(p^2+q^2)^2 =c^2\). | |
% Acknowledgments---Will not appear in anonymized version | |
\acks{We thank a bunch of people.} | |
\bibliography{samplebibliography} | |
\appendix | |
\section{Proof of Theorem 1} | |
This is a boring technical proof of | |
\begin{equation}\label{eq:example} | |
\cos^2\theta + \sin^2\theta \equiv 1. | |
\end{equation} | |
\section{Proof of Theorem 2} | |
This is a complete version of a proof sketched in the main text with | |
some inline math $\cos^2\theta + \sin^2\theta \equiv 1$ and $\vv{AB}$. | |
\end{document} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@book{Lamport:Book:1989, | |
author = {Lamport, Leslie}, | |
title = {Latex: A Document Preparation System}, | |
year = {1986}, | |
isbn = {0-201-15790-X}, | |
publisher = {Addison-Wesley Longman Publishing Co., Inc.}, | |
address = {Boston, MA, USA}, | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\Preamble{xhtml,mathml,mathjax,fn-in} | |
\begin{document} | |
\EndPreamble |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\Preamble{xhtml,mathml,mathjax,fn-in,NoFonts,-css} | |
% Provide configurations for em and textit, as they are by default dealt only by css | |
% See https://tex.stackexchange.com/questions/70059/generation-of-simple-css-less-html-with-htlatex/70061#70061 | |
\Configure{emph}{\ifvmode\ShowPar\fi\HCode{<em>}}{\HCode{</em>}} | |
\Configure{textbf}{\ifvmode\ShowPar\fi\HCode{<b>}}{\HCode{</b>}} | |
\begin{document} | |
\EndPreamble |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment