No description
Find a file
Yann Esposito (Yogsototh) e17a27f024 More github friendly README
2010-11-10 11:58:30 +01:00
content More github friendly README 2010-11-10 11:58:30 +01:00
filters Added the \textbar{} filter 2010-11-08 17:33:24 +01:00
include Many L&F improvements and README update 2010-11-10 11:47:11 +01:00
.gitignore A bit cleaner generation (tmp file in tmp dir) 2010-11-04 10:33:52 +01:00
config.rb Many L&F improvements and README update 2010-11-10 11:47:11 +01:00
krambook.pdf Cleaner compilation (all in tmp) 2010-11-09 11:32:47 +01:00
Rakefile make more versatile configuration 2010-11-09 11:58:15 +01:00
README.md More github friendly README 2010-11-10 11:58:30 +01:00

Write Books like a Hacker

Quality and scalability of XeLaTeX & readable as Markdown.

Idea: provide macros for Markdown then transform the text in Latex and generate a pdf file.

Why not using LaTeX directly? 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

Why macros are so necessary for long documents? Because without them, %markdown simply does not scale. For example imagine you can't declare \su to be generated as $$\sum_{n=0}^{\infty} u_n$$ in a thesis where this expression is repeated 1000 times.

Install

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.

How do I write a book using it?

  • 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 (or rake 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

Macros

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.


  1. %kramdown is an amelioration of the original markdown format. ↩︎