This project has two homes. It is ok to work in github, still, for a better decentralized web please consider contributing (issues, PR, etc...) throught:
This project intends to provide you a cool way to write a book.
You write text file using the natural markdown syntax. The book can then be generated as PDF using %xelatex or to an HTML website.
You can see examples of standard end result here:
The best typesetting system I know is LaTeX. Unfortunately LaTeX was created a long time ago and its syntax is full of backslashes. Here is an example of a standard minimal LaTeX document:
\documenttype{article}
\usepackage[utf-8]{inputenc}
\usepackage{fontenc}
\usepackage{amsmath}
... % This is the ritual header
\begin{document} % ---- end of the preamble
\section{First section}
I begin by making a list of bullet points:
\begin{itemize}
\item the first point is
\LaTeX is a bit verbose
\item the second point is
\Latex has \textem{more} \textbackslash{} than Markdown
\item I believe you understood now.
\end{itemize}
\end{document}
To achieve a similar result using a markdown
syntax:
First section
=============
I begin by making a list of bullet points:
- the first point is LaTeX is a bit verbose
- the second point is LaTeX has _more_ \ than Markdown
- I believe you understood now
The HTML end result using the markdown will be:
I begin by making a list of bullet points:
- the first point is LaTeX is a bit verbose
- the second point is LaTeX has more \ than Markdown
- I believe you understood now
I believe I don't need more to convince you the markdown feel more natural than LaTeX.
LaTeX has many incredible properties that makes it scalable even for very long document. Markdown wasn't created for this purpose and so lack many features. Many language tried to extend Markdown (for example Kramdown).
None of these extension made the new language scalable enough. These new languages are stricly inferior to the power of the TeX language. In fact TeX is Turing complete -- considering we have the ability to make many compilations until reaching a fixed point.
An essential feature are macros. In LaTeX you can declare macros like this:
\newcommand{\un}{\sum_{n=0}^\infty u_n}
And each time you type:
Here is a formula $\un = \pi$
It will be equivalent to:
Here is a formula $\sum_{n=0}^\infty u_n = \pi$
Imagine a thesis where this formula is present a hundred times and you begin to understand why macros are a necessity for long documents. But in LaTeX you could also declare macros with parameters and that use other declared macros:
\newcommand{\ratlang}[2]{\mathcal{S}_{#1}^{\mathrm{rat}}(#2)}
\newcommand{\sr}[2]{\ratlang{\mathbb{R}}(\Sigma)}
...
Let us denote $\sr$ the class of rationnal stochastic language over $\mathbb{R}$ with alphabet $\Sigma$.
Now you see the power of LaTeX.
There is also another thing that make LaTeX scalable. You can include other source files. This make it easy to separate work and also to work with many other people.
Another good point with LaTeX and markdown is that you write only in text file
and you can then version these file using git
for example.
The purposes of this project are:
- Handle long documents by:
- adding macros to kramdown
- working with many small and versionable text files
- generate high-quality PDF and HTML documents.
For now, the power of this superset of kramdown syntax is not Turing complete. You can declare macros, but without any parameters and you cannot use already declared macros inside other macros declaration. But this simple addition to markdown is already powerful enough for most of usage.
Provide macros for Markdown then transform the text in Latex and generate a pdf
file.
Simply because LaTeX is verbose and full of backslashes. To prove my point, simply compare a LaTeX and a Markdown file.
LaTeX:
\documenttype{article}
\usepackage[utf-8]{inputenc}
\usepackage{fontenc}
\usepackage{amsmath}
... % This is the ritual header
\begin{document} % ---- end of the preamble
I begin by making a list of bullet points:
\begin{itemize}
\item the first point is
\LaTeX is a bit verbose
\item the second point is
\Latex has \textem{more} \textbackslash{} than Markdown
\item I believe you understood now.
\end{itemize}
\end{document}
Markdown:
I begin by making a list of bullet points:
- the first point is LaTeX is a bit verbose
- the second point is LaTeX has _more_ \ than Markdown
- I believe you understood now
Both file will be generated as:
I begin by making a list of bullet points:
- the first point is LaTeX is a bit verbose
- the second point is LaTeX has more \ than Markdown
- I believe you understood now
Because without them, Markdown simply does not scale. For example imagine you can't declare \su
to be generated as
If you are reading these lines, chances are great that your system contains all necessary packages. But to resume you have to install:
- LaTeX (more precisely XeLaTeX),
- ruby,
- rake and
- %kramdown1.
To install XeLaTeX, I suggest you to use TexLive full install? But of course you are free to use any other distribution.
You'll need to install ruby and rake. They should be present on your system, but just in case:
[Ubuntu]> sudo apt-get install ruby rake
[Mac OS X]> sudo port install ruby rake
In order to install the %kramdown gem:
gem install kramdown
Finally Download this source code and your installation should be over.
- Edit the
config.rb
file (set title, author name and pdf filename) - Create and write files in the
content
folder. You should write them using the kramdown format. Very close to the Mardown format. - run
rake
(orrake compile
) to create and show a.pdf
file.
Remark:
: by default file are sorted by name. I suggest you to name your files and folder with number prefixes. For example like 00_intro.md
, 01_section/01_subsection.md
, etc... You can make a bit of ruby
(search @filelist
in the Rakefile
file) to change this behaviour.
Of course there is also a
rake clean
and
rake clobber
Now you can write the content of your book mostly in %kramdown format. But with some simple additions: macros.
Remark: for now Krambook accept only macros without any parameter. Here are some examples:
%%% simple %%% A Simple Macro %%%
%%% amacro %%% a
macro
on many lines %%%
%%% code %%% ruby: "a"*3 %%%
%%% complex %%% ruby: (1..5).map do |x|
x*x
end.join(" : ") %%%
These transformations will occur on the markdown file before it is transformed in LaTeX.
You can also declare macro that will be processed after the file was transformed in LaTeX.
LLL latex LLL \LaTeX LLL
LLL latex_ LLL \LaTeX{} LLL
In markdown, you simply write %macroname or %code and it will be transformed correctly in your pdf.
To render math properly install MathJax into the site/js
directory
Footnotes
-
%kramdown is an amelioration of the original markdown format. ↩