ScholarlyMarkdown: a Markdown-compatible plaintext format for academic communication

Tim T.Y. Lin
January 1, 2000

Abstract

This is the abstract! It should show up at the beginning of the page.

ScholarlyMarkdown math support

Math as (fenced) code blocks

This is a line of text with a simple code block in it.

`this should be just a `normal` inline code block surrounded by literal backticks`

This is another line of text. Here should be some math: \(\mathbf{F = ma}<2\mathbf{ma}\). There should be some displaymath environment on the following line \[ \begin{equation*} \mathbf{F = ma} < 2\mathbf{ma} \end{equation*} \] and there should be no line breaks between the displaymath block and here. This should be bold. This should be italic.

The following is a displaymath with an aligned environment in a separate paragraph (preceded with, and followed by, two blank lines), with identifier matheqn1. It should automatically be wrapped with the aligned environment.

\[ \begin{equation} \label{matheqn1} \begin{aligned} \tag{BIGLABEL} \mbox{minimize}\quad & \fx = \max_{i=1,\ldots,m} (a_i^T x + b_i) \\ & \|x\|_2 \le \sigma. \end{aligned} \end{equation} \]

Here is an implicit align math environment consisting of multiple lines of equations with no newline in between, with at least one & symbol in the whole expression. It should be in the same paragraph as this one. \[ \begin{align} \nonumber \sum_{j_1, j_2, \ldots j_m} \sum_{k_1, k_2, \ldots, k_m} & \widetilde{A}_{j_1,k_1}^{\ast} \widetilde{A}_{j_1,k_2} \tilde{A}_{j_2,k_2}^{\ast} \widetilde{A}_{j_2,k_3} \ldots \widetilde{A}_{j_m,k_m}^{\ast} \widetilde{A}_{j_m,k_1}\\ \label{middleAlignMathNumber} = \sum_{j_1, j_2, \ldots j_m} \sum_{k_1, k_2, \ldots, k_m} & \left( R_{\Lambda} T_{k_1}^{\ast} P_{\Omega} T_{j_1} R_{\Lambda}^{\ast} \right) \left( R_{\Lambda} T_{j_1}^{\ast} P_{\Omega} T_{k_2} R_{\Lambda}^{\ast} \right) \left( R_{\Lambda} T_{k_2}^{\ast} P_{\Omega} T_{j_2} R_{\Lambda}^{\ast} \right)\\ \nonumber & \left( R_{\Lambda} T_{j_2}^{\ast} P_{\Omega} T_{k_3} R_{\Lambda}^{\ast} \right) \ldots \left( R_{\Lambda} T_{k_m}^{\ast} P_{\Omega} T_{j_m} R_{\Lambda}^{\ast} \right) \left( R_{\Lambda} T_{j_m}^{\ast} P_{\Omega} T_{k_1} R_{\Lambda}^{\ast} \right). \end{align} \] And here is an implicit gather math environment consisting of multiple lines of equations with no newline in between, with & symbol not appearing in every statement: \[ \begin{gather} \label{firstGatherMathNumber} \left.\begin{aligned} B'&=-\partial\times E\\ E'&=\partial\times B - 4\pi j \end{aligned} \right\} \quad \textsf{Maxwell's equations}\\ \label{secondGatherMathNumber} A = B\\ \label{thirdgathernumber} AAAAAAA = BBBBBB \end{gather} \]

Single math equations that have line-breaks (the \\ command) are automatically wrapped in a split environment. If alignment commands (symbol &) also exist, they get wrapped in an aligned environment instead. This behaviour can be disabled using the math_plain environment: \[ \begin{equation*} \begin{split} y = ax \\ f = kg^{-1} \end{split} \end{equation*} \] \[ \begin{equation*} \begin{aligned} y &= ax \\ f &= kg^{-1} \end{aligned} \end{equation*} \] The following has an ampersand and line breaks in comma, but is actually a single-line equation that should be untouched: \[ \begin{equation*} |y|\ \&\ |x| % an & and \\ that should be ignored = 99\% z % an & and \\ that should be ignored \end{equation*} \] Below is more internal vertical alignment tests. The first is one that uses cases internally: \[ \begin{equation} \label{matheqn2} P_{r-j}=\begin{cases} 0& \ensuremath\text{if $r-j$ is odd},\\ r!\,(-1)^{(r-j)/2}& \text{if $r-j$ is even}, \end{cases} \end{equation} \] and another one that uses aligned internally. \[ \begin{equation} \label{matheqn3} \left.\begin{aligned} B'&=-\partial\times E\\ E'&=\partial\times B - 4\pi j \end{aligned} \right\} \qquad \text{Maxwell's equations} \end{equation} \]

Math and lists

Here’s a list with both inline and display math environments:

\[ \begin{equation*} \mathbf{F_2 = m_2a} \end{equation*} \]

  without breaking this text out of the list and into a pre block

Scholarly X-refs

References to figures

This line refers to Figure 3.

This line refers to Figure 2.

This line refers to subfigure (2c).

References to equations

This line refers to Equation \(\eqref{matheqn3}\).

Referencing using the \ref tag: Equation \(\ref{matheqn1}\).

Referencing using the \eqref tag: Equation \(\eqref{middleAlignMathNumber}\).

Automatic non-breaking spaces

Any cross-references (such as Equation \(\ref{middleAlignMathNumber}\)) will automatically be prepended with non-breaking spaces.

Unless, they appear in a list like equations \(\ref{matheqn1}\), \(\ref{matheqn2}\), \(\ref{matheqn3}\), and \(\ref{middleAlignMathNumber}\).

ScholarlyMarkdown Figures

Images with attributes

The following will be a bunch of figures with attributes: Regular link with attributes Reference link with attributes Which should all show fine and display a picture with a baby seal.

Below is more text so that the css doesn’t end abruptly! Now we’ll have an explicit Scholarly Figure environment!

ScholarlyMarkdown figure/multifigures

Figure1Single-image figure. You can also have citations inside captions [@Gill].
(a)sub
(b)subfig
(c)longer subcaption that flows
Figure2Reference link in its own paragraph and long caption Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
(a)fdsaf
(b)woogawooga
Figure3Reference link in its own paragraph and long caption Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.

ScholarlyMarkdown Algorithms

Here are some algorithms using various methods. The “most canonical one” is currently just using a line-block:

1. Inputs: variables \(A, b\)
2. Output\(\phi\)                //this is a comment

3. Choose an initial guess \(\phi\) to the solution
4.  repeat until convergence
5.    for \(i\) from 1 until \(n\) do
6.        \(\sigma \leftarrow 0\)
7.        for \(j\) from 1 until \(n\) do
8.            if \(j \ne i\) then
9.               \(\sigma \leftarrow \sigma + a_{ij} \phi_j\)
10.            end if
11.        end (\(j\)-loop)
12.        \(\phi_i \leftarrow \frac 1 {a_{ii}} (b_i - \sigma)\)
13.    end (\(i\)-loop)
14.    check if convergence is reached
15. end (repeat)

Algorithm1caption for this algorithm

 Inputs: variables \(A, b\)
 Output\(\phi\)

 Choose an initial guess \(\phi\) to the solution
 repeat until convergence
      for \(i\) from 1 to \(n\) do
          \(\sigma \leftarrow 0\)
          for \(j\) from 1 to \(n\) do
               if \(j \ne i\) then
                    \(\sigma \leftarrow \sigma + a_{ij} \phi_j\)
               end if
          end (\(j\)-loop)
          \(\phi_i \leftarrow \frac 1 {a_{ii}} (b_i - \sigma)\)
      end (\(i\)-loop)
      check if convergence is reached
 end (repeat)

Algorithm2

The should not be a caption

 Inputs: variables \(A, b\)
 Output\(\phi\)

 Choose an initial guess \(\phi\) to the solution
 repeat until convergence
      for \(i\) from 1 to \(n\) do
          \(\sigma \leftarrow 0\)
          for \(j\) from 1 to \(n\) do
               if \(j \ne i\) then
                    \(\sigma \leftarrow \sigma + a_{ij} \phi_j\)
               end if
          end (\(j\)-loop)
          \(\phi_i \leftarrow \frac 1 {a_{ii}} (b_i - \sigma)\)
      end (\(i\)-loop)
      check if convergence is reached
 end (repeat)

Algorithm3This should should be a caption

ScholarlyMarkdown Tables

Standard Pandoc tables

The following is a normal Pandoc table

Thisis a caption
Right Left Default Center
12 12 12 12
123 123 123 123
1 1 1 1

This should not be a caption

Scholarly tables

The following is a floated ScholMD table

Right Left Default Center
12 12 12 12
123 123 123 123
1 1 1 1
Table1This is a really really really really really really really really really really really really really really really really really really really really really really really really really really really long caption

ScholarlyMarkdown Code blocks

Standard Pandoc code blocks

fenced blocks

Value   <- [0-9.]+ / '(' Expr ')'
Product <- Expr (('*' / '/') Expr)*
Sum     <- Expr (('+' / '-') Expr)*
Expr    <- Product / Sum / Value

indented blocks

Value   <- [0-9.]+ / '(' Expr ')'
Product <- Expr (('*' / '/') Expr)*
Sum     <- Expr (('+' / '-') Expr)*
Expr    <- Product / Sum / Value

Scholarly code block floats

100
101
102
103
Value   <- [0-9.]+ / '(' Expr ')'
Product <- Expr (('*' / '/') Expr)*
Sum     <- Expr (('+' / '-') Expr)*
Expr    <- Product / Sum / Value
Listing1Parsing Expression Grammar rules for a simple calculator using PEG.
Value   <- [0-9.]+ / '(' Expr ')'
Product <- Expr (('*' / '/') Expr)*
Sum     <- Expr (('+' / '-') Expr)*
Expr    <- Product / Sum / Value
Listing2Parsing Expression Grammar rules for a simple calculator.