$$
\newcommand{\bra}{\langle}
\newcommand{\ket}{\rangle}
\newcommand{\set}[1]{\{\ #1 \ \}}
\newcommand{\sett}[2]{\{\ #1 \ |\ #2 \}}
\newcommand{\id}{\mathbb{\,I\,}}
$$
\title{MiniLatex Demo}
% \author{James Carlson}
% \email{jxxcarlson@gmail.com}
% \date{August 5, 2018}s
\maketitle
% EXAMPLE 1
\begin{comment}
This multi-line comment
should also not
be visible in the
rendered text.
\end{comment}
\tableofcontents
\section{Introduction}
MiniLatex is a subset of LaTeX that can be
rendered live in the browser, as demonstrated
by this app. For a simple MiniLatex editor, see
\href{https://jxxcarlson.github.io/app/miniLatexLive/index.html}{MiniLatex Live}.
For a full content-management system based on MiniLatex,
see \href{https://knode.io}{knode.io}.
MiniLatex is still a research project, albeit
advancing rapidly. I need your feedback to make
it better: jxxcarlson at gmail.
The design of
MiniLatexSee is discussed in \cite{H}
and \cite{T}, and the source code is found at \cite{S}.
For an example of a long
MiniLatex document, see
\href{https://www.knode.io/424}{QF Notes}
\mdash then click on the document title, which
you will find in \blue{blue}, to see
the table of contents.
\section{Formulas}
% \italic{Try editing formula \eqref{integral:xn} or \eqref{integral:exp} below.}
Some math formulas, beginning with the most basic integral:
\begin{equation}
% \label{integral:xn}
\int_0^1 x^n dx = \frac{1}{n+1}
\end{equation}
An improper integral:
\begin{equation}
% \label{integral:exp}
\int_0^\infty e^{-x} dx = 1
\end{equation}
\section{Math-mode Macros}
It is easy to define new math-mode macros
in MiniLatex:
\begin{verbatim}
$$
\newcommand{\bra}{\langle}
\newcommand{\ket}{\rangle}
\newcommand{\set}[1]{\{\ #1 \ \}}
\newcommand{\sett}[2]{\{\ #1 \ |\ #2 \}}
$$
\end{verbatim}
Thus, if we say
\begin{verbatim}
$$
\bra x | y \ket = \bra y | x \ket.
$$
\end{verbatim}
then we get this:
$$
\bra x | y \ket = \bra y | x \ket.
$$
And if we say
\begin{verbatim}
$A = \set{a \in Z, a \equiv 1\ mod\ 2}$
$B = \sett{a,b,c}{a,b,c \in Z}$
\end{verbatim}
then we get the following:
$A = \set{a \in Z, a \equiv 1\ mod\ 2}$
$B = \sett{a,b,c}{a,b,c \in Z}$
\section{Text-mode Macros}
\newcommand{\hello}[1]{Hello \strong{#1}!}
We have added an experimental macro expansion feature that permits
the author to define new text-mode macros in a MiniLatex document.
For example, if we add the text
\newcommand{\boss}{Phineas Fogg}
\begin{verbatim}
\newcommand{\boss}{Phineas Fogg}
\end{verbatim}
then saying
\begin{verbatim}
\italic{My boss is \boss.}
\end{verbatim}
produces \italic{My boss is \boss.}
Likewise, if one says
\begin{verbatim}
\newcommand{\hello}[1]{Hello \strong{#1}!}
\end{verbatim}
then the macro \backslash{hello}\texarg{John} renders as \hello{John}
For one more example, make the definition
\begin{verbatim}
\newcommand{\reverseconcat}[3]{#3#2#1}
\end{verbatim}
\newcommand{\reverseconcat}[3]{#3#2#1}
Then \backslash{reverseconcat}\texarg{A}\texarg{B}\texarg{C} = \reverseconcat{A}{B}{C}
The macro expansion feature will need a lot more work and testing.
We also plan to add a feature so that authors can define new environments.
\section{MiniLatex Macros}
MiniLatex has a number of macros of its own, For
example, text can be rendered in various colors, \red{such as red}
and \blue{blue}. Text can \highlight{be highlighted}
and can \strike{also be struck}. Here are the macros:
\begin{verbatim}
\red
\blue
\highlight
\strike
\end{verbatim}
\section{Theorems}
\begin{theorem}
There are infinitely many prime numbers.
\end{theorem}
\begin{theorem}
There are infinitley many prime numbers
$p$ such that $p \equiv 1\ mod\ 4$.
\end{theorem}
\section{Images}
\image{http://psurl.s3.amazonaws.com/images/jc/beats-eca1.png}{Figure 1. Two-frequency beats}{width: 350, align:
center}
\section{Lists and Tables}
A list
\begin{itemize}
\item This is \strong{just} a test.
\item \italic{And so is this:} $a^2 + b^2 = c^2$
\begin{itemize}
\item Items can be nested
\item And you can do this:
$ \frac{1}{1 + \frac{2}{3}} $
\end{itemize}
\end{itemize}
A table
\begin{indent}
\strong{Light Elements}
\begin{tabular}{ l l l l }
Hydrogen & H & 1 & 1.008 \\
Helium & He & 2 & 4.003 \\
Lithium& Li & 3 & 6.94 \\
Beryllium& Be& 4& 9.012 \\
\end{tabular}
\end{indent}
\section{Technology}
MiniLatex is written in \href{http://elm-lang.org}{Elm}, the statically typed functional
programming language created by Evan Czaplicki. Because of its excellent
\href{http://package.elm-lang.org/packages/elm-tools/parser/latest}{parser combinator library}, Elm is an ideal
choice for a project like the present one.
For an overview of the design of MiniLatex, see
\href{https://hackernoon.com/towards-latex-in-the-browser-2ff4d94a0c08}{Towards Latex in the Browser}.
Briefly, \href{https://www.mathjax.org/}{MathJax} is used inside dollar signs, and Elm is used outside.
\bigskip
\section{References}
\begin{thebibliography}
\bibitem{G} James Carlson, \href{https://knode.io/628}{MiniLaTeX Grammar},
\bibitem{H} James Carlson, \href{https://hackernoon.com/towards-latex-in-the-browser-2ff4d94a0c08}{Towards LaTeX in
the Browser }, Hackernoon
\bibitem{S} \href{http://package.elm-lang.org/packages/jxxcarlson/minilatex/latest}{Source code}
\bibitem{T} James Carlson, \href{https://knode.io/525}{MiniLatex Technical Report}
\end{thebibliography}
MiniLatex Reader
MiniLatex Reader is a simple app for displaying LaTeX in a web browser. To display your own content, replace the current text in the div with id = 'source' by your text. To run MiniLatex Reader, you need two files, (1) 'index.html' and (2) 'Main.min.js'. These files, plus the source code for the Elm app, and some directions, can be found on GitHub. Note that the text below scrolls.
Note. MiniLatex Reader is running under MathJax 3.0 beta 2