TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've used LaTeX a lot in the past, but now (thanks to StackOverflow's great editor!), I find it annoying/boring, for short documents (< 2 pages), to have to use pure LaTeX.

For a short document, instead of having 30 lines as introduction:

\begin{document}
\documentclass[11pt,a4paper]{article}
\usepackage[frenchb]{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{amsfonts} + <lots of other things>

I'd like to write my short document with MarkDown + Math, like on math.stackexchange.com.

Question:

Is there an offline compiler such that

compilemarkdown exercice.tex

would produce a PDF from this:

#Title

Here is a *short document* including Markdown and Math, here is the equation:

$$f(x)=x^2$$

___

Proof: ... 

This is **bold**.
share|improve this question

closed as off-topic by Martin Schröder, Papiro, Maarten Dhondt, Jesse, Christian Hupfer Feb 14 at 17:00

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question does not fall within the scope of TeX, LaTeX or related typesetting systems as defined in the help center." – Martin Schröder, Papiro, Maarten Dhondt, Jesse, Christian Hupfer
If this question can be reworded to fit the rules in the help center, please edit the question.

    
Well, not a solution, but many LaTeX editors allow to use templates. So you can create one and then just open it. I created one and then I just call it on Linux terminal fastex and the editor opens with my minimal template. – Sigur Feb 1 at 19:50
    
@Sigur I already use templates, but this is not really a solution. To sum up the idea : now that I'm used to mix Markdown and Latex/Mathjax (thanks StackExchange!), I really want to have this great way of writing short documents offline. No more 30 lines of \usepackage[frenchb]{babel} \usepackage[latin1]{inputenc}... I want to keep the goodness of StackEdit / StackExchange's editor offline, as a compiler like latex. – Basj Feb 1 at 19:54
1  
try pandoc's new non-latex pdf generation. – erreka Feb 1 at 20:00
1  
@Basj Okay, I think pandoc will work for you then. I've posted an answer that uses pandoc. – Null Feb 1 at 20:04
1  
Why would you want to do this in LaTeX? There is a ton of markdown editors which do exactly that. You write markdown + mathjax, then export as either PDF or LaTeX. There are cloud solutions, Windows solutions, Linux solutions... – rumtscho Feb 2 at 9:15
up vote 16 down vote accepted

This is possible with pandoc. If the Markdown you've posted is in the file test.md you can generate a PDF called test.pdf with the following command:

pandoc test.md -o test.pdf

The PDF file looks like this:

enter image description here

pandoc converts the Markdown to a PDF using LaTeX. It recognizes that the input is Markdown from the file extension, but if you use a different file extension you can include -f markdown to instruct pandoc to convert from Markdown. The -o test.pdf part of the command tells pandoc to output a PDF with the given filename.

The pandoc website has a nice getting started guide.

share|improve this answer
    
Really really nice. Installed and already working! This is really LaTeX's future. I will always use this for small documents now! Wonderful. – Basj Feb 1 at 20:09
    
@Basj Glad to hear you like it! – Null Feb 1 at 20:12
    
If someone has a SublimeText .sublime-build build system file to share, I'm in heaven :) – Basj Feb 1 at 20:14

I'd use RedNotebook for notes and small documents. It's really a journal or diary, but it lets me to take quick notes with (modified) markdown and MathJax (with webkit), and then, if necessary, to export to html or pdf or LaTeX.

If I type:

= Title =

Here is a //short document// including Markdown and Math, here is the equation:

$$f(x)=x^2$$

====================

Proof: ... 

This is **bold**.

I get this (edition mode):

Editor

and this (preview):

Preview

Then you export to pdf, which looks like this:

PDF output

(Output font can be changed from Preferences).

share|improve this answer
    
Nice as well! Thanks. – Basj Feb 1 at 20:14

What I meant by my original comment is this: with pandoc -t html5 -o test.pdf test.md you can bypass LaTeX entirely; you are only required to install wkhtmltopdf, which is a single executable like pandoc on windows.

Results as follows:

Result with wkhtmltopdf, without LaTeX

You may control the output with css.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.