The Hybrid Format (.md)

Write Markdown that compiles to a full LaTeX document, with raw LaTeX wherever you need it.

A Markdown file can be the main file of a TeXposit project. When you compile it, TeXposit converts it to a complete LaTeX document and typesets that on the server. You write plain Markdown for prose and drop into raw LaTeX only where Markdown is not expressive enough.

The syntax follows Pandoc-style Markdown. This page covers what TeXposit does with it.

Starting a Markdown file

  • To start a whole project, choose Markdown Project when you create it.
  • To add a file to an existing project, create a new file from the Markdown or Markdown LaTeX template.
  • To compile an existing Markdown file, set it as the project's main file in Project Settings under Build.

Markdown files open in the visual editor by default. See Markdown and the visual editor for switching to the source view.

No preamble needed

A Markdown file does not need a preamble. TeXposit generates the document class and layout for you:

  • 12pt text with 1-inch margins
  • numbered sections
  • title, author, date and abstract taken from the YAML block at the top of the file

What converts to what

  • Math: $...$ for inline math and $$...$$ for display math. Leave a blank line before and after a display block.
  • Citations: [@key] gives a numbered citation such as [1]. @key without brackets puts the author name in the sentence: Vaswani et al. [1]. Both use the natbib package.
  • Tables: Markdown pipe tables become LaTeX tables with booktabs rules.
  • Code: fenced code blocks are typeset with the listings package. They are display only and are not executed.
  • Images: ![Caption](file.png){width=30%} inserts a figure.
  • Headings: #, ## and ### become sections, subsections and subsubsections.

For complex tables, merged cells or custom figure environments, write raw LaTeX instead of fighting the Markdown syntax.

Raw LaTeX

Raw LaTeX is passed through unchanged. For longer blocks, use a fenced block marked {=latex}:

```{=latex}
\begin{figure}[ht]
  \centering
  \includegraphics[width=0.8\linewidth]{fig1.pdf}
  \caption{Results.}
\end{figure}
```

Bibliography

Add the bibliography commands at the end of the file, exactly as in a .tex file:

\bibliographystyle{unsrtnat}
\bibliography{references}

Use one citation style per document. Do not mix [@key] and \cite{} for the same reference.

Example

---
title: My Research Paper
author: Jane Doe
abstract: |
  This abstract is formatted into a standard
  LaTeX abstract environment.
---

# Introduction

We can use **Markdown** for text and still use LaTeX.

## Citations and math

As noted in [@vaswani2017], attention is the key mechanism.
Here, $n_{\text{features}} = 128$.

## Images

![TeXposit logo](texposit_logo.png){width=30%}

## A raw LaTeX table

\begin{center}
\begin{tabular}{lc}
\toprule
Metric & Value \\
\midrule
Accuracy & 98.2\% \\
\bottomrule
\end{tabular}
\end{center}

\bibliography{references}

Common mistakes

  • Do not write \[@key\]. The brackets need no escaping, and a backslash breaks the citation.
  • Do not start a sentence with [@key]. It renders as a bare number. Use @key when the author is the subject of the sentence.
  • Inside $...$, an underscore means a subscript. Write \_ for a literal one.
  • \\ for a line break does nothing useful in prose. Use a blank line for a new paragraph.

Document files

A file ending in .doc.md is different. It is a formatted page-view document with headers, footers and page numbers, edited only in the visual editor and never compiled with LaTeX. Use it for letters and reports where you do not need LaTeX output. You can create one from the Document project type or the Document (.doc.md) file template.